|
@@ -1,20 +1,24 @@
|
|
|
package cn.iocoder.yudao.module.work.service.totalscore;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.work.controller.admin.score.vo.ScorePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.work.controller.admin.score.vo.ScoreRespVO;
|
|
|
+import cn.iocoder.yudao.module.work.dal.dataobject.score.ScoreDO;
|
|
|
+import cn.iocoder.yudao.module.work.dal.mysql.score.ScoreMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
import cn.iocoder.yudao.module.work.controller.admin.totalscore.vo.*;
|
|
|
import cn.iocoder.yudao.module.work.dal.dataobject.totalscore.TotalScoreDO;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
import cn.iocoder.yudao.module.work.dal.mysql.totalscore.TotalScoreMapper;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
import static cn.iocoder.yudao.module.work.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -28,6 +32,8 @@ public class TotalScoreServiceImpl implements TotalScoreService {
|
|
|
|
|
|
@Resource
|
|
|
private TotalScoreMapper totalScoreMapper;
|
|
|
+ @Resource
|
|
|
+ private ScoreMapper scoreMapper;
|
|
|
|
|
|
@Override
|
|
|
public Integer createTotalScore(TotalScoreSaveReqVO createReqVO) {
|
|
@@ -71,4 +77,75 @@ public class TotalScoreServiceImpl implements TotalScoreService {
|
|
|
return totalScoreMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Integer JsTotalScore() {
|
|
|
+ List<Map<String,Integer>> workidList=scoreMapper.getScoreWork();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
+ //添加总分人数
|
|
|
+ Integer scrs=0;
|
|
|
+ //评选人数
|
|
|
+ Integer pxqrrs=0;
|
|
|
+ //评选人数
|
|
|
+ Integer workId=0;
|
|
|
+ double pingjunfen=0;
|
|
|
+ for (Map<String,Integer> workid : workidList) {
|
|
|
+ workId=workid.get("work_id");
|
|
|
+ pxqrrs=Integer.parseInt(String.valueOf(workid.get("pfrs")));
|
|
|
+ //获取有几个人评选
|
|
|
+ String userids= scoreMapper.getxydfrs(workId);
|
|
|
+ String[] strArray = userids.replace("[", "").replace("]", "").split(",");
|
|
|
+ if(pxqrrs.equals(strArray.length)){
|
|
|
+// System.out.println("按规则计算分数");
|
|
|
+ List<Integer> scoreList= scoreMapper.getdfxq(workId);
|
|
|
+ int sum=0;
|
|
|
+ int max=scoreList.get(0);
|
|
|
+ int min=scoreList.get(0);
|
|
|
+ for (int score : scoreList) {
|
|
|
+ sum += score;
|
|
|
+ if (score > max) {
|
|
|
+ max = score;
|
|
|
+ }
|
|
|
+ if (min > score) {
|
|
|
+ min = score;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pingjunfen= (double) (sum - max - min) / (double) (strArray.length - 2);
|
|
|
+ TotalScoreSaveReqVO totalScoreSaveReqVO=new TotalScoreSaveReqVO();
|
|
|
+ totalScoreSaveReqVO.setWorkName(workid.get("work_name")+"");
|
|
|
+ totalScoreSaveReqVO.setOverallRating(decimalFormat.format(pingjunfen));
|
|
|
+ totalScoreSaveReqVO.setWorkId(workId+"");
|
|
|
+ TotalScoreDO totalScore = BeanUtils.toBean(totalScoreSaveReqVO, TotalScoreDO.class);
|
|
|
+ //统计的分数添加到数据库
|
|
|
+ totalScoreMapper.insert(totalScore);
|
|
|
+ scrs++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return scrs;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getScoreName(Integer workId) {
|
|
|
+ return scoreMapper.getScoreName(workId+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean delTotalScore(Integer workId) {
|
|
|
+ //获取专家评分表id
|
|
|
+ ScorePageReqVO scorePageReqVO=new ScorePageReqVO();
|
|
|
+ scorePageReqVO.setWorkId(workId);
|
|
|
+ PageResult<ScoreDO> pageResult = scoreMapper.selectPage(scorePageReqVO);
|
|
|
+ List<ScoreDO> scoreDOList=pageResult.getList();
|
|
|
+ for (ScoreDO scoredo: scoreDOList) {
|
|
|
+ //进行逻辑删除
|
|
|
+ scoreMapper.deleteById(scoredo.getId());
|
|
|
+ }
|
|
|
+ //获取总分表id
|
|
|
+ TotalScorePageReqVO totalScorePageReqVO=new TotalScorePageReqVO();
|
|
|
+ totalScorePageReqVO.setWorkId(workId+"");
|
|
|
+ PageResult<TotalScoreDO> totalScoreDOPageResult = totalScoreMapper.selectPage(totalScorePageReqVO);
|
|
|
+ System.out.println(totalScoreDOPageResult.getList());
|
|
|
+ totalScoreMapper.deleteById(totalScoreDOPageResult.getList().get(0).getId());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|