任务管理

This commit is contained in:
zhangheng 2025-01-14 17:34:36 +08:00
parent f06a6db9f4
commit e1f6509c22
9 changed files with 341 additions and 6 deletions

View File

@ -11,6 +11,12 @@ import lombok.Getter;
@Getter
public enum PhoneDialMethodEnum {
/**
* AI
*/
ALL("ALL"),
/**
* AI
*/

View File

@ -183,4 +183,18 @@ public class SignPatientManageRouteController extends BaseController {
public R<List<SignPatientRecordSelectVo>> getRecordList(@PathVariable("patientId") Long patientId) {
return R.ok(signPatientManageRouteService.getRecordList(patientId));
}
@ApiOperation("任务管理")
@GetMapping("taskManagement")
public TableDataInfo taskManagement(ManualFollowUpDTO manualFollowUpDTO) {
startPage();
List<ManualFollowUpVO> list = signPatientManageRouteService.taskManagement(manualFollowUpDTO);
return getDataTable(list);
}
@ApiOperation("批量删除未执行任务")
@PostMapping("batchDeleteTask")
public AjaxResult batchDeleteTask(Long[] ids){
return signPatientManageRouteService.batchDeleteTask(ids);
}
}

View File

@ -90,6 +90,6 @@ public class ManualFollowUpDTO extends BaseEntity {
@ApiModelProperty(value = "任务执行类型(批量还是单个执行,'批量任务BATCH_TASK,单个实时拔打任务ACTUAL_TIME_TASK'")
private String taskExcuteType;
@ApiModelProperty(value = "任务节点类型电话外呼PHONE_OUTBOUND问卷量表QUESTIONNAIRE_SCALE宣教文章PROPAGANDA_ARTICLE文字提醒TEXT_REMIND")
private String taskNodeType;
}

View File

@ -99,4 +99,37 @@ public interface SignPatientManageRouteMapper {
* @return
*/
String selectPatientPhone(Long patientId);
/**
* 根据节点ids查询路径ids
*
* @param ids 节点ids
* @return SignPatientManageRoute
*/
List<SignPatientManageRoute> selectRouteByNodeIds(List<Long> ids);
/**
* 根据路径ids查询是否存在子路径
*
* @param ids 路径ids
* @return SignPatientManageRoute
*/
List<SignPatientManageRoute> selectRouteByParentRouteIds(List<Long> ids);
/**
* 删除路径
*
* @param ids 路径ids
* @return int
*/
int updateSignPatientManageRouteByIds(List<Long> ids);
/**
* 查询子路径同级子路径
*
* @param ids 子路径ids
* @return SignPatientManageRoute
*/
List<SignPatientManageRoute> selectParentRouteIds(List<Long> ids);
}

View File

@ -223,4 +223,20 @@ public interface SignPatientManageRouteNodeMapper {
* @return UploadRobotPublishRecordVo
*/
List<UploadRobotPublishRecordVo> selectTaskOptionContented(UploadRobotPublishRecordDto uploadRobotPublishRecordDto);
/**
* 根据节点ids查询同路径的节点ids
*
* @param ids 节点ids
* @return SignPatientManageRouteNode
*/
List<SignPatientManageRouteNode> selectSameManageRouteNodeIdByNodeIds(Long[] ids);
/**
* 根据路径ids查询路径的节点ids
*
* @param ids 路径ids
* @return SignPatientManageRouteNode
*/
List<SignPatientManageRouteNode> selectSameManageRouteNodeIdByRouteIds(List<Long> ids);
}

View File

@ -133,4 +133,20 @@ public interface ISignPatientManageRouteService {
Boolean sendSms(SmsInfoDTO smsInfoDTO) throws ClientException, ServiceException;
void shortMessageSendRecordExtracted(PatientQuestionSubmitResultDTO dto, LocalDateTime time, Boolean b, String createBy);
/**
* 任务管理
* @param manualFollowUpDTO 人工随访查询DTO
* @return ManualFollowUpVO 人工随访代办VO
*/
List<ManualFollowUpVO> taskManagement(ManualFollowUpDTO manualFollowUpDTO);
/**
*
* 批量删除未执行任务
*
* @param ids 任务id
* @return AjaxResult
*/
AjaxResult batchDeleteTask(Long[] ids);
}

View File

@ -32,7 +32,6 @@ import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
import com.xinelu.manage.domain.signroutetriggercondition.SignRouteTriggerCondition;
import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict;
import com.xinelu.manage.dto.aiob.ActualTimeTaskDto;
import com.xinelu.manage.dto.manualfollowup.ManualFollowUpDTO;
import com.xinelu.manage.dto.patientinfo.PatientInfoDto;
@ -647,6 +646,195 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
shortMessageSendRecordMapper.insertShortMessageSendRecord(shortMessageSendRecord);
}
/**
* 任务管理
*
* @param manualFollowUpDTO 人工随访查询DTO
* @return ManualFollowUpVO 人工随访代办VO
*/
@Override
@DataScope(agencyAlias = "pi", deptAlias = "pi")
public List<ManualFollowUpVO> taskManagement(ManualFollowUpDTO manualFollowUpDTO) {
if (manualFollowUpDTO.getNodeExecuteStatus().equals(NodeExecuteStatusEnum.UNEXECUTED.getInfo())) {
manualFollowUpDTO.setPhoneNodeExecuteResultStatus(null);
}
if (StringUtils.isNotBlank(manualFollowUpDTO.getPhoneDialMethod()) && manualFollowUpDTO.getPhoneDialMethod().equals(PhoneDialMethodEnum.ALL.getInfo())) {
manualFollowUpDTO.setPhoneDialMethod(null);
}
//1查询
List<ManualFollowUpVO> manualFollowUpVOS = signPatientManageRouteMapper.selectManualFollowUpList(manualFollowUpDTO);
if (CollectionUtils.isEmpty(manualFollowUpVOS) || manualFollowUpVOS.size() == 0) {
return manualFollowUpVOS;
}
//字典名称匹配
ArrayList<String> strings = new ArrayList<>();
strings.add("task_node_type");
strings.add("route_name");
List<SysDictData> sysDictDataList = sysDictDataMapper.selectDictDataByTypeList(strings);
for (ManualFollowUpVO manualFollowUpVO : manualFollowUpVOS) {
SysDictData taskNodeType = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictValue().equals(manualFollowUpVO.getTaskNodeType())).findFirst().orElse(new SysDictData());
if (StringUtils.isNotBlank(taskNodeType.getDictLabel())) {
manualFollowUpVO.setTaskNodeTypeName(taskNodeType.getDictLabel());
}
SysDictData routeNodeName = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictValue().equals(manualFollowUpVO.getRouteNodeName())).findFirst().orElse(new SysDictData());
if (StringUtils.isNotBlank(routeNodeName.getDictLabel())) {
manualFollowUpVO.setRouteNode(routeNodeName.getDictLabel());
}
}
//21如果是查询已执行的任务直接返回查询结果a
if (manualFollowUpDTO.getNodeExecuteStatus().equals(NodeExecuteStatusEnum.EXECUTED.getInfo())) {
return manualFollowUpVOS;
}
//2.2如果是查询所有"未执行“任务,则直接返回查询结果
if (StringUtils.isNotBlank(manualFollowUpDTO.getTimeSign()) && manualFollowUpDTO.getTimeSign().equals("WHOLE")) {
return manualFollowUpVOS;
}
//2.3如果是查询未执行截止到当前时间的任务
ArrayList<ManualFollowUpVO> manualFollowUps = new ArrayList<>();
for (ManualFollowUpVO manualFollowUpVO : manualFollowUpVOS) {
//3.1判断路径节点组装数据
//任务执行时间
LocalDate localDate = null;
if (Objects.nonNull(manualFollowUpVO.getNodePlanTime()) && StringUtils.isNotBlank(manualFollowUpVO.getNodePlanTime().toString())) {
localDate = manualFollowUpVO.getNodePlanTime().toLocalDate();
} else {
//3.2根据出院时间 第几天 计算
if (Objects.nonNull(manualFollowUpVO.getDischargeTime())) {
localDate = manualFollowUpVO.getDischargeTime().plusDays(manualFollowUpVO.getRouteNodeDay()).toLocalDate();
}
//3.3根据就诊时间 第几天 计算
if (Objects.isNull(manualFollowUpVO.getDischargeTime()) && Objects.nonNull(manualFollowUpVO.getVisitTime())) {
localDate = manualFollowUpVO.getVisitTime().plusDays(manualFollowUpVO.getRouteNodeDay()).toLocalDate();
}
//3.4如果为空不予处理
if (Objects.isNull(localDate)) {
continue;
}
}
//3.5如果截止到当前时间已到期则放入返回集合
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
if (before) {
//转换成中文
manualFollowUpVO.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(manualFollowUpVO.getRouteNodeName()).getName());
manualFollowUpVO.setPlanTime(localDate);
// 3.6 放入集合
manualFollowUps.add(manualFollowUpVO);
}
}
//返回今天之前任务
return manualFollowUps;
}
/**
* 批量删除未执行任务
*
* @param ids 任务id
* @return AjaxResult
*/
@Override
public AjaxResult batchDeleteTask(Long[] ids) {
int deleteNodeCount = signPatientManageRouteNodeMapper.deleteSignPatientManageRouteNodeByIds(ids);
if (deleteNodeCount < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
List<SignPatientManageRouteNode> signPatientManageRouteNodes = signPatientManageRouteNodeMapper.selectSameManageRouteNodeIdByNodeIds(ids);
//无同级节点id
List<Long> noSameLevelNodeIds = new ArrayList<>();
//有同级节点且同级节点状态不为0不删除上级路径
for (Long aLong : ids) {
List<SignPatientManageRouteNode> collect = signPatientManageRouteNodes.stream().filter(Objects::nonNull).filter(item -> item.getId().equals(aLong)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect) || collect.size() == 0) {
noSameLevelNodeIds.add(aLong);
}
}
//无同级节点查询上级路径 signPatientManageRoutes 上级路径ids
List<SignPatientManageRoute> signPatientManageRoutes = signPatientManageRouteMapper.selectRouteByNodeIds(noSameLevelNodeIds);
if (CollectionUtils.isEmpty(signPatientManageRoutes) || signPatientManageRoutes.size() == 0) {
return AjaxResult.success();
}
//上级为主路径ids
List<Long> manageRouteIds = new ArrayList<>();
//上级为子路径ids
List<Long> patientManageRouteIds = new ArrayList<>();
//List<SignPatientManageRoute> patientManageRouteIds = new ArrayList<>();
//上级为主路径查询是否有子路径上级为子路径继续查询同级信息
for (SignPatientManageRoute signPatientManageRoute : signPatientManageRoutes) {
if (Objects.nonNull(signPatientManageRoute.getParentRouteId())) {
patientManageRouteIds.add(signPatientManageRoute.getId());
} else {
manageRouteIds.add(signPatientManageRoute.getId());
}
}
//上级为主路径查询是否有子路径
if (CollectionUtils.isNotEmpty(manageRouteIds)) {
manageRouteIds = manageRouteIds.stream().distinct().collect(Collectors.toList());
List<SignPatientManageRoute> parentRoutes = signPatientManageRouteMapper.selectRouteByParentRouteIds(manageRouteIds);
if (CollectionUtils.isEmpty(parentRoutes) || parentRoutes.size() == 0) {
int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(manageRouteIds);
if (updateRouteCount < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
}
//有子路径不删无子路径删除 delete无子路径id集合
List<Long> delete = new ArrayList<>();
for (Long manageRouteId : manageRouteIds) {
List<SignPatientManageRoute> equalsCollect = parentRoutes.stream().filter(Objects::nonNull).filter(item -> item.getParentRouteId().equals(manageRouteId)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(equalsCollect) || equalsCollect.size() == 0) {
delete.add(manageRouteId);
}
}
if (CollectionUtils.isEmpty(delete) || delete.size() == 0) {
int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(delete);
if (updateRouteCount < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
}
}
//上级为子路径查询除自己以外的同级无同级查询上级是否有其他节点有同级
if (CollectionUtils.isNotEmpty(patientManageRouteIds)) {
int updateRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(patientManageRouteIds);
if (updateRouteCount < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
List<Long> mainRouteIds = new ArrayList<>();
//查询上级为子路径查询除自己以外的同级
List<SignPatientManageRoute> patientSignPatientManageRoutes = signPatientManageRouteMapper.selectParentRouteIds(patientManageRouteIds);
if (CollectionUtils.isNotEmpty(patientSignPatientManageRoutes) || patientSignPatientManageRoutes.size() != 0) {
for (Long patientManageRouteId : patientManageRouteIds) {
List<SignPatientManageRoute> collect = patientSignPatientManageRoutes.stream().filter(Objects::nonNull).filter(item -> item.getParentRouteId().equals(patientManageRouteId)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect) || collect.size() == 0) {
mainRouteIds.add(patientManageRouteId);
}
}
//无同级查询上级是否有其他节点
List<SignPatientManageRouteNode> mainSignPatientManageRouteNodes = signPatientManageRouteNodeMapper.selectSameManageRouteNodeIdByRouteIds(mainRouteIds);
if (CollectionUtils.isEmpty(mainSignPatientManageRouteNodes) || mainSignPatientManageRouteNodes.size() == 0) {
int updateMainRouteCount = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(mainRouteIds);
if (updateMainRouteCount < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
}
//无其他节点删除
List<Long> delete = new ArrayList<>();
for (Long mainRouteId : mainRouteIds) {
List<SignPatientManageRouteNode> collect = mainSignPatientManageRouteNodes.stream().filter(Objects::nonNull).filter(item -> item.getManageRouteId().equals(mainRouteId)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect) || collect.size() == 0) {
delete.add(mainRouteId);
}
}
if (CollectionUtils.isEmpty(delete) || delete.size() == 0) {
int count = signPatientManageRouteMapper.updateSignPatientManageRouteByIds(delete);
if (count < 0) {
return AjaxResult.error("删除失败,请联系管理员!");
}
}
}
}
return AjaxResult.success();
}
/**
* 电话记录
*
@ -1145,7 +1333,8 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
signPatientManageRouteNode.setPhoneMessageRemind(StringUtils.isBlank(routeNode.getPhoneMessageRemind()) ? null : routeNode.getPhoneMessageRemind());
signPatientManageRouteNode.setPhoneMessageTemplateId(Objects.isNull(routeNode.getPhoneMessageTemplateId()) ? null : routeNode.getPhoneMessageTemplateId());
signPatientManageRouteNode.setPhoneMessageTemplateName(StringUtils.isBlank(routeNode.getPhoneMessageTemplateName()) ? null : routeNode.getPhoneMessageTemplateName());
signPatientManageRouteNode.setPhoneDialMethod(StringUtils.isBlank(routeNode.getPhoneDialMethod()) ? null : routeNode.getPhoneDialMethod()); signPatientManageRouteNode.setPhonePushSign(Objects.isNull(routeNode.getPhonePushSign()) ? null : routeNode.getPhonePushSign());
signPatientManageRouteNode.setPhoneDialMethod(StringUtils.isBlank(routeNode.getPhoneDialMethod()) ? null : routeNode.getPhoneDialMethod());
signPatientManageRouteNode.setPhonePushSign(Objects.isNull(routeNode.getPhonePushSign()) ? null : routeNode.getPhonePushSign());
}
//根据问卷ID获取问卷信息 zyk 20241216
QuestionInfo questionInfo = questionInfoService.selectQuestionInfoById(signPatientManageRouteNode.getQuestionInfoId());

View File

@ -364,9 +364,12 @@
LEFT JOIN patient_visit_record pvr ON pi.patient_visit_record_id = pvr.id
<where>
pi.del_flag = 0
and spmrn.del_flag = 0
and spmrn.phone_push_sign = 1
AND spmrn.route_check_status = 'AGREE'
AND spmrn.task_node_type in ('PHONE_OUTBOUND','QUESTIONNAIRE_SCALE')
<if test="taskNodeType != null and taskNodeType != ''">
AND spmrn.task_node_type = #{taskNodeType}
</if>
<if test="patientName != null and patientName != ''">
AND pi.patient_name LIKE concat('%', #{patientName}, '%')
</if>
@ -415,7 +418,10 @@
<if test="phoneNodeExecuteResultStatus = null">
AND (spmrn.phone_node_execute_result_status is null or spmrn.phone_node_execute_result_status = ' ')
</if>
<if test="phoneDialMethod != null">
<if test="phoneDialMethod == 'ALL'">
AND (spmrn.phone_dial_method = 'AI' OR spmrn.phone_dial_method = 'COMMON')
</if>
<if test="phoneDialMethod != null and phoneDialMethod != 'ALL'">
AND spmrn.phone_dial_method = #{phoneDialMethod}
</if>
-- 如果是单个执行类型,应考虑默认为空时,按单个任务处理
@ -691,4 +697,38 @@
from patient_info
where id = #{id}
</select>
<select id="selectRouteByNodeIds"
resultType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute">
<include refid="selectSignPatientManageRouteVo"/>
where id in (select manage_route_id form sign_patient_manage_route_node where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>)
</select>
<select id="selectRouteByParentRouteIds"
resultType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute">
<include refid="selectSignPatientManageRouteVo"/>
where parent_route_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<update id="updateSignPatientManageRouteByIds">
update sign_patient_manage_route set route_sort = 10000000 where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectParentRouteIds"
resultType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute">
<include refid="selectSignPatientManageRouteVo"/>
where parent_route_id in (select parent_route_id form sign_patient_manage_route where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>)
</select>
</mapper>

View File

@ -1369,4 +1369,25 @@
AND pqor.option_choose_sign = #{optionChooseSign}
ORDER BY spmrn.create_time DESC
</select>
<select id="selectSameManageRouteNodeIdByNodeIds"
resultType="com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode">
select *
from sign_patient_manage_route_node
where del_flag = 0 and manage_route_id in
(select manage_route_id from sign_patient_manage_route_node where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>)
</select>
<select id="selectSameManageRouteNodeIdByRouteIds"
resultType="com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode">
select *
from sign_patient_manage_route_node
where del_flag = 0 and manage_route_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>