zoukankan      html  css  js  c++  java
  • 团队作业9——第二次项目冲刺1(Beta阶段)

    召开冲刺会议

    会议内容:商讨第二次冲刺计划,更多功能添加。

    分配任务:

        宋非:dao层设计

        罗建彪:接口设计以及实现

        罗远云:model设计及service接口及实现

    遇到的困难:

      评委评分集合获取总是失败,getScoreById方法总是出错。

    任务分解图

     

    燃尽图

     

    代码记录:

    https://git.coding.net/Ssl_dhlg18/SIMsystem.git

     部分代码:

     

    package com.ms.service.impl;
    
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import org.apache.log4j.Logger;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Qualifier;
    import org.springframework.stereotype.Service;
    
    import com.alibaba.fastjson.JSONObject;
    import com.ms.dao.ActivitylistInterface;
    import com.ms.dao.AudienceInterface;
    import com.ms.dao.ItemFormInterface;
    import com.ms.dao.JudgeScoreInterface;
    import com.ms.dao.RuleInterface;
    import com.ms.dao.ScoreInterface;
    import com.ms.dao.UserFormInterface;
    import com.ms.model.Activityform;
    import com.ms.model.Audiencescoring;
    import com.ms.model.GradingRule;
    import com.ms.model.Judgescoring;
    import com.ms.model.Userform;
    import com.ms.service.scoreServiceI;
    @Service("scoreService")
    public class ScoreServiceImpl implements scoreServiceI {
        @Autowired
        @Qualifier("activityDao")
        private ActivitylistInterface activityDao;
        @Autowired
        @Qualifier("ruleDao")
        private RuleInterface ruleDao;
        @Autowired
        @Qualifier("itemDao")
        private ItemFormInterface itemDao;
        @Autowired
        @Qualifier("userDao")
        private UserFormInterface userDao;
        @Autowired
        @Qualifier("audienceDao")
        private AudienceInterface audienceDao;
        @Autowired
        @Qualifier("judgeScoreDao")
        private JudgeScoreInterface judgeScoreDao;
        @Autowired
        @Qualifier("scoreDao")
        private ScoreInterface scoreDao;
        private Activityform activityForm = new Activityform();
        private Map<String, Object> map = new HashMap<String, Object>();
        private static final Logger logger = Logger.getLogger(ScoreServiceImpl.class);
        java.text.DecimalFormat   df   =new   java.text.DecimalFormat("#.00");  
        /**
         * @description 根据项目ID获取评委评分分数
         * @date 2016-11-09
         */
    @Override
        public Map<String, Object> getJudgeScoreById(int item_id) {
            //1.获得已启动活动的评分细则
            activityForm = activityDao.getStartActivity(true);// 查询已经启动的活动
            List<GradingRule> list_rule= ruleDao.selectRulesByActivId(activityForm.getActivityId());
            
            //2.获取已启动活动的评委
            List<Userform> judges = new ArrayList<Userform>();
            judges = userDao.getJudgeById(2, activityForm.getActivityId());
            
            int n = 0;
            int s = 0;
            int j = 0;
            int[] score = new int[judges.size()];
            List<Judgescoring> list2= new ArrayList<Judgescoring>();
            for(Userform c : judges){
                list2 = judgeScoreDao.getScores1(c.getUserId(), item_id);
                if(!list2.isEmpty() ){
                    for(Judgescoring s1 : list2){
                        score[n] += s1.getScore();
                        s++;
                    }
                    if(s == list_rule.size()){
                        j++;
                    }
                    s=0;            
                    n++;
                }                        
            }
            for(int i=0;i<n-1;i++){
                int t = 0;
                if(score[i]>score[i+1]){
                    t=score[i+1];
                    score[i+1]=score[i];
                    score[i]=t;
                    i=-1;
                }
            }
             
            JSONObject json = new JSONObject();
            Audiencescoring audienceScoring = new Audiencescoring();
            if(n == judges.size()){
            //获取观众评分
            audienceScoring = audienceDao.getAudScoring(item_id, activityForm.getActivityId());
            //评委平均分
            float judgeScore = 0;
            for(int t=1;t<score.length-1;t++){
                judgeScore += score[t];
            }
            judgeScore = (float)judgeScore/(float)(score.length-2);
            //观众平均分
            double audScore = 0.0;
            if(audienceScoring.getAllScoring() != 0 || audienceScoring.getAverage() == 0){
                if(audienceScoring.getNumber() != 0){
                    audScore = (float)audienceScoring.getAllScoring()/(float)audienceScoring.getNumber();
                    audienceDao.addAudAverage(audScore, item_id, activityForm.getActivityId());
                }
            }if(audienceScoring.getAverage() != 0){
                audScore = audienceScoring.getAverage();
            }
            //获取评分权重
            double weight = activityDao.getWeight(activityForm.getActivityId());
            //总平均分
            double average = judgeScore*(1-weight)+audScore*weight;
            //double average2 = average*10;        
            //int average3 = (int)average2;
            String average_format = df.format(average);
            String audScore_format = df.format(audScore);
            map.put("average", Double.parseDouble(average_format));//项目评委打分综合计算得分
            map.put("audScore", Double.parseDouble(audScore_format));//项目观众打分综合计算得分
            map.put("num", audienceScoring.getNumber());//观众评分人数
            //添加项目分数
            itemDao.addScoreByItemId(item_id,average);
            }
            map.put("n",j);//评委已评分个数
            map.put("i",judges.size());//总评委数
            map.put("score", Arrays.toString(score));//当前评委评分分数数组
            map.put("msg", true);//状态码
            return map;
        }
    
        /**
         * @description 根据项目ID获取评委评分分数
         * @date 2016-11-09
         */
        @Override
        public boolean addJudgeScore(Judgescoring judgeScore) {
            try {
                scoreDao.addJudgeScore(judgeScore);
                return true;
            } catch (Exception e) {
                logger.info("提交评委评分分数失败", e);
                return false;
            }
        }
        @Override
        public List<Judgescoring> getJudgeScore(int userId, int itemId) {
            try {
                return scoreDao.getScoreById(itemId, userId);
                
            } catch (Exception e) {
                logger.info("获取评委评分分数失败", e);
                return null;
            }
        }
    
    }

     

     

     

  • 相关阅读:
    中美贸易战再次开启,世界两极化进程正在加快形成!..... Copyright: 1688澳洲新闻网 Read more at: https://www.1688.com.au/world/international/2018/06/17/369368/
    缠师的博客中关于舒伯特中的回帖,细思极恐
    南怀瑾,脱了国学大师的外衣,只剩下江湖和名利
    你可能修了一个假的“不净观”
    陈大惠老师:什么叫道德?
    C#-正则,常用几种数据解析-端午快乐
    html5+go+websocket简单实例代码
    Task三个列子的分享
    golang-web框架revel一个表单提交的总结
    百度流行音乐-资源数据整合
  • 原文地址:https://www.cnblogs.com/gordonsong/p/10090885.html
Copyright © 2011-2022 走看看