diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index b41e5d3e..e1b2846a 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -395,5 +395,8 @@ public class Constants { */ public static final String SMS_CODE ="SMS_CODE_"; - + /** + * 医院时间配置 + */ + public static final String DIAL_TIME ="dial_time"; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfoimportmain/PatientInfoImportMainController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfoimportmain/PatientInfoImportMainController.java index 7e8c6b1d..6eb9a083 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfoimportmain/PatientInfoImportMainController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfoimportmain/PatientInfoImportMainController.java @@ -4,6 +4,7 @@ package com.xinelu.manage.controller.patientinfoimportmain; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.page.TableDataInfo; +import com.xinelu.manage.domain.dialtime.DialTime; import com.xinelu.manage.service.patientinfoimportmain.IPatientInfoImportMainService; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; import com.xinelu.manage.vo.patientinfoimportmain.PatientInfoImportMainVO; @@ -55,4 +56,21 @@ public class PatientInfoImportMainController extends BaseController { public AjaxResult updatePatientInfoImport(@RequestBody PatientInfoVo patientInfoVo) { return AjaxResult.success(patientInfoImportMainService.updatePatientInfoImport(patientInfoVo)); } + + /** + * 获取医院外呼时间起止详细信息 + */ + @ApiOperation("获取医院外呼时间起止详细信息") + @GetMapping(value = "/selectDialTime") + public AjaxResult selectDialTimeById() { + return patientInfoImportMainService.selectDialTimeById(); + } + + /** + * 新增医院外呼时间起止 + */ + @PostMapping("/addDialTime") + public AjaxResult add(@RequestBody DialTime dialTime) { + return patientInfoImportMainService.insertDialTime(dialTime); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/dialtime/DialTime.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/dialtime/DialTime.java new file mode 100644 index 00000000..93ce15dc --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/dialtime/DialTime.java @@ -0,0 +1,71 @@ +package com.xinelu.manage.domain.dialtime; + +import com.xinelu.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 医院外呼时间起止对象 dial_time + * + * @author zh + * @date 2025-04-16 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "医院外呼时间起止对象", description = "dial_time") +public class DialTime extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private Long id; + + /** + * 呼叫开始时间 + */ + @ApiModelProperty(value = "呼叫开始时间") + private String dialStartTime; + + /** + * 呼叫结束时间 + */ + @ApiModelProperty(value = "呼叫结束时间") + private String dialEndTime; + + /** + * 所属机构id + */ + @ApiModelProperty(value = "所属机构id") + private Long hospitalAgencyId; + + /** + * 所属机构名称 + */ + @ApiModelProperty(value = "所属机构名称") + private String hospitalAgencyName; + + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dialStartTime", getDialStartTime()) + .append("dialEndTime", getDialEndTime()) + .append("hospitalAgencyId", getHospitalAgencyId()) + .append("hospitalAgencyName", getHospitalAgencyName()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateTaskDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateTaskDto.java index 7152eebc..a913155d 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateTaskDto.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateTaskDto.java @@ -32,12 +32,12 @@ public class CreateTaskDto { /** * 呼叫开始时间 */ - private String dialStartTime = "09:00"; + private String dialStartTime; /** * 呼叫结束时间 */ - private String dialEndTime = "18:00"; + private String dialEndTime; /** * 禁呼日期, 99-节假日;1-周一;2-周二;3-周三;4-周四;5-周五;6-周六;0-周日,默认为空,表示不限制禁呼日期 diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimportmain/PatientInfoImportMainMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimportmain/PatientInfoImportMainMapper.java index 8abe2d9a..ea22d6ca 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimportmain/PatientInfoImportMainMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimportmain/PatientInfoImportMainMapper.java @@ -1,5 +1,6 @@ package com.xinelu.manage.mapper.patientinfoimportmain; +import com.xinelu.manage.domain.dialtime.DialTime; import com.xinelu.manage.domain.patientinfoimportmain.PatientInfoImportMain; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; import com.xinelu.manage.vo.patientinfoimportmain.PatientInfoImportMainVO; @@ -162,4 +163,36 @@ public interface PatientInfoImportMainMapper { * @return int */ int selectPatientInfoImportCount(String sn); + + /** + * 查询医院外呼时间起止 + * + * @param hospitalAgencyId 医院外呼时间起止主键 + * @return 医院外呼时间起止 + */ + DialTime selectDialTimeById(Long hospitalAgencyId); + + /** + * 新增医院外呼时间起止 + * + * @param dialTime 医院外呼时间起止 + * @return 结果 + */ + int insertDialTime(DialTime dialTime); + + /** + * 修改医院外呼时间起止 + * + * @param dialTime 医院外呼时间起止 + * @return 结果 + */ + int updateDialTime(DialTime dialTime); + + /** + * 根据sn查询医院 + * + * @param sn + * @return Long + */ + Long selectHospitalAgencyId(String sn); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/IPatientInfoImportMainService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/IPatientInfoImportMainService.java index ce5a3484..0c27aef2 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/IPatientInfoImportMainService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/IPatientInfoImportMainService.java @@ -2,6 +2,7 @@ package com.xinelu.manage.service.patientinfoimportmain; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.manage.domain.dialtime.DialTime; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; import com.xinelu.manage.vo.patientinfoimportmain.PatientInfoImportMainVO; @@ -26,4 +27,19 @@ public interface IPatientInfoImportMainService { * @return AjaxResult */ AjaxResult updatePatientInfoImport(PatientInfoVo patientInfoVo); + + /** + * 获取医院外呼时间起止详细信息 + * + * @return AjaxResult + */ + AjaxResult selectDialTimeById(); + + /** + * 新增医院外呼时间起止 + * + * @param dialTime 医院外呼时间起止 + * @return 结果 + */ + AjaxResult insertDialTime(DialTime dialTime); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/impl/PatientInfoImportMainServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/impl/PatientInfoImportMainServiceImpl.java index c7242c2b..4e64ac12 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/impl/PatientInfoImportMainServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfoimportmain/impl/PatientInfoImportMainServiceImpl.java @@ -2,15 +2,22 @@ package com.xinelu.manage.service.patientinfoimportmain.impl; import com.xinelu.common.annotation.DataScope; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.core.domain.entity.SysUser; +import com.xinelu.common.utils.SecurityUtils; +import com.xinelu.manage.domain.agency.Agency; +import com.xinelu.manage.domain.dialtime.DialTime; +import com.xinelu.manage.mapper.agency.AgencyMapper; import com.xinelu.manage.mapper.patientinfoimportmain.PatientInfoImportMainMapper; import com.xinelu.manage.service.patientinfoimportmain.IPatientInfoImportMainService; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; import com.xinelu.manage.vo.patientinfoimportmain.PatientInfoImportMainVO; +import com.xinelu.system.mapper.SysUserMapper; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -21,6 +28,11 @@ public class PatientInfoImportMainServiceImpl implements IPatientInfoImportMainS @Resource PatientInfoImportMainMapper patientInfoImportMainMapper; + @Resource + private SysUserMapper sysUserMapper; + @Resource + private AgencyMapper agencyMapper; + @DataScope(agencyAlias = "p") @Override @@ -80,4 +92,51 @@ public class PatientInfoImportMainServiceImpl implements IPatientInfoImportMainS } return AjaxResult.success(); } + + /** + * 获取医院外呼时间起止详细信息 + * + * @return AjaxResult + */ + @Override + public AjaxResult selectDialTimeById() { + SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); + if (Objects.isNull(sysUser.getHospitalAgencyId())) { + return AjaxResult.error("该账号未绑定医院,请绑定医院后查看!"); + } + Agency agency = agencyMapper.selectAgencyById(sysUser.getHospitalAgencyId()); + if (Objects.isNull(agency)) { + return AjaxResult.error("未查询该账号绑定的医院信息,请联系管理员!"); + } + return AjaxResult.success(patientInfoImportMainMapper.selectDialTimeById(agency.getId())); + } + + /** + * 新增医院外呼时间起止 + * + * @param dialTime 医院外呼时间起止 + * @return 结果 + */ + @Override + public AjaxResult insertDialTime(DialTime dialTime) { + SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); + if (Objects.isNull(sysUser.getHospitalAgencyId())) { + return AjaxResult.error("该账号未绑定医院,请绑定医院后添加!"); + } + Agency agency = agencyMapper.selectAgencyById(sysUser.getHospitalAgencyId()); + if (Objects.isNull(agency)) { + return AjaxResult.error("未查询该账号绑定的医院信息,请联系管理员!"); + } + DialTime dataDialTime = patientInfoImportMainMapper.selectDialTimeById(agency.getId()); + dialTime.setHospitalAgencyId(agency.getId()); + dialTime.setHospitalAgencyName(agency.getAgencyName()); + if (Objects.nonNull(dataDialTime)) { + dialTime.setUpdateTime(LocalDateTime.now()); + dialTime.setUpdateBy(SecurityUtils.getUsername()); + return AjaxResult.success(patientInfoImportMainMapper.updateDialTime(dialTime)); + } + dialTime.setCreateTime(LocalDateTime.now()); + dialTime.setCreateBy(SecurityUtils.getUsername()); + return AjaxResult.success(patientInfoImportMainMapper.insertDialTime(dialTime)); + } } diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimportmain/PatientInfoImportMainMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimportmain/PatientInfoImportMainMapper.xml index 93c8e15f..e4280f3a 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimportmain/PatientInfoImportMainMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimportmain/PatientInfoImportMainMapper.xml @@ -315,4 +315,94 @@ from patient_info_import where sn = #{sn} + + + + + insert into dial_time + + dial_start_time, + + dial_end_time, + + hospital_agency_id, + + hospital_agency_name, + + create_by, + + create_time, + + update_by, + + update_time, + + + + #{dialStartTime}, + + #{dialEndTime}, + + #{hospitalAgencyId}, + + #{hospitalAgencyName}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + + + + + + update dial_time + + dial_start_time = + #{dialStartTime}, + + dial_end_time = + #{dialEndTime}, + + hospital_agency_id = + #{hospitalAgencyId}, + + hospital_agency_name = + #{hospitalAgencyName}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + + + where hospital_agency_id = #{hospitalAgencyId} + + + diff --git a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java index 9e0a9001..f9ee28e6 100644 --- a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java +++ b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java @@ -2,9 +2,12 @@ package com.xinelu.quartz.task; import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.constant.AiobTaskTypeContant; +import com.xinelu.common.constant.Constants; +import com.xinelu.common.core.domain.entity.SysDictData; import com.xinelu.common.enums.*; import com.xinelu.common.utils.StringUtils; import com.xinelu.common.utils.regex.RegexUtil; +import com.xinelu.manage.domain.dialtime.DialTime; import com.xinelu.manage.domain.patientinfo.PatientInfo; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; import com.xinelu.manage.domain.scriptInfo.ScriptInfo; @@ -19,6 +22,8 @@ import com.xinelu.manage.dto.aiob.ImportTaskDto; import com.xinelu.manage.dto.signpatientmanageroutenode.SignPatientManageRouteNodeDto; import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.mapper.patientinfoimport.PatientInfoImportMapper; +import com.xinelu.manage.mapper.patientinfoimportmain.PatientInfoImportMainMapper; import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper; import com.xinelu.manage.mapper.scriptInfo.ScriptInfoMapper; import com.xinelu.manage.mapper.scriptinfotaskinfo.ScriptInfoTaskInfoMapper; @@ -38,6 +43,7 @@ import java.util.*; import java.util.stream.Collectors; import javax.annotation.Resource; +import com.xinelu.system.service.ISysDictTypeService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -77,6 +83,10 @@ public class UploadRobotPublishTask { private LabelFieldContentMapper labelFieldContentMapper; @Resource private RegexUtil regexUtil; + @Resource + private ISysDictTypeService iSysDictTypeService; + @Resource + private PatientInfoImportMainMapper patientInfoImportMainMapper; /** * @description 创建百度智能外呼任务并导入客户名单 @@ -149,6 +159,26 @@ public class UploadRobotPublishTask { scriptInfoTaskInfoQuery.setSn(sn); String taskId = scriptInfoTaskInfoMapper.getByNodeId(scriptInfoTaskInfoQuery); if (StringUtils.isBlank(taskId)) { + Long aLong = patientInfoImportMainMapper.selectHospitalAgencyId(sn); + DialTime dialTime = patientInfoImportMainMapper.selectDialTimeById(aLong); + LocalTime localStartTime = LocalTime.parse(dialTime.getDialStartTime()); + LocalTime localEndTime = LocalTime.parse(dialTime.getDialEndTime()); + LocalTime dateStartTime; + LocalTime dateEndTime; + List sysDictDataList = iSysDictTypeService.selectDictDataByType(Constants.DIAL_TIME); + if (CollectionUtils.isEmpty(sysDictDataList) || sysDictDataList.size() != 2) { + dateStartTime = LocalTime.parse("08:00"); + dateEndTime = LocalTime.parse("16:00"); + } else { + dateStartTime = LocalTime.parse(sysDictDataList.get(0).getDictLabel()); + dateEndTime = LocalTime.parse(sysDictDataList.get(1).getDictLabel()); + } + if (dateStartTime.isAfter(localStartTime) ) { + localStartTime = dateStartTime; + } + if (dateEndTime.isBefore(localEndTime)) { + localEndTime = dateEndTime; + } // 没有任务则创建任务 if (ObjectUtils.isNotEmpty(scriptInfo)) { log.info("创建任务......"); @@ -168,6 +198,8 @@ public class UploadRobotPublishTask { createTaskDto.setNumTypeFilterList(Arrays.asList(1, 2)); createTaskDto.setTaskDataCallback(true); createTaskDto.setCallBackUrl(callBackUrl); + createTaskDto.setDialStartTime(localStartTime.format(DateTimeFormatter.ofPattern("HH:mm"))); + createTaskDto.setDialEndTime(localEndTime.format(DateTimeFormatter.ofPattern("HH:mm"))); taskId = aiobService.createTask(createTaskDto); // 开启任务 log.info("开启任务......");