修改发布渠道bug

main
whb 1 year ago
parent 163884a70c
commit b2917df971

@ -48,8 +48,6 @@ public class CptfController {
private FbqdStuAnswerMapper fbqdStuAnswerMapper;
@Autowired
StuGradeMapper stuGradeMapper;
@Autowired
@ -70,31 +68,31 @@ public class CptfController {
StuGradeExample stuGradeExample = new StuGradeExample();
stuGradeExample.createCriteria().andUserIdEqualTo(fbqdStuAnswerDTO.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPDJ);
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
if(CollectionUtils.isEmpty(stuGradeList)){
if (CollectionUtils.isEmpty(stuGradeList)) {
// FbqdAnswer answer = fbqdAnswerMapper.selectByExampleWithBLOBs(new FbqdAnswerExample()).get(0);
int count = 0;
//1.
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);
int count1 = calculte(dataInfoList, 1, oneAnswer);
//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);
int count2 = calculte(radioInfoList, 2, twoAnswer);
//3.
List<FbqdDTO> messageInfoList = fbqdStuAnswerDTO.getMessageInfoList();
String threeAnswer = "0.6305,0.5342,0.4066,0.5243";
int count3 =calculte(messageInfoList,3,threeAnswer);
int count3 = calculte(messageInfoList, 3, threeAnswer);
//4.
List<FbqdDTO> eventInfoList = fbqdStuAnswerDTO.getEventInfoList();
String fourAnswer = "0.1940,0.2446,0.3116,0.2498";
int count4 = calculte(eventInfoList,4,fourAnswer);
int count4 = calculte(eventInfoList, 4, fourAnswer);
//5.综合评分
String fiveAnswer = "1,0.1503,0.2751";
@ -106,28 +104,27 @@ public class CptfController {
int i = compareListsUtil.calculateLengthPenaltyEnhanced(fbqdStuAnswerDTO.getScenePromotion());
count= count1 + count2+count3+count4+i + fiveCount;
count = count1 + count2 + count3 + count4 + i + fiveCount;
FbqdStuAnswer fbqdStuAnswer = new FbqdStuAnswer();
fbqdStuAnswer.setId(IdUtil.simpleUUID());
fbqdStuAnswer.setUserId(fbqdStuAnswerDTO.getUserId());
fbqdStuAnswer.setCrowdPromotion( JSON.toJSONString(fbqdStuAnswerDTO));
fbqdStuAnswer.setCrowdPromotion(JSON.toJSONString(fbqdStuAnswerDTO));
fbqdStuAnswerMapper.insertSelective(fbqdStuAnswer);
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, "提交成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败");
}
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
}
}
@ApiOperation("发布渠道-回显接口")
@GetMapping("/selectByCpdjUserId")
@AnonymousAccess
@ -149,58 +146,55 @@ public class CptfController {
}
@GetMapping("/restartTraining")
@ApiOperation("产品投放-重新实训")
@AnonymousAccess
public ResultEntity restartTraining(@RequestParam String userId,@ApiParam("重新实训的模块名") String module) {
public ResultEntity restartTraining(@RequestParam String userId, @ApiParam("重新实训的模块名") String module) {
if (Constant.MODULE_FBQDPG.equals(module)) {
Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPTFCS,module);
if(b){
Boolean b = scoreService.deleteScore(userId, Constant.PRO_CPTFCS, module);
if (b) {
FbqdStuAnswerExample cpdjStuAnswerExample = new FbqdStuAnswerExample();
cpdjStuAnswerExample.createCriteria().andUserIdEqualTo(userId);
fbqdStuAnswerMapper.deleteByExample(cpdjStuAnswerExample);
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
}
}
if (Constant.MODULE_CPTGCS.equals(module)) {
Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPTFCS,module);
if(b){
Boolean b = scoreService.deleteScore(userId, Constant.PRO_CPTFCS, module);
if (b) {
CptgcsStuAnswerExample cptgcsStuAnswerExample = new CptgcsStuAnswerExample();
cptgcsStuAnswerExample.createCriteria().andUserIdEqualTo(userId);
cptgcsStuAnswerMapper.deleteByExample(cptgcsStuAnswerExample);
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
}
}
if (Constant.MODULE_CPTGCS.equals(module)) {
Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPGH,module);
if(b){
Boolean b = scoreService.deleteScore(userId, Constant.PRO_CPGH, module);
if (b) {
CptgcsStuAnswerExample cptgcsStuAnswerExample = new CptgcsStuAnswerExample();
cptgcsStuAnswerExample.createCriteria().andUserIdEqualTo(userId);
cptgcsStuAnswerMapper.deleteByExample(cptgcsStuAnswerExample);
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
}
}
if (Constant.MODULE_CPYXDW.equals(module)) {
Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPGH,module);
if(b){
Boolean b = scoreService.deleteScore(userId, Constant.PRO_CPGH, module);
if (b) {
CpyxdwStuAnswerExample cpyxdwStuAnswerExample = new CpyxdwStuAnswerExample();
cpyxdwStuAnswerExample.createCriteria().andUserIdEqualTo(userId);
cpyxdwStuAnswerMapper.deleteByExample(cpyxdwStuAnswerExample);
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
}
}
@ -210,16 +204,12 @@ public class CptfController {
}
@Autowired
private CptgcsAnswerMapper cptgcsAnswerMapper;
@Autowired
private CptgcsStuAnswerMapper cptgcsStuAnswerMapper;
@PostMapping("/commitCptgcsAnswer")
@ApiOperation("产品推广测试-提交")
@AnonymousAccess
@ -228,7 +218,7 @@ public class CptfController {
StuGradeExample stuGradeExample = new StuGradeExample();
stuGradeExample.createCriteria().andUserIdEqualTo(stuAnswer.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPTGCS);
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
if(CollectionUtils.isEmpty(stuGradeList)){
if (CollectionUtils.isEmpty(stuGradeList)) {
CptgcsAnswer answer = cptgcsAnswerMapper.selectByExampleWithBLOBs(new CptgcsAnswerExample()).get(0);
int count = 0;
@ -239,7 +229,7 @@ public class CptfController {
//产品点击率 校验
//错误次数
int monthlyDataErrorCount =compareListsUtil.compareErrorCount(stuAnswerClickRate, clickRate).getErrorCount();
int monthlyDataErrorCount = compareListsUtil.compareErrorCount(stuAnswerClickRate, clickRate).getErrorCount();
count = count + monthlyDataErrorCount;
@ -248,17 +238,16 @@ public class CptfController {
String conversionRate = answer.getConversionRate();
//错误次数
int cheapSumCount =compareListsUtil.compareErrorCount(stuAnswerConversionRate, conversionRate).getErrorCount();
int cheapSumCount = compareListsUtil.compareErrorCount(stuAnswerConversionRate, conversionRate).getErrorCount();
count = count + cheapSumCount;
//3.投资回报率数据
String stuRoiData = stuAnswer.getRoiData();
String roiData = answer.getRoiData();
//错误次数
int cheapPercentageCount =compareListsUtil.compareErrorCount(stuRoiData, roiData).getErrorCount();
int cheapPercentageCount = compareListsUtil.compareErrorCount(stuRoiData, roiData).getErrorCount();
count = count + cheapPercentageCount;
@ -267,21 +256,19 @@ public class CptfController {
String orderAmount = answer.getOrderAmount();
//错误次数
int costEffectiveSumCount =compareListsUtil.compareErrorCount(stuAnswerOrderAmount, orderAmount).getErrorCount();
int costEffectiveSumCount = compareListsUtil.compareErrorCount(stuAnswerOrderAmount, orderAmount).getErrorCount();
count = count + costEffectiveSumCount;
//5.p值
String stuPValue = stuAnswer.getpValue();
String pValue = answer.getpValue();
//错误次数
int costEffectivePercentageCount =compareListsUtil.compareErrorCount(stuPValue, pValue).getErrorCount();
int costEffectivePercentageCount = compareListsUtil.compareErrorCount(stuPValue, pValue).getErrorCount();
count = count + costEffectivePercentageCount;
//主观题
int i = compareListsUtil.calculateLengthPenaltyEnhanced(stuAnswer.getContext());
count = count + i;
@ -290,20 +277,17 @@ public class CptfController {
cptgcsStuAnswerMapper.insertSelective(stuAnswer);
Boolean aBoolean = scoreService.insertScore(stuAnswer.getUserId(), Constant.PRO_CPTFCS, Constant.MODULE_CPTGCS, BigDecimal.valueOf(100 - count), stuAnswer.getContext());
if(aBoolean){
if (aBoolean) {
return new ResultEntity<>(HttpStatus.OK, "提交成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败");
}
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
}
}
@ApiOperation("产品推广测试-回显接口")
@GetMapping("/selectCptgcsByUserId")
@AnonymousAccess
@ -326,9 +310,6 @@ public class CptfController {
private CpyxdwStuAnswerMapper cpyxdwStuAnswerMapper;
@PostMapping("/commitCpyxdwAnswer")
@ApiOperation("产品营销定位-提交")
@AnonymousAccess
@ -337,14 +318,13 @@ public class CptfController {
StuGradeExample stuGradeExample = new StuGradeExample();
stuGradeExample.createCriteria().andUserIdEqualTo(stuAnswer.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPYXDW);
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
if(CollectionUtils.isEmpty(stuGradeList)){
if (CollectionUtils.isEmpty(stuGradeList)) {
int count = 0;
//1.产品点击率
String axis = stuAnswer.getxAxis();
if (axis!=null)
{
if (axis != null) {
if (!"点击率".equals(axis)) {
count++;
}
@ -352,16 +332,13 @@ public class CptfController {
String yAxis = stuAnswer.getyAxis();
if (yAxis!=null)
{
if (yAxis != null) {
if (!"转换率".equals(yAxis)) {
count++;
}
}
//主观题
int i = compareListsUtil.calculateLengthPenaltyEnhanced(stuAnswer.getAnalysis());
count = count + i;
@ -370,20 +347,17 @@ public class CptfController {
cpyxdwStuAnswerMapper.insertSelective(stuAnswer);
Boolean aBoolean = scoreService.insertScore(stuAnswer.getUserId(), Constant.PRO_CPTFCS, Constant.MODULE_CPYXDW, BigDecimal.valueOf(100 - count), stuAnswer.getAnalysis());
if(aBoolean){
if (aBoolean) {
return new ResultEntity<>(HttpStatus.OK, "提交成功");
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败");
}
}else {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
}
}
@ApiOperation("产品营销定位-回显接口")
@GetMapping("/selectCpyxdwByUserId")
@AnonymousAccess
@ -403,24 +377,19 @@ public class CptfController {
}
public Integer calculte( List<FbqdDTO> dataInfoList,Integer ser,String answer ) {
public Integer calculte(List<FbqdDTO> dataInfoList, Integer ser, String answer) {
int count = 0;
if (CollectionUtils.isEmpty(dataInfoList)) {
if (ser==1)
{
if (ser == 1) {
return 12;
}
if (ser==2)
{
if (ser == 2) {
return 12;
}
if (ser==3)
{
if (ser == 3) {
return 4;
}
if (ser==4)
{
if (ser == 4) {
return 4;
}
return 0;
@ -441,4 +410,54 @@ public Integer calculte( List<FbqdDTO> dataInfoList,Integer ser,String answer )
return count;
}
}
// @PostMapping("/commitCpyxdwAnswer")
// @ApiOperation("用户数据分析/产品定位-提交")
// @AnonymousAccess
// public ResultEntity commitCpyxdwAnswer(@RequestBody CpyxdwStuAnswer stuAnswer) {
// //先查询是否提交过
// StuGradeExample stuGradeExample = new StuGradeExample();
// stuGradeExample.createCriteria().andUserIdEqualTo(stuAnswer.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPYXDW);
// List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
// if (CollectionUtils.isEmpty(stuGradeList)) {
//
// int count = 0;
//
// //1.产品点击率
// String axis = stuAnswer.getxAxis();
// if (axis != null) {
// if (!"点击率".equals(axis)) {
// count++;
// }
// }
//
//
// String yAxis = stuAnswer.getyAxis();
// if (yAxis != null) {
// if (!"转换率".equals(yAxis)) {
// count++;
// }
// }
//
//
// //主观题
// int i = compareListsUtil.calculateLengthPenaltyEnhanced(stuAnswer.getAnalysis());
// count = count + i;
// stuAnswer.setId(IdUtil.simpleUUID());
//
// cpyxdwStuAnswerMapper.insertSelective(stuAnswer);
//
// Boolean aBoolean = scoreService.insertScore(stuAnswer.getUserId(), Constant.PRO_CPTFCS, Constant.MODULE_CPYXDW, BigDecimal.valueOf(100 - count), stuAnswer.getAnalysis());
// if (aBoolean) {
// return new ResultEntity<>(HttpStatus.OK, "提交成功");
// } else {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败");
// }
// } else {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
// }
// }
}

@ -93,25 +93,20 @@ public class CompareListsUtil {
// 将字符串分割成数组
String[] submitted = stulist.split(",");
String[] answers = answerList.split(",");
int errorCount = 0; // 错误数量
List<Integer> errorPositions = new ArrayList<>(); // 错误位置
// 获取较长数组的长度
int maxLength = Math.max(submitted.length, answers.length);
// 遍历较长的数组
for (int i = 0; i < maxLength; i++) {
String submittedValue = (i < submitted.length) ? submitted[i] : null;
String answerValue = (i < answers.length) ? answers[i] : null;
// 检查对应位置是否相同(处理数值和字符串)
if (!valuesEqual(submittedValue, answerValue)) {
errorCount++;
errorPositions.add(i + 1); // 位置从1开始
}
}
return new Result(errorCount, errorPositions);
}
@ -123,7 +118,6 @@ public class CompareListsUtil {
if (a == null || b == null) {
return false;
}
try {
// 尝试解析为Double比较数值
double numA = Double.parseDouble(a);
@ -134,5 +128,4 @@ public class CompareListsUtil {
return a.equals(b);
}
}
}

Loading…
Cancel
Save