溯源修改

master
whb 11 months ago
parent 746b671dc0
commit 08714699b6

@ -3,9 +3,11 @@ package com.sztzjy.block_finance.controller;
import com.nimbusds.jose.shaded.gson.Gson;
import com.sztzjy.block_finance.annotation.AnonymousAccess;
import com.sztzjy.block_finance.config.security.TokenProvider;
import com.sztzjy.block_finance.entity.StuBlockOnChain;
import com.sztzjy.block_finance.entity.StuPracticalTrainingReport;
import com.sztzjy.block_finance.entity.StuSupplyScore;
import com.sztzjy.block_finance.entity.dto.StuBlockProductWithBLOBs;
import com.sztzjy.block_finance.entity.dto.StuOnChainInfoDTO;
import com.sztzjy.block_finance.mappers.StuUploadResourceInfoMapper;
import com.sztzjy.block_finance.service.StuPublicService;
import com.sztzjy.block_finance.util.ResultDataEntity;
@ -48,6 +50,7 @@ public class StuPublicModuleController {
@PostMapping("/errorNumber")
@ApiOperation("6.统计错误次数")
@AnonymousAccess
public ResultEntity errorNumber(int number, String userId) {
publicService.errorNumber(number, userId);
@ -69,6 +72,7 @@ public class StuPublicModuleController {
@PostMapping("/upload")
@ApiOperation("7.上传实训报告")
@AnonymousAccess
public ResultDataEntity<StuPracticalTrainingReport> upload(@RequestParam(required = false) @RequestPart MultipartFile file,
@RequestParam(required = false) String stuBlockProduct) {
@ -106,6 +110,7 @@ public class StuPublicModuleController {
@GetMapping("/getReport")
@ApiOperation("9.获取实训报告详情")
@AnonymousAccess
public ResultDataEntity<StuPracticalTrainingReport> getReport(String userId) {
StuPracticalTrainingReport report = publicService.getReport(userId);
@ -124,6 +129,7 @@ public class StuPublicModuleController {
@GetMapping("/getScore")
@ApiOperation("5.操作记录和成绩")
@AnonymousAccess
public ResultEntity<List<StuSupplyScore>> getScore(String userId) {
List<StuSupplyScore> info = publicService.getScore(userId);
@ -133,7 +139,34 @@ public class StuPublicModuleController {
@GetMapping("/getOnChain")
@ApiOperation("2.区块上链")
@AnonymousAccess
public ResultEntity<StuOnChainInfoDTO> getOnChain(String userId) {
StuOnChainInfoDTO info = publicService.getOnChain(userId);
return new ResultEntity<StuOnChainInfoDTO>(HttpStatus.OK, info);
}
/**
*
*
* @param numbers
* @param userId
* @return
*/
@GetMapping("/getTrace")
@ApiOperation("3.发票溯源")
@AnonymousAccess
public ResultEntity<List<StuBlockOnChain>> getTrace(String numbers, String userId) {
List<StuBlockOnChain> info = publicService.getTrace(numbers, userId);
return new ResultEntity<List<StuBlockOnChain>>(HttpStatus.OK, info);
}

@ -0,0 +1,24 @@
package com.sztzjy.block_finance.entity.dto;
import com.sztzjy.block_finance.entity.StuBlockOnChain;
import lombok.Data;
import java.util.List;
/**
* @author 17803
* @date 2023-11-21 9:13
*/
@Data
public class StuOnChainInfoDTO {
//节点数
private Integer nodeNumber;
//区块链
private List<StuBlockOnChain> stuBlockOnChains;
}

@ -1,8 +1,10 @@
package com.sztzjy.block_finance.service;
import com.sztzjy.block_finance.entity.StuBlockOnChain;
import com.sztzjy.block_finance.entity.StuPracticalTrainingReport;
import com.sztzjy.block_finance.entity.StuSupplyScore;
import com.sztzjy.block_finance.entity.dto.StuBlockProductWithBLOBs;
import com.sztzjy.block_finance.entity.dto.StuOnChainInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
@ -38,4 +40,15 @@ public interface StuPublicService {
void updateState(String userId);
/**
*
* @param userId
* @return
*/
StuOnChainInfoDTO getOnChain(String userId);
List<StuBlockOnChain> getTrace(String numbers, String userId);
}

@ -5,18 +5,18 @@ package com.sztzjy.block_finance.service.impl;/**
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.block_finance.config.exception.handler.InvoceTException;
import com.sztzjy.block_finance.entity.*;
import com.sztzjy.block_finance.entity.dto.StuBlockProductWithBLOBs;
import com.sztzjy.block_finance.mappers.StuPracticalTrainingReportMapper;
import com.sztzjy.block_finance.mappers.StuSupplyScoreMapper;
import com.sztzjy.block_finance.mappers.StuUserMapper;
import com.sztzjy.block_finance.mappers.TchSupplyGradeWeightMapper;
import com.sztzjy.block_finance.entity.dto.StuOnChainInfoDTO;
import com.sztzjy.block_finance.mappers.*;
import com.sztzjy.block_finance.service.StuPublicService;
import com.sztzjy.block_finance.util.CalculationScoreUtil;
import com.sztzjy.block_finance.util.file.IFileUtil;
import com.sztzjy.block_finance.util.file.LocalFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -57,6 +57,10 @@ public class StuPublicServiceImpl implements StuPublicService {
@Resource
private IFileUtil iFileUtil;
@Autowired
private StuBlockOnChainMapper stuBlockOnChainMapper;
/**
*
*
@ -356,17 +360,14 @@ public class StuPublicServiceImpl implements StuPublicService {
}
@Override
public List<StuSupplyScore> getScore(String userId) {
return null;
}
//提交完成状态
@Override
public void updateState(String userId) {
StuSupplyScoreExample stuInvoiceScoreExample = new StuSupplyScoreExample();
stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(3);
stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(1);
List<StuSupplyScore> stuInvoiceScores = stuSupplyScoreMapper.selectByExample(stuInvoiceScoreExample);
if (!stuInvoiceScores.isEmpty()){
@ -378,6 +379,52 @@ public class StuPublicServiceImpl implements StuPublicService {
}
/**
*
* @param userId
* @return
*/
@Override
public StuOnChainInfoDTO getOnChain(String userId) {
StuBlockOnChainExample onChainExample = new StuBlockOnChainExample();
onChainExample.createCriteria().andUserIdEqualTo(userId);
onChainExample.setOrderByClause("block_index asc");
List<StuBlockOnChain> blockOnChainList = stuBlockOnChainMapper.selectByExample(onChainExample);
StuOnChainInfoDTO stuOnChainInfoDTO = new StuOnChainInfoDTO();
stuOnChainInfoDTO.setNodeNumber(blockOnChainList.size());
stuOnChainInfoDTO.setStuBlockOnChains(blockOnChainList);
return stuOnChainInfoDTO;
}
@Override
public List<StuBlockOnChain> getTrace(String numbers, String userId) {
//返回链表数据
List<StuBlockOnChain> stuBlockOnChainArrayList = new ArrayList<>();
//根据报税单号查询
StuBlockOnChainExample onChainExample = new StuBlockOnChainExample();
onChainExample.createCriteria().andUserIdEqualTo(userId).andPlanNumberEqualTo(numbers);
onChainExample.setOrderByClause("sequence asc");
List<StuBlockOnChain> blockOnChainList = stuBlockOnChainMapper.selectByExample(onChainExample);
if (blockOnChainList.size() == 0)
{
throw new InvoceTException(HttpStatus.ACCEPTED,"单号不存在!");
}
//从上往下开始溯源根据sequence字段
return blockOnChainList;
}
/**
*
@ -385,322 +432,240 @@ public class StuPublicServiceImpl implements StuPublicService {
* @param userId
* @return
*/
// @Override
// public List<StuSupplyScore> getScore(String userId) {
// //查询教师设置权重表 如果权重修改则重新计算分数
// //查询学校ID
// StuUserExample stuUserExample =new StuUserExample();
// stuUserExample.createCriteria().andUserIdEqualTo(userId);
// List<StuUser> userList = stuUserMapper.selectByExample(stuUserExample);
//
// String schoolId = userList.get(0).getSchoolId();
//
// //根据学校ID查询权重数据
// TchSupplyGradeWeightExample tchInvoiceWeightExample = new TchSupplyGradeWeightExample();
// tchInvoiceWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
//
// List<TchSupplyGradeWeight> tchInvoiceWeights = tchSupplyGradeWeightMapper.selectByExample(tchInvoiceWeightExample);
// //设置默认权重数据
// if (tchInvoiceWeights.size() == 0 )
// {
// TchSupplyGradeWeight tchInvoiceWeight = new TchSupplyGradeWeight();
//
// tchInvoiceWeight.setExperimentTrainWeight(BigDecimal.valueOf(0.7));
//
// tchInvoiceWeight.setTrainingReportWeight(BigDecimal.valueOf(0.3));
//
// tchInvoiceWeight.setId(UUID.randomUUID().toString().replaceAll("-",""));
// tchInvoiceWeight.setSchoolId(schoolId);
// tchSupplyGradeWeightMapper.insertSelective(tchInvoiceWeight);
//
// }
//
//
// //发起采购订单次数
// initiateOrderPurchaseNumber(userId);
//
// //申请开具发票次数
// applyInvoiceIssuanceNumber(userId);
//
// //发起采购计划次数
// initiatePlanPurchaseNumber(userId);
//
// //企业报税次数
// sumDeclarationNumber(userId);
//
// //发货次数
// initiateSendNumber(userId);
//
// //开具发票张数
// intMakeInvoiceNumber(userId);
//
//
// //企业报税次数
// initEnterpriseTaxFrequency(userId);
//
// //企业报税审批次数
// initEnterpriseTaxExamineFrequency(userId);
//
// //错误次数重新统计分数
// initErrorNumber(userId);
//
// //实训报告更新权重
// initReportNumber(userId);
//
// //遍历循环
//
// double sum = 0;
//// Integer[] array = {1,2,3,4,5,6,7,8,9};
//
// //从教师端查询计分标准和权重数据不存在则默认 TODO
//
// //根据用户ID查询项目 根据序号升序 就算没有成绩没有做过也要返回得分标准,权重,实际操作次数,项目名,序号。
//
// StuInvoiceScoreExample stuInvoiceScoreExample = new StuInvoiceScoreExample();
//
// stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId);
// stuInvoiceScoreExample.setOrderByClause("order_numbers asc");
//
// List<StuInvoiceScore> stuInvoiceScoreList = stuInvoiceScoreMapper.selectByExample(stuInvoiceScoreExample);
// //需要重新查询教师端设置的权重和得分标准,如果更新了需要重新计算分数 //TODO
//
// if (stuInvoiceScoreList.size() < 10) {
//
// //查询出哪些数据,还有那些数据没有做过,也需要返回
// //已经做的
// List<Integer> collect = stuInvoiceScoreList.stream().map(item -> item.getOrderNumbers()).collect(Collectors.toList());
// // 创建一个标记数组初始值为false
// boolean[] presence = new boolean[11];
//
// // 标记已经存在的数字
// for (int num : collect) {
// presence[num] = true;
// }
// for (int i = 1; i <= 10; i++) {
//
// //给不存在的数字添加默认值
// if (!presence[i]) {
//
// if (i == 1) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(1);
// stuInvoiceScore.setProjects("发起采购订单次数");
// //TODO 只需要修改这些
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 2) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(2);
// stuInvoiceScore.setProjects("申请开具发票次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 3) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(3);
// stuInvoiceScore.setProjects("发起采购计划次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 4) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(4);
// stuInvoiceScore.setProjects("企业报税次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 5) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(5);
// stuInvoiceScore.setProjects("发货次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 6) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(6);
// stuInvoiceScore.setProjects("开具发票张数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 7) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(7);
// stuInvoiceScore.setProjects("企业报税次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 8) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(8);
// stuInvoiceScore.setProjects("企业报税审批次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
// stuInvoiceScore.setProjectsWeight(0.05);
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 9) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数 实验报告未提交为0,1为已提交
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(9);
// stuInvoiceScore.setProjects("输错/选错次数");
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(2));
//
// stuInvoiceScore.setProjectsWeight(tchInvoiceWeights.get(0).getExperimentalTrainingWeight().doubleValue());
//
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// if (i == 10) {
// StuInvoiceScore stuInvoiceScore = new StuInvoiceScore();
// //次数 实验报告未提交为0,1为已提交
// stuInvoiceScore.setProjectsNumber(0);
// stuInvoiceScore.setOrderNumbers(10);
// stuInvoiceScore.setProjects("实训报告");
//
//
// stuInvoiceScore.setProjectsWeight(tchInvoiceWeights.get(0).getReportTraining().doubleValue());
//
//
// stuInvoiceScoreList.add(stuInvoiceScore);
// }
// }
//
//
// }
// } else if (stuInvoiceScoreList.size() == 10) {
//
// //计算总分
// //上面已填充,需要重新查询计算总分
// StuInvoiceScoreExample scoreExample = new StuInvoiceScoreExample();
//
// scoreExample.createCriteria().andUserIdEqualTo(userId);
// stuInvoiceScoreExample.setOrderByClause("order_numbers asc");
//
// List<StuInvoiceScore> stuInvoiceScore = stuInvoiceScoreMapper.selectByExample(scoreExample);
//
// //可能实验报告分数存在但是其他不存在
// //获取权重计算总分
// //遍历获取当前有数据的总分
// for (int j = 0; j < stuInvoiceScore.size(); j++) {
// //判断是否为实验报告
// if ("实训报告".equals(stuInvoiceScore.get(j).getProjects())) {
// //判断成绩是否评分如果有分数返回,没有数据不算分数
// if (stuInvoiceScore.get(j).getProjectsScore() != null) {
// int projectsReportScore = stuInvoiceScore.get(j).getProjectsScore();
// double projectsReportWeight = stuInvoiceScore.get(j).getProjectsWeight();
// double reportScore = projectsReportScore * projectsReportWeight;
// sum += reportScore;
// }
// } else {
// //项目得分
// Integer projectsScore = stuInvoiceScore.get(j).getProjectsScore();
// if (projectsScore ==null)
// {
// projectsScore = 0;
// }
// //权重数据
// double projectsWeight = stuInvoiceScore.get(j).getProjectsWeight();
// double oneScore = projectsScore * projectsWeight;
//
// sum += oneScore;
// }
//
// }
// System.out.println(sum);
//
// //将分数写入总成绩用户表
// insertSumScore(userId,sum);
//
// // 根据score字段进行排序
// Collections.sort(stuInvoiceScoreList, Comparator.comparingInt(StuInvoiceScore::getOrderNumbers));
// return stuInvoiceScoreList;
// }
//
// //计算总分
// //上面已填充,需要重新查询计算总分
// StuInvoiceScoreExample scoreExample = new StuInvoiceScoreExample();
//
// scoreExample.createCriteria().andUserIdEqualTo(userId);
// stuInvoiceScoreExample.setOrderByClause("order_numbers asc");
//
// List<StuInvoiceScore> stuInvoiceScore = stuInvoiceScoreMapper.selectByExample(scoreExample);
//
// //可能实验报告分数存在但是其他不存在
//
//
// //获取权重计算总分
// //遍历获取当前有数据的总分
// for (int j = 0; j < stuInvoiceScore.size(); j++) {
// //判断是否为实验报告
// if ("实训报告".equals(stuInvoiceScore.get(j).getProjects())) {
// //判断成绩是否评分如果有分数返回,没有数据不算分数
// if (stuInvoiceScore.get(j).getProjectsScore() != null) {
// int projectsReportScore = stuInvoiceScore.get(j).getProjectsScore();
// double projectsReportWeight = stuInvoiceScore.get(j).getProjectsWeight();
// double reportScore = projectsReportScore * projectsReportWeight;
// sum += reportScore;
// }
// } else {
// //项目得分
// Integer projectsScore = stuInvoiceScore.get(j).getProjectsScore();
// if (projectsScore ==null)
// {
// projectsScore = 0;
// }
// //
// //权重数据
// double projectsWeight = stuInvoiceScore.get(j).getProjectsWeight();
// double oneScore = projectsScore * projectsWeight;
//
// sum += oneScore;
// }
//
// }
// System.out.println(sum);
// //分数写入总成绩表
// insertSumScore(userId,sum);
//
// // 根据score字段进行排序
// Collections.sort(stuInvoiceScoreList,Comparator.comparingInt(StuInvoiceScore::getOrderNumbers));
//
// return stuInvoiceScoreList;
// }
@Override
public List<StuSupplyScore> getScore(String userId) {
//查询教师设置权重表 如果权重修改则重新计算分数
//查询学校ID
StuUserExample stuUserExample =new StuUserExample();
stuUserExample.createCriteria().andUserIdEqualTo(userId);
List<StuUser> userList = stuUserMapper.selectByExample(stuUserExample);
String schoolId = userList.get(0).getSchoolId();
//根据学校ID查询权重数据
TchSupplyGradeWeightExample tchInvoiceWeightExample = new TchSupplyGradeWeightExample();
tchInvoiceWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TchSupplyGradeWeight> tchInvoiceWeights = tchSupplyGradeWeightMapper.selectByExample(tchInvoiceWeightExample);
//设置默认权重数据
if (tchInvoiceWeights.size() == 0 )
{
TchSupplyGradeWeight tchInvoiceWeight = new TchSupplyGradeWeight();
tchInvoiceWeight.setExperimentTrainWeight(BigDecimal.valueOf(0.7));
tchInvoiceWeight.setTrainingReportWeight(BigDecimal.valueOf(0.3));
tchInvoiceWeight.setId(UUID.randomUUID().toString().replaceAll("-",""));
tchInvoiceWeight.setSchoolId(schoolId);
tchSupplyGradeWeightMapper.insertSelective(tchInvoiceWeight);
}
//实训算分
initiateOrderPurchaseNumber(userId);
//实训报告更新权重
initReportNumber(userId);
//遍历循环
double sum = 0;
// Integer[] array = {1,2,3,4,5,6,7,8,9};
//从教师端查询计分标准和权重数据不存在则默认 TODO
//根据用户ID查询项目 根据序号升序 就算没有成绩没有做过也要返回得分标准,权重,实际操作次数,项目名,序号。
StuSupplyScoreExample stuInvoiceScoreExample = new StuSupplyScoreExample();
stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId);
stuInvoiceScoreExample.setOrderByClause("numbers asc");
List<StuSupplyScore> stuInvoiceScoreList = stuSupplyScoreMapper.selectByExample(stuInvoiceScoreExample);
//需要重新查询教师端设置的权重和得分标准,如果更新了需要重新计算分数 //TODO
if (stuInvoiceScoreList.size() < 2) {
//查询出哪些数据,还有那些数据没有做过,也需要返回
//已经做的
List<Integer> collect = stuInvoiceScoreList.stream().map(item -> item.getNumbers()).collect(Collectors.toList());
// 创建一个标记数组初始值为false
boolean[] presence = new boolean[3];
// 标记已经存在的数字
for (int num : collect) {
presence[num] = true;
}
for (int i = 1; i <= 2; i++) {
//给不存在的数字添加默认值
if (!presence[i]) {
if (i == 1) {
StuSupplyScore stuInvoiceScore = new StuSupplyScore();
//次数
stuInvoiceScore.setProjectsNumber(null);
stuInvoiceScore.setNumbers(1);
stuInvoiceScore.setProjects("输错/选错次数");
//TODO 只需要修改这些
stuInvoiceScore.setScoringCriteria(String.valueOf(1));
stuInvoiceScore.setProjectsWeight(0.7);
stuInvoiceScoreList.add(stuInvoiceScore);
}
if (i == 2) {
StuSupplyScore stuInvoiceScore = new StuSupplyScore();
//次数
stuInvoiceScore.setProjectsNumber(0);
stuInvoiceScore.setNumbers(2);
stuInvoiceScore.setProjects("实训报告");
stuInvoiceScore.setScoringCriteria(String.valueOf(100));
stuInvoiceScore.setProjectsWeight(0.3);
stuInvoiceScoreList.add(stuInvoiceScore);
}
}
}
} else if (stuInvoiceScoreList.size() == 2) {
//计算总分
//上面已填充,需要重新查询计算总分
StuSupplyScoreExample scoreExample = new StuSupplyScoreExample();
scoreExample.createCriteria().andUserIdEqualTo(userId);
stuInvoiceScoreExample.setOrderByClause("numbers asc");
List<StuSupplyScore> stuInvoiceScore = stuSupplyScoreMapper.selectByExample(scoreExample);
//可能实验报告分数存在但是其他不存在
//获取权重计算总分
//遍历获取当前有数据的总分
for (int j = 0; j < stuInvoiceScore.size(); j++) {
//判断是否为实验报告
if ("实训报告".equals(stuInvoiceScore.get(j).getProjects())) {
//判断成绩是否评分如果有分数返回,没有数据不算分数
if (stuInvoiceScore.get(j).getProjectsScore() != null) {
int projectsReportScore = stuInvoiceScore.get(j).getProjectsScore();
double projectsReportWeight = stuInvoiceScore.get(j).getProjectsWeight();
double reportScore = projectsReportScore * projectsReportWeight;
sum += reportScore;
}
} else {
//项目得分
Integer projectsScore = stuInvoiceScore.get(j).getProjectsScore();
if (projectsScore ==null)
{
projectsScore = 0;
}
//权重数据
double projectsWeight = stuInvoiceScore.get(j).getProjectsWeight();
double oneScore = projectsScore * projectsWeight;
sum += oneScore;
}
}
//将分数写入总成绩用户表
insertSumScore(userId,sum);
// 根据score字段进行排序
Collections.sort(stuInvoiceScoreList, Comparator.comparingInt(StuSupplyScore::getNumbers));
return stuInvoiceScoreList;
}
//计算总分
//上面已填充,需要重新查询计算总分
StuSupplyScoreExample scoreExample = new StuSupplyScoreExample();
scoreExample.createCriteria().andUserIdEqualTo(userId);
stuInvoiceScoreExample.setOrderByClause("numbers asc");
List<StuSupplyScore> stuInvoiceScore = stuSupplyScoreMapper.selectByExample(scoreExample);
//可能实验报告分数存在但是其他不存在
//获取权重计算总分
//遍历获取当前有数据的总分
for (int j = 0; j < stuInvoiceScore.size(); j++) {
//判断是否为实验报告
if ("实训报告".equals(stuInvoiceScore.get(j).getProjects())) {
//判断成绩是否评分如果有分数返回,没有数据不算分数
if (stuInvoiceScore.get(j).getProjectsScore() != null) {
int projectsReportScore = stuInvoiceScore.get(j).getProjectsScore();
double projectsReportWeight = stuInvoiceScore.get(j).getProjectsWeight();
double reportScore = projectsReportScore * projectsReportWeight;
sum += reportScore;
}
} else {
//项目得分
Integer projectsScore = stuInvoiceScore.get(j).getProjectsScore();
if (projectsScore ==null)
{
projectsScore = 0;
}
//
//权重数据
double projectsWeight = stuInvoiceScore.get(j).getProjectsWeight();
double oneScore = projectsScore * projectsWeight;
sum += oneScore;
}
}
System.out.println(sum);
//分数写入总成绩表
insertSumScore(userId,sum);
// 根据score字段进行排序
Collections.sort(stuInvoiceScoreList,Comparator.comparingInt(StuSupplyScore::getNumbers));
return stuInvoiceScoreList;
}
private void insertSumScore(String userId, double sum) {
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUserIdEqualTo(userId);
List<StuUser> userList = stuUserMapper.selectByExample(stuUserExample);
userList.get(0).setSupplyChainFinanceScore(BigDecimal.valueOf(sum));
stuUserMapper.updateByPrimaryKeySelective(userList.get(0));
return;
}
/**
*
* @param userId
* @return
*/
private void initReportNumber(String userId) {
TchSupplyGradeWeight tchWeight = getTchWeight(userId);
StuSupplyScoreExample stuInvoiceScoreExample = new StuSupplyScoreExample();
stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(2);
List<StuSupplyScore> stuInvoiceScores = stuSupplyScoreMapper.selectByExample(stuInvoiceScoreExample);
if (stuInvoiceScores.size()>0)
{
//重新设置权重 TODO
stuInvoiceScores.get(0).setProjectsWeight(tchWeight.getTrainingReportWeight().doubleValue());
stuSupplyScoreMapper.updateByPrimaryKeySelective(stuInvoiceScores.get(0));
return;
}
}
@ -722,115 +687,104 @@ public class StuPublicServiceImpl implements StuPublicService {
* @return
*/
// public void initiateOrderPurchaseNumber(String userId) {
//
// StuSupplyScore stuInvoiceScore = new StuSupplyScore();
//
// //TODO 查询教师端设置计分标准(没有则默认一个)
//
// stuInvoiceScore.setScoringCriteria(String.valueOf(1));
//
// //TODO 查询教师端设置权重数据(没有则默认一个)
//
// TchSupplyGradeWeight tchWeight = getTchWeight(userId);
// if (tchWeight.getExperimentTrainWeight()!=null)
// {
// stuInvoiceScore.setProjectsWeight(tchWeight.getExperimentTrainWeight().doubleValue());
// }else {
//
// stuInvoiceScore.setProjectsWeight(0.7);
// }
//
//
//
// //查询成绩表是否已经存在
// StuSupplyScoreExample stuInvoiceScoreExample = new StuSupplyScoreExample();
// stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(1);
// List<StuSupplyScore> stuInvoiceScores = stuSupplyScoreMapper.selectByExample(stuInvoiceScoreExample);
//// //发起次数
//// int count = stuPersonBuyPlanList.size();
// //如果存在就更新发起次数
// if (stuInvoiceScores.size() > 0) {
//
//// //次数
//// stuInvoiceScores.get(0).setProjectsNumber(count);
//
// stuInvoiceScores.get(0).setUpdateTime(new Date());
//
// //TODO 可能更新权重或者得分标准
// stuInvoiceScores.get(0).setScoringCriteria(String.valueOf(1));
//
//
// TchSupplyGradeWeight tchWeight22 = getTchWeight(userId);
// if (tchWeight22.getExperimentTrainWeight()!=null)
// {
// stuInvoiceScores.get(0).setProjectsWeight(tchWeight22.getExperimentTrainWeight().doubleValue());
// }else {
//
// stuInvoiceScores.get(0).setProjectsWeight(0.7);
// }
//
// StuSupplyScoreExample example = new StuSupplyScoreExample();
// stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(3);
// List<StuSupplyScore> stuInvoiceScoresList = stuSupplyScoreMapper.selectByExample(example);
//
// if (!stuInvoiceScoresList.isEmpty()){
//
//
//
// }else {
//
//
// stuInvoiceScores.get(0).setProjectsScore(null);
//
// }
//
// double projectsScore = CalculationScoreUtil.initiateOrderPurchaseNumberScore(count, 20);
//
//
//
// if (projectsScore == 0 && count == 0)
// {
// stuInvoiceScores.get(0).setProjectsScore(null);
// }else {
// stuInvoiceScores.get(0).setProjectsScore((int) projectsScore);
// }
//
//
// stuInvoiceScoreMapper.updateByPrimaryKeySelective(stuInvoiceScores.get(0));
// return;
// }
// //不存在插入数据
// else {
//
//
// int random = UUID.randomUUID().hashCode();
// int id = random > 0 ? random : -random;
// stuInvoiceScore.setId(id);
// //设置序号
// stuInvoiceScore.setOrderNumbers(1);
// //项目
// stuInvoiceScore.setProjects("发起采购订单次数");
public void initiateOrderPurchaseNumber(String userId) {
StuSupplyScore stuInvoiceScore = new StuSupplyScore();
//TODO 查询教师端设置计分标准(没有则默认一个)
stuInvoiceScore.setScoringCriteria(String.valueOf(1));
//TODO 查询教师端设置权重数据(没有则默认一个)
TchSupplyGradeWeight tchWeight = getTchWeight(userId);
if (tchWeight.getExperimentTrainWeight()!=null)
{
stuInvoiceScore.setProjectsWeight(tchWeight.getExperimentTrainWeight().doubleValue());
}else {
stuInvoiceScore.setProjectsWeight(0.7);
}
//查询成绩表是否已经存在
StuSupplyScoreExample stuInvoiceScoreExample = new StuSupplyScoreExample();
stuInvoiceScoreExample.createCriteria().andUserIdEqualTo(userId).andNumbersEqualTo(1);
List<StuSupplyScore> stuInvoiceScores = stuSupplyScoreMapper.selectByExample(stuInvoiceScoreExample);
// //发起次数
// int count = stuPersonBuyPlanList.size();
//如果存在就更新发起次数
if (stuInvoiceScores.size() > 0) {
// //次数
// stuInvoiceScore.setProjectsNumber(count);
// stuInvoiceScore.setScoringCriteria(String.valueOf(20));
//
//
// double projectsScore = CalculationScoreUtil.initiateOrderPurchaseNumberScore(count, 20);
// if (projectsScore == 0 && count == 0)
// {
// stuInvoiceScore.setProjectsScore(null);
// }else {
// stuInvoiceScores.get(0).setProjectsNumber(count);
stuInvoiceScores.get(0).setUpdateTime(new Date());
//TODO 可能更新权重或者得分标准
stuInvoiceScores.get(0).setScoringCriteria(String.valueOf(1));
TchSupplyGradeWeight tchWeight22 = getTchWeight(userId);
if (tchWeight22.getExperimentTrainWeight()!=null)
{
stuInvoiceScores.get(0).setProjectsWeight(tchWeight22.getExperimentTrainWeight().doubleValue());
}else {
stuInvoiceScores.get(0).setProjectsWeight(0.7);
}
if (stuInvoiceScores.get(0).getReplenishScore().equals("1")){
//错误次数
Integer projectsNumber = stuInvoiceScores.get(0).getProjectsNumber();
double projectsScore = CalculationScoreUtil.initiateOrderPurchaseNumberScore(projectsNumber);
stuInvoiceScores.get(0).setProjectsScore((int) projectsScore);
}
else {
stuInvoiceScores.get(0).setProjectsScore(null);
}
stuSupplyScoreMapper.updateByPrimaryKeySelective(stuInvoiceScores.get(0));
return;
}
//不存在插入数据
else {
int random = UUID.randomUUID().hashCode();
int id = random > 0 ? random : -random;
stuInvoiceScore.setId(id);
//设置序号
stuInvoiceScore.setNumbers(1);
//项目
stuInvoiceScore.setProjects("输错/选错次数");
//错误次数
stuInvoiceScore.setProjectsNumber(null);
// double projectsScore = CalculationScoreUtil.initiateOrderPurchaseNumberScore(projectsNumber);
// stuInvoiceScore.setProjectsScore((int) projectsScore);
// }
// stuInvoiceScore.setUserId(userId);
// stuInvoiceScore.setCreateTime(new Date());
// stuInvoiceScoreMapper.insert(stuInvoiceScore);
// return;
// }
//
//
// }
stuInvoiceScore.setProjectsScore(null);
stuInvoiceScore.setScoringCriteria(String.valueOf(1));
stuSupplyScoreMapper.insert(stuInvoiceScore);
return;
}
}

@ -12,20 +12,21 @@ public class CalculationScoreUtil {
/**
*
* @param count
* @param score
* @return
*/
public static double initiateOrderPurchaseNumberScore(int count,int score){
public static double initiateOrderPurchaseNumberScore(int count){
//计算得分
if (count < 2) {
if (count >=100) {
return 0;
} else if (count == 2) {
return 60;
} else if (count >= 2 + 40 / score) {
} else if (count <= 0)
{
return 100;
} else if (count < 2 + 40 / 20) {
return (60 + score * (count - 2));
}else if (count>0 && count <100){
int sum = 100 - count;
return sum;
}
return 0;
}

Loading…
Cancel
Save