@ -3,15 +3,13 @@ package com.ccsens.health.service;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.lang.Snowflake ;
import cn.hutool.core.lang.Snowflake ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.core.util.StrUtil ;
import com.ccsens.health.bean.dto.JourneyDto ;
import com.ccsens.health.bean.dto.MemberDto ;
import com.ccsens.health.bean.dto.MemberDto ;
import com.ccsens.health.bean.po.EmployeeExample ;
import com.ccsens.health.bean.po.* ;
import com.ccsens.health.bean.po.Member ;
import com.ccsens.health.bean.vo.ClockVo ;
import com.ccsens.health.bean.po.MemberExample ;
import com.ccsens.health.bean.vo.HealthVo ;
import com.ccsens.health.bean.po.RealNameAuthExample ;
import com.ccsens.health.bean.vo.MemberVo ;
import com.ccsens.health.bean.vo.MemberVo ;
import com.ccsens.health.persist.dao.EmployeeDao ;
import com.ccsens.health.persist.dao.* ;
import com.ccsens.health.persist.dao.MemberDao ;
import com.ccsens.health.persist.dao.RealNameAuthDao ;
import com.ccsens.health.util.HealthConstant ;
import com.ccsens.health.util.HealthConstant ;
import com.ccsens.util.* ;
import com.ccsens.util.* ;
import com.ccsens.util.bean.dto.QueryDto ;
import com.ccsens.util.bean.dto.QueryDto ;
@ -26,9 +24,13 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import javax.annotation.Resource ;
import javax.annotation.Resource ;
import javax.validation.Valid ;
import java.io.File ;
import java.io.File ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
@Slf4j
@Slf4j
@Service
@Service
@Transactional ( propagation = Propagation . REQUIRED , rollbackFor = Exception . class )
@Transactional ( propagation = Propagation . REQUIRED , rollbackFor = Exception . class )
@ -48,6 +50,14 @@ public class StudentService implements IStudentService{
private RealNameAuthDao realNameAuthDao ;
private RealNameAuthDao realNameAuthDao ;
@Resource
@Resource
private IAsyncService asyncService ;
private IAsyncService asyncService ;
@Resource
private SiteClockInDao siteClockInDao ;
@Resource
private HealthRecordsDao healthRecordsDao ;
@Resource
private JourneyDao journeyDao ;
/ * *
/ * *
* 查询学生健康信息列表
* 查询学生健康信息列表
* @param params
* @param params
@ -174,9 +184,128 @@ public class StudentService implements IStudentService{
@Override
@Override
public MemberVo . ContactPatientVo getContactPatient ( QueryDto < MemberDto . ContactPatientDto > params ) {
public MemberVo . ContactPatientVo getContactPatient ( QueryDto < MemberDto . ContactPatientDto > params ) {
log . info ( "查询接触病患学生列表:{}" , params ) ;
log . info ( "查询接触病患学生列表:{}" , params ) ;
// 返回对象
MemberVo . ContactPatientVo vo = new MemberVo . ContactPatientVo ( ) ;
MemberVo . ContactPatientVo vo = new MemberVo . ContactPatientVo ( ) ;
//请求参数
MemberDto . ContactPatientDto dto = params . getParam ( ) ;
// 校外行程车次
List < MemberDto . ContactPatientDto > carNos = new ArrayList < > ( ) ;
if ( StrUtil . isNotBlank ( dto . getCarNo ( ) ) ) {
carNos . add ( dto ) ;
}
if ( StrUtil . isNotBlank ( dto . getPatientMkno ( ) ) | | StrUtil . isNotBlank ( dto . getPatientName ( ) ) ) {
//查询打卡
List < ClockVo . ClockInMsg > clockInMsgs = siteClockInDao . queryRecord ( dto ) ;
log . info ( "病人打卡信息" ) ;
if ( CollectionUtil . isNotEmpty ( clockInMsgs ) ) {
// 查询同时间同场所接触信息
List < ClockVo . ClockInMsg > allClockIns = siteClockInDao . queryRecordBySite ( clockInMsgs ) ;
//封装用户打卡信息,并查询用户时间范围内最新的健康上报信息
List < MemberVo . ContactPatientInside > insides = transInsideVo ( allClockIns , dto . getEndTime ( ) , clockInMsgs . get ( 0 ) . getName ( ) ) ;
// 查询病人外出行程
vo . setContactPatientInsideList ( insides ) ;
}
// 查询校外行程
queryJourney ( dto , carNos ) ;
}
if ( CollectionUtil . isNotEmpty ( carNos ) ) {
List < MemberVo . ContactPatientOutside > outsides = journeyDao . queryByCarNo ( carNos ) ;
vo . getContactPatientOutsideList ( ) . addAll ( outsides ) ;
}
log . info ( "疫情查看" ) ;
return vo ;
return vo ;
}
}
/ * *
* 查询学生的校外行程
* @param dto
* @param carNos
* /
private void queryJourney ( MemberDto . ContactPatientDto dto , List < MemberDto . ContactPatientDto > carNos ) {
List < Journey > journeys = journeyDao . queryByNoAndName ( dto ) ;
if ( CollectionUtil . isNotEmpty ( journeys ) ) {
journeys . forEach ( journey - > {
MemberDto . ContactPatientDto carDto = new MemberDto . ContactPatientDto ( ) ;
carDto . setCarNo ( journey . getCarNo ( ) ) ;
carDto . setTripMode ( journey . getTripMode ( ) ) ;
carDto . setStartTime ( journey . getStartTime ( ) ) ;
carDto . setEndTime ( journey . getEndTime ( ) ) ;
carNos . add ( carDto ) ;
} ) ;
}
}
/ * *
* 将打卡记录转换为所需样式返回
* @param allClockIns 转换对象
* @param endTime 结束时间
* @return
* /
private List < MemberVo . ContactPatientInside > transInsideVo ( List < ClockVo . ClockInMsg > allClockIns , Long endTime , String patientName ) {
List < MemberVo . ContactPatientInside > insides = new ArrayList < > ( ) ;
if ( CollectionUtil . isEmpty ( allClockIns ) ) {
return insides ;
}
Map < String , MemberVo . ContactPatientInside > memberMap = new HashMap < > ( ) ;
allClockIns . forEach ( clockInMsg - > {
MemberVo . ContactPatientInside inside ;
String no = clockInMsg . getNo ( ) ;
if ( memberMap . containsKey ( no ) ) {
inside = memberMap . get ( no ) ;
} else {
inside = new MemberVo . ContactPatientInside ( ) ;
inside . setName ( clockInMsg . getName ( ) ) ;
inside . setWkno ( clockInMsg . getNo ( ) ) ;
inside . setDepartment ( clockInMsg . getDepartment ( ) ) ;
inside . setContactPatient ( patientName ) ;
//初始化健康信息
initHealth ( endTime , clockInMsg , inside ) ;
memberMap . put ( no , inside ) ;
//将对象保存在list中
insides . add ( inside ) ;
}
inside . getContactSiteList ( ) . add ( clockInMsg . getSiteName ( ) ) ;
inside . getClockInSiteList ( ) . add ( transClock ( clockInMsg ) ) ;
} ) ;
return insides ;
}
/ * *
* 转化对象
* @param clockInMsg
* @return
* /
private MemberVo . ClockInSite transClock ( ClockVo . ClockInMsg clockInMsg ) {
MemberVo . ClockInSite site = new MemberVo . ClockInSite ( ) ;
site . setSiteId ( clockInMsg . getSiteId ( ) ) ;
site . setSiteName ( clockInMsg . getSiteName ( ) ) ;
site . setInSiteTime ( clockInMsg . getTime ( ) ) ;
site . setOutSiteTime ( clockInMsg . getOutTime ( ) ) ;
return site ;
}
/ * *
* 初始化健康信息
* @param endTime
* @param clockInMsg
* @param inside
* /
private void initHealth ( Long endTime , ClockVo . ClockInMsg clockInMsg , MemberVo . ContactPatientInside inside ) {
HealthVo . HealthDetail healthDetail = healthRecordsDao . queryDetail ( clockInMsg . getUserId ( ) , endTime ) ;
if ( healthDetail ! = null ) {
inside . setHealthType ( healthDetail . getCode ( ) ) ;
inside . setHealthTypeName ( healthDetail . getName ( ) ) ;
inside . setAnimalHeat ( healthDetail . getAnimalHeat ( ) ) ;
inside . setTouchHubei ( healthDetail . getTouchHubei ( ) ) ;
inside . setTouchSick ( healthDetail . getTouchSick ( ) ) ;
inside . setAddress ( healthDetail . getDistrict ( ) + healthDetail . getAddress ( ) ) ;
inside . setTime ( healthDetail . getTime ( ) ) ;
inside . setHospital ( healthDetail . getHospital ( ) ) ;
}
}
}
}