|
@ -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");
|