瀏覽代碼

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

wujunjie 8 年之前
父節點
當前提交
9cd534a91b
共有 1 個文件被更改,包括 11 次插入9 次删除
  1. 11 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/consult/EvaluateScoreJob.java

+ 11 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/consult/EvaluateScoreJob.java

@ -30,7 +30,7 @@ import static com.yihu.wlyy.job.consult.ConsultCleanerJob.ConsultTerminatorJobKe
 * @since 2016/9/26
 */
@Service
public class EvaluateScoreJob implements Job{
public class EvaluateScoreJob implements Job {
    @Autowired
    ConsultTeamDoctorDao consultTeamDoctorDao;
    @Autowired
@ -38,7 +38,7 @@ public class EvaluateScoreJob implements Job{
    @Autowired
    DoctorDao doctorDao;
    @Override
    @Transactional
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            System.out.println("calculate evaluate job start");
@ -48,19 +48,21 @@ public class EvaluateScoreJob implements Job{
            List<Map<String, Object>> doctorList = jdbcTemplate.queryForList(doctorsSql);
            for (Map<String, Object> doctorMap : doctorList) {
                //获取医生的所有评价信息
                String doctor =  doctorMap.get("doctor").toString();
                String doctor = doctorMap.get("doctor").toString();
                //统计总的分数
                List<Map<String, Object>> evaluateList = jdbcTemplate.queryForList(sql, new Object[]{doctor});
                //统计评价次数
                List<Map<String, Object>> evaluateTimes = jdbcTemplate.queryForList(evaluateTimesSql, new Object[]{doctor});
                if(evaluateTimes!=null&&evaluateTimes.size()>0&&evaluateList!=null&&evaluateList.size()>0){
                if (evaluateTimes != null && evaluateTimes.size() > 0 && evaluateList != null && evaluateList.size() > 0) {
                    //计算完毕
                    BigDecimal amount = new BigDecimal(evaluateList.get(0).get("score").toString());
                    BigDecimal count = new BigDecimal(evaluateList.get(0).get("count").toString());
                    BigDecimal score = amount.divide(count,1,BigDecimal.ROUND_HALF_UP);
                    Doctor d  =  doctorDao.findByCode(doctor);
                    d.setEvaluateScore(score.doubleValue());
                    doctorDao.save(d);
                    BigDecimal count = new BigDecimal(evaluateTimes.get(0).get("count").toString());
                    BigDecimal score = amount.divide(count, 1, BigDecimal.ROUND_HALF_UP);
                    Doctor d = doctorDao.findByCode(doctor);
                    if (d != null) {
                        d.setEvaluateScore(score.doubleValue());
                        doctorDao.save(d);
                    }
                }
            }
            System.out.println("calculate evaluate job end");