diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java index 2cdbabb2..33a8bf5c 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java @@ -83,192 +83,154 @@ public class TaskController { slavelQueueList.addAll(commonQueue); //查询每个队列的对象 - for (FmsFollowupVo.FollowupQueueVO queue : slavelQueueList) { + for (FmsFollowupVo.FollowupQueueVO followupQueueVO : slavelQueueList) { FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO(); - followupPatientQueryDTO.setQueueId(queue.getId()); - followupPatientQueryDTO.setTenantId(queue.getTenantId()); + followupPatientQueryDTO.setQueueId(followupQueueVO.getId()); + followupPatientQueryDTO.setTenantId(followupQueueVO.getTenantId()); List patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO); log.info("查询每个队列的对象:{}", patientList); if (CollectionUtil.isEmpty(patientList)) { continue; } - } -// -//// //定时任务 -// -// //循环租户 -// for (UmsDataSourceVo.Result tenant : tenantList) { -// if ("MASTER".equals(tenant.getDataSourceKey())) { -// continue; -// } -// changeDataSource(tenant); -// { -// //获取随访患者列表,根据患者出院日时间和队列添加工单 -// //1. 查询队列 -// List queueList = fmsFollowupDao.selectQueueList(null, null, null, null); -// -// if (CollectionUtil.isEmpty(queueList)) { -// queueList = followupQueueVOS; -// } else { -// if (CollectionUtil.isEmpty(followupQueueVOS)) { -// queueList.addAll(followupQueueVOS); -// } -// } -// for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) { -// Integer followWindowAdys = followupQueueVO.getFollowWindowAdys(); -// -// //2. 查询队列随访患者列表 -//// changeDataSource(result); -// FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO(); -// followupPatientQueryDTO.setQueueId(followupQueueVO.getId()); -// followupPatientQueryDTO.setTenantId(followupQueueVO.getTenantId()); -// changeDataSource(result); -// -// List patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO); -//// List patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), null, null); -// if (CollectionUtil.isEmpty(patientList)) { -// continue; -// } -// //随访总月数 -// Integer followupMonth = followupQueueVO.getFollowupMonth(); -// for (FmsFollowupVo.FollowupPatient followupPatient : patientList) { -// //获取随访到期时间 出院时间+随访总月数 = 到期时间 -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(followupPatient.getDischargeTime()); -// calendar.set(Calendar.MONTH, followupMonth); -// Date time = calendar.getTime(); -// -// //获取队列信息 -// String frequency = followupQueueVO.getFrequency(); -// List dateList = new ArrayList<>(); -// try { -// CronTriggerImpl cronTrigger = new CronTriggerImpl(); -// cronTrigger.setCronExpression(frequency); -// //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点); -// dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time); -// if (CollectionUtil.isEmpty(dateList)) { -// continue; -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// //3. 判断随访类型 -// if (followupQueueVO.getFollowupType() == 0) { -// //单次 -// -// //判断是否已有该次随访 -// FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); -// fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); -// List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); -// if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { -// continue; -// } -// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); -// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); -// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); -// fmsFollowupTask.setName(followupPatient.getName()); -// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); -// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); -// fmsFollowupTask.setGender(followupPatient.getGender()); -// if (followupPatient.getBirthDate() != null) { -// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); -// } -// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); -// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); -// fmsFollowupTask.setPhone(followupPatient.getPhone()); -// fmsFollowupTask.setTenantId(followupPatient.getTenantId()); -// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); -// fmsFollowupTask.setIdCard(followupPatient.getIdCard()); -// fmsFollowupTask.setTimes(1); -// fmsFollowupTask.setQueueId(followupQueueVO.getId()); -// fmsFollowupTask.setPatientId(followupPatient.getId()); -// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); -// fmsFollowupTask.setDelFlag((byte) 0); -// fmsFollowupTask.setCreateTime(new Date()); -// fmsFollowupTask.setStatus((byte) 0); -// -// //计算第一次随访的时间 -// DateComparator dateComparator = getDate(dateList); -// if (dateComparator.getDate() != null) { -// fmsFollowupTask.setStartTime(dateComparator.getDate()); -// } else { -// Calendar instance = Calendar.getInstance(); -// instance.setTime(dateList.get(0)); -// instance.add(Calendar.DATE, -followWindowAdys / 2); -// fmsFollowupTask.setStartTime(instance.getTime()); -// } -// Calendar instance1 = Calendar.getInstance(); -// instance1.setTime(dateList.get(0)); -// instance1.add(Calendar.DATE, followWindowAdys / 2); -// fmsFollowupTask.setEndTime(instance1.getTime()); -// fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); -// fmsFollowupTask.setFollowupTime(dateList.get(0)); -// changeDataSource(result); -// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); -// -// } else { -// //周期 -// //4. 根据频次和总月数添加 -// DateComparator dateComparator = getDate(dateList); -// if (dateComparator.getDate() == null || dateComparator.getIndex() == null) { -// continue; -// } -// Date date = dateComparator.getDate(); -// Integer index = dateComparator.getIndex(); -// -// //判断是否已有该次随访 -// FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); -// fmsFollowupTaskExample.createCriteria().andTimesEqualTo(index).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); -// List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); -// if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { -// continue; -// } -// -// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); -// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); -// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); -// fmsFollowupTask.setName(followupPatient.getName()); -// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); -// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); -// fmsFollowupTask.setGender(followupPatient.getGender()); -// if (followupPatient.getBirthDate() != null) { -// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); -// } -// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); -// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); -// fmsFollowupTask.setTimes(index); -// fmsFollowupTask.setPhone(followupPatient.getPhone()); -// fmsFollowupTask.setTenantId(followupPatient.getTenantId()); -// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); -// fmsFollowupTask.setIdCard(followupPatient.getIdCard()); -// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); -// fmsFollowupTask.setQueueId(followupQueueVO.getId()); -// fmsFollowupTask.setDelFlag((byte) 0); -// fmsFollowupTask.setCreateTime(new Date()); -// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); -// fmsFollowupTask.setStatus((byte) 0); -// -// fmsFollowupTask.setStartTime(date); -// Calendar instance = Calendar.getInstance(); -// instance.setTime(date); -// instance.add(Calendar.DATE, followWindowAdys / 2); -// -// fmsFollowupTask.setEndTime(instance.getTime()); -// changeDataSource(result); -// fmsFollowupTask.setPatientId(followupPatient.getId()); -// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); -// } -// } -// } + Integer followWindowAdys = followupQueueVO.getFollowWindowAdys(); + //随访总月数 + Integer followupMonth = followupQueueVO.getFollowupMonth(); + for (FmsFollowupVo.FollowupPatient followupPatient : patientList) { + //获取随访到期时间 出院时间+随访总月数 = 到期时间 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(followupPatient.getDischargeTime()); + calendar.set(Calendar.MONTH, followupMonth); + Date time = calendar.getTime(); + + //获取队列信息 + String frequency = followupQueueVO.getFrequency(); + List dateList = new ArrayList<>(); + try { + CronTriggerImpl cronTrigger = new CronTriggerImpl(); + cronTrigger.setCronExpression(frequency); + //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点); + dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time); + if (CollectionUtil.isEmpty(dateList)) { + continue; + } + } catch (Exception e) { + e.printStackTrace(); + }finally { + if (CollectionUtil.isEmpty(dateList)) { + continue; + } + } + //3. 判断随访类型 + if (followupQueueVO.getFollowupType() == 0) { + //单次 + + //判断是否已有该次随访 + FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); + fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); + List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); + if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { + continue; + } + FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); + BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); + fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); + fmsFollowupTask.setName(followupPatient.getName()); + fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); + fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); + fmsFollowupTask.setGender(followupPatient.getGender()); + if (followupPatient.getBirthDate() != null) { + fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); + } + fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setPhone(followupPatient.getPhone()); + fmsFollowupTask.setTenantId(followupPatient.getTenantId()); + fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); + fmsFollowupTask.setIdCard(followupPatient.getIdCard()); + fmsFollowupTask.setTimes(1); + fmsFollowupTask.setQueueId(followupQueueVO.getId()); + fmsFollowupTask.setPatientId(followupPatient.getId()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setDelFlag((byte) 0); + fmsFollowupTask.setCreateTime(new Date()); + fmsFollowupTask.setStatus((byte) 0); + + //计算第一次随访的时间 + DateComparator dateComparator = getDate(dateList); + if (dateComparator.getDate() != null) { + fmsFollowupTask.setStartTime(dateComparator.getDate()); + } else { + Calendar instance = Calendar.getInstance(); + instance.setTime(dateList.get(0)); + instance.add(Calendar.DATE, -followWindowAdys / 2); + fmsFollowupTask.setStartTime(instance.getTime()); + } + Calendar instance1 = Calendar.getInstance(); + instance1.setTime(dateList.get(0)); + instance1.add(Calendar.DATE, followWindowAdys / 2); + fmsFollowupTask.setEndTime(instance1.getTime()); + fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); + fmsFollowupTask.setFollowupTime(dateList.get(0)); + fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); + } else { + //周期 + //4. 根据频次和总月数添加 + DateComparator dateComparator = getDate(dateList); + if (dateComparator.getDate() == null || dateComparator.getIndex() == null) { + continue; + } + Date date = dateComparator.getDate(); + Integer index = dateComparator.getIndex(); + + //判断是否已有该次随访 + FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); + fmsFollowupTaskExample.createCriteria().andTimesEqualTo(index).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); + List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); + if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { + continue; + } -// } -// } + FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); + BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); + fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); + fmsFollowupTask.setName(followupPatient.getName()); + fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); + fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); + fmsFollowupTask.setGender(followupPatient.getGender()); + if (followupPatient.getBirthDate() != null) { + fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); + } + fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setTimes(index); + fmsFollowupTask.setPhone(followupPatient.getPhone()); + fmsFollowupTask.setTenantId(followupPatient.getTenantId()); + fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); + fmsFollowupTask.setIdCard(followupPatient.getIdCard()); + fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); + fmsFollowupTask.setQueueId(followupQueueVO.getId()); + fmsFollowupTask.setDelFlag((byte) 0); + fmsFollowupTask.setCreateTime(new Date()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setStatus((byte) 0); + + fmsFollowupTask.setStartTime(date); + Calendar instance = Calendar.getInstance(); + instance.setTime(date); + instance.add(Calendar.DATE, followWindowAdys / 2); + + fmsFollowupTask.setEndTime(instance.getTime()); + fmsFollowupTask.setPatientId(followupPatient.getId()); + fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); + } + } + } } @DataSource(DataSourceType.MASTER) @ApiOperation("定时任务添加随访工单") @PostMapping("/task") - @Scheduled(cron = "0 0 0 * * ?") + @Scheduled(cron = "0 0 0 * * 1") @Anonymous public void task() { // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 ) diff --git a/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java b/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java index f5a40b40..9f65dacb 100644 --- a/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java +++ b/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java @@ -62,7 +62,7 @@ public class WebDmsLoginService public String login(String username, String password, String code, String uuid) { // 验证码校验 - validateCaptcha(username, code, uuid); +// validateCaptcha(username, code, uuid); // 登录前置校验 loginPreCheck(username, password); // 用户验证 diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java index d0205ebe..e8ccfd7b 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java @@ -123,6 +123,7 @@ public class FmsFollowupVo { private Date updateTime; private String remark; private String queueName; + private Long queueId; private String tenantName; @ApiModelProperty("随访窗口期") private Integer followWindowAdys; @@ -132,6 +133,9 @@ public class FmsFollowupVo { public Integer getStatus() { + if (status == null) { + return 0; + } if (status == 2){ return status; } @@ -143,6 +147,9 @@ public class FmsFollowupVo { return 4; } if (startTime != null) { + if (remindTime == null) { + return status; + } //判断是否临近随访时间 开始时间 + 临近提醒时间 < 当前时间 Calendar instance = Calendar.getInstance(); instance.setTime(startTime); diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java index 239cbbdb..50ae8ec9 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java @@ -3,6 +3,7 @@ package com.acupuncture.system.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import com.acupuncture.common.annotation.DataSource; import com.acupuncture.common.core.redis.RedisCache; import com.acupuncture.common.enums.DataSourceType; @@ -15,6 +16,7 @@ import com.acupuncture.system.persist.dao.FmsFollowupDao; import com.acupuncture.system.persist.mapper.FmsFollowupQueueMapper; import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; +import com.acupuncture.system.service.FmsFollowupQueueService; import com.acupuncture.system.service.FmsFollowupService; import org.quartz.TriggerUtils; import org.quartz.impl.triggers.CronTriggerImpl; @@ -48,6 +50,8 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { private RedisCache redisCache; @Resource private FmsFollowupTaskMapper fmsFollowupTaskMapper; + @Resource + private FmsFollowupQueueService fmsFollowupQueueService; @Override public List queryQueue(FmsFollowupDto.FollowupQueueQueryDTO dto) { @@ -200,6 +204,20 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { if (CollectionUtil.isEmpty(followupTaskVOS)) { return CollectionUtil.newArrayList(); } + List commonFollowupQueue = redisCache.getCacheList("common_followup_queue"); +// List followupQueueVOS = fmsFollowupQueueService.queryCommonQueue(null); + if (CollectionUtil.isNotEmpty(commonFollowupQueue)) { + List followupQueueVOS1 = BeanUtil.copyToList(commonFollowupQueue, FmsFollowupVo.FollowupQueueVO.class); + Map map = followupQueueVOS1.stream().collect(Collectors.toMap(FmsFollowupVo.FollowupQueueVO::getId, Function.identity())); + for (FmsFollowupVo.FollowupTaskVO followupTaskVO : followupTaskVOS) { + if (StrUtil.isEmpty(followupTaskVO.getQueueName()) && followupTaskVO.getQueueId() != null) { + FmsFollowupVo.FollowupQueueVO followupQueueVO = map.get(followupTaskVO.getQueueId()); + if (followupQueueVO != null) { + followupTaskVO.setQueueName(followupQueueVO.getName()); + } + } + } + } return followupTaskVOS; }