|
@@ -1,15 +1,15 @@
|
|
|
package cn.iocoder.yudao.module.work.service.totalscore;
|
|
|
|
|
|
+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;
|
|
@@ -28,6 +28,8 @@ public class TotalScoreServiceImpl implements TotalScoreService {
|
|
|
|
|
|
@Resource
|
|
|
private TotalScoreMapper totalScoreMapper;
|
|
|
+ @Resource
|
|
|
+ private ScoreMapper scoreMapper;
|
|
|
|
|
|
@Override
|
|
|
public Integer createTotalScore(TotalScoreSaveReqVO createReqVO) {
|
|
@@ -71,4 +73,52 @@ public class TotalScoreServiceImpl implements TotalScoreService {
|
|
|
return totalScoreMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map<String,String>> JsTotalScore() {
|
|
|
+ List<Map<String,Integer>> workidList=scoreMapper.getScoreWork();
|
|
|
+ //总分 暂存
|
|
|
+ List<Map<String,String>> workzfList=new ArrayList<Map<String, String>>();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
+ //评选人数
|
|
|
+ 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);
|
|
|
+// System.out.println("平均分数"+pingjunfen);
|
|
|
+// System.out.println("平均分数"+decimalFormat.format(pingjunfen));
|
|
|
+ //拼接最终核算的总分
|
|
|
+ Map<String, String> workzf=new HashMap<>();
|
|
|
+ workzf.put("workName",workid.get("work_name")+"");
|
|
|
+ workzf.put("workId",workId+"");
|
|
|
+ workzf.put("overallRating",decimalFormat.format(pingjunfen));
|
|
|
+ workzfList.add(workzf);
|
|
|
+ }else {
|
|
|
+ System.out.println("分数未打完不计算");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return workzfList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|