Bläddra i källkod

修复超过24小时未回复咨询的清理BUG:第二次任务重名造成任务执行失败

Sand 8 år sedan
förälder
incheckning
7ea23666be

+ 6 - 7
src/main/java/com/yihu/wlyy/job/consult/ConsultCleaner.java

@ -41,7 +41,7 @@ public class ConsultCleaner {
            // 先关闭超过24小时未回应的咨询
            consultTeamDao.updateUnresponsedConsultOver24Hours();
            // 计算下一次执行此任务的时间,若无下次计算时间为半个小时后
            // 计算下一次执行此任务的时间,若无下次计算时间为50分钟后
            Date nextTriggerTime;
            Page<ConsultTeam> consultTeams = consultTeamDao.getUnresponsedConsultIn24Hours(new PageRequest(0, 1));
@ -54,17 +54,16 @@ public class ConsultCleaner {
                nextTriggerTime = calendar.getTime();
            } else {
                Calendar calendar = GregorianCalendar.getInstance();
                calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 30);
                calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 50);
                nextTriggerTime = calendar.getTime();
            }
            if (quartzHelper.isExistJob(ConsultTerminatorJobKey)) {
                quartzHelper.removeJob(ConsultTerminatorJobKey);
            }
            System.out.println("计算下次任务执行时间,下次执行在" + nextTriggerTime.toString());
            quartzHelper.startAt(nextTriggerTime, ConsultCleanerJob.class, ConsultTerminatorJobKey, null);
            quartzHelper.startAt(nextTriggerTime,
                    ConsultCleanerJob.class,
                    ConsultTerminatorJobKey + new Date().toString(),
                    null);
        } catch (Exception e) {
            e.printStackTrace();
        }

+ 5 - 5
src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -226,12 +226,12 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.status = 0 and b.reply = 1 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorIngNoTitleList(String uid, Pageable pageRequest);
    // 最近24小时内未回复的项目
    @Query("FROM ConsultTeam a where CURRENT_TIME - a.czrq < 86400 and a.status = 0 order by a.czrq desc")
    Page<ConsultTeam> getUnresponsedConsultIn24Hours(Pageable pageable);
    // 更新超过24小时未回复的项目,多加一分钟,防止过于频繁更新
    @Modifying
    @Query("UPDATE ConsultTeam a set a.status = -2 where CURRENT_TIME - a.czrq > 87840")
    @Query("UPDATE ConsultTeam a set a.status = -2 where TIMESTAMPDIFF(SECOND, a.czrq, CURRENT_TIME) > 87840 and status = 0")
    void updateUnresponsedConsultOver24Hours();
    // 最近24小时内未回复的项目
    @Query("FROM ConsultTeam a where TIMESTAMPDIFF(SECOND, a.czrq, CURRENT_TIME) < 86400 and a.status = 0 order by a.czrq desc")
    Page<ConsultTeam> getUnresponsedConsultIn24Hours(Pageable pageable);
}

+ 1 - 1
src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -88,7 +88,7 @@ public class AdminTeamService extends BaseService {
        Map<String, Object> team = new HashMap<>();
        team.put("teamId", result[0]);
        team.put("teamName", result[1]);
        team.put("isLeader", currentDoctor == null ? false : result[2].equals(currentDoctor));
        team.put("isLeader", currentDoctor != null && result[2].equals(currentDoctor));
        team.put("doctorCode", result[3]);
        team.put("doctorName", result[4]);
        team.put("healthDoctorCode", result[5]);