导入当月处理
This commit is contained in:
parent
46eca29edb
commit
55fea1032f
@ -5,6 +5,7 @@ import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport;
|
||||
import com.xinelu.manage.domain.residentinfo.ResidentInfo;
|
||||
import com.xinelu.manage.dto.patientinfo.PatientInfoDto;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientBaseInfoVo;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientImportVo;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientInfoVo;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientNextTaskVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -142,13 +143,21 @@ public interface PatientInfoMapper {
|
||||
int selectPatientSignServiceCount();
|
||||
|
||||
/**
|
||||
* 批量查询患者信息
|
||||
* 批量当天查询患者信息
|
||||
*
|
||||
* @param list 集合
|
||||
* @return PatientInfo
|
||||
*/
|
||||
List<PatientInfo> selectPatientInfoByPatientName(@Param("list") List<PatientInfoImport> list, @Param("nowDate") LocalDate nowDate);
|
||||
|
||||
/**
|
||||
* 批量当月查询患者信息
|
||||
*
|
||||
* @param list 集合
|
||||
* @return PatientInfo
|
||||
*/
|
||||
List<PatientImportVo> selectPatientInfoByTime(@Param("list") List<PatientInfoImport> list, @Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||
|
||||
/**
|
||||
* 新增患者信息
|
||||
*
|
||||
|
||||
@ -36,10 +36,12 @@ import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper;
|
||||
import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper;
|
||||
import com.xinelu.manage.service.patientinfo.IPatientInfoService;
|
||||
import com.xinelu.manage.service.patientvisitrecord.IPatientVisitRecordService;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientImportVo;
|
||||
import com.xinelu.manage.vo.patientinfo.PatientInfoVo;
|
||||
import com.xinelu.manage.vo.patientinfoimport.DeptAliasVO;
|
||||
import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO;
|
||||
import com.xinelu.system.mapper.SysUserMapper;
|
||||
import com.xinelu.system.service.ISysConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
@ -48,13 +50,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -89,6 +89,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
private PatientInfoImportMainMapper patientInfoImportMainMapper;
|
||||
@Resource
|
||||
private AgencyMapper agencyMapper;
|
||||
@Resource
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
/**
|
||||
* 查询患者信息
|
||||
@ -374,9 +376,21 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
//如果要求自动去重(同数据库中 当日已导入患者列表 比对,如果患者姓名和手机号相同,视为重复)
|
||||
if (Objects.isNull(isDistinct) || isDistinct == 1) {
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
//此处实现是跟患者表数据比对,(也可以直接跟已导入患者表数据比对)
|
||||
//此处实现是当天跟患者表数据比对,(也可以直接跟已导入患者表数据比对)
|
||||
patientInfos_CurrentDay = patientInfoMapper.selectPatientInfoByPatientName(list, nowDate);
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = new Date();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
//获得本月第一天
|
||||
calendar.add(Calendar.MONTH, 0);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
String firstDay = sdf.format(calendar.getTime());
|
||||
//获得本月最后一天
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
String lastDay = sdf.format(calendar.getTime());
|
||||
List<PatientImportVo> patientInfoList = patientInfoMapper.selectPatientInfoByTime(list, firstDay, lastDay);
|
||||
//sn 导入流水号;
|
||||
String sn = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
|
||||
@ -390,6 +404,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
List<PatientInfoImport> patientInfoImportList = new ArrayList<>();
|
||||
//要导入的居民信息列表
|
||||
List<PatientInfoImport> patientInfoImportList_forResident = new ArrayList<>();
|
||||
String aiobMaxCount = sysConfigService.selectConfigByKey("aiob_max_count");
|
||||
for (PatientInfoImport patientInfoImport : distinctCollect) {
|
||||
//选择自动去除当日重复记录
|
||||
// if (CollectionUtils.isNotEmpty(residentInfos)) {
|
||||
@ -401,7 +416,14 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
// 如果当日已有导入,则不再重复导入
|
||||
if (CollectionUtils.isNotEmpty(patientInfos_CurrentDay) && (Objects.isNull(isDistinct) || isDistinct == 1)) {
|
||||
List<PatientInfo> collect1 = patientInfos_CurrentDay.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect1)) {
|
||||
if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//同一手机号每月可最多拔打xx次
|
||||
if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount)) {
|
||||
List<PatientInfo> collect1 = patientInfoList.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientPhone().equals(item.getPatientPhone()) && item.getCountPhone() >= Long.parseLong(aiobMaxCount)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xinelu.manage.vo.patientinfo;
|
||||
|
||||
import com.xinelu.manage.domain.patientinfo.PatientInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 某时间段电话外呼数量
|
||||
* @author: zh
|
||||
* @create: 2025-01-3
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PatientImportVo extends PatientInfo {
|
||||
|
||||
/**
|
||||
* 某时间段电话外呼数量
|
||||
*/
|
||||
private Long countPhone;
|
||||
}
|
||||
@ -882,6 +882,34 @@
|
||||
AND date_format(create_time,'%y%m%d') = date_format(#{nowDate},'%y%m%d')
|
||||
</select>
|
||||
|
||||
<select id="selectPatientInfoByTime" resultType="com.xinelu.manage.vo.patientinfo.PatientImportVo">
|
||||
select
|
||||
pii.patient_name,
|
||||
pii.patient_phone,
|
||||
(select count(1) FROM sign_patient_manage_route_node a
|
||||
LEFT JOIN sign_patient_manage_route b ON a.manage_route_id = b.id
|
||||
LEFT JOIN patient_info c ON c.id = b.patient_id
|
||||
LEFT JOIN patient_info_import d ON d.id = c.patient_info_import_id
|
||||
where
|
||||
a.del_flag = 0
|
||||
AND c.del_flag = 0
|
||||
AND a.sn IS NOT NULL
|
||||
AND c.sn IS NOT NULL
|
||||
AND d.patient_phone = pi.patient_phone
|
||||
AND date_format(a.node_finish_date,'%y%m%d') >= #{startDate}
|
||||
AND date_format(a.node_finish_date,'%y%m%d') <= #{endDate})
|
||||
countPhone
|
||||
FROM patient_info_import pii
|
||||
LEFT JOIN patient_info pi ON pii.id = pi.patient_info_import_id
|
||||
where
|
||||
pi.del_flag = 0
|
||||
AND pi.sn IS NOT NULL
|
||||
and pi.patient_phone IN
|
||||
<foreach item="list" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{list.patientPhone}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insertPatientInfoList" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into patient_info(
|
||||
resident_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user