Browse Source

接触病患学生统计

master
zhizhi wu 5 years ago
parent
commit
bd433e0827
  1. 11
      health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java
  2. 18
      health/src/main/java/com/ccsens/health/bean/dto/MemberDto.java
  3. 21
      health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java
  4. 30
      health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java
  5. 16
      health/src/main/java/com/ccsens/health/bean/vo/MemberVo.java
  6. 8
      health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java
  7. 16
      health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java
  8. 17
      health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java
  9. 143
      health/src/main/java/com/ccsens/health/service/StudentService.java
  10. 4
      health/src/main/resources/application.yml
  11. 16
      health/src/main/resources/mapper_dao/HealthRecordDao.xml
  12. 52
      health/src/main/resources/mapper_dao/JourneyDao.xml
  13. 41
      health/src/main/resources/mapper_dao/SiteClockInDao.xml
  14. 1
      util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java

11
health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java

@ -32,4 +32,15 @@ public class ClockDto {
@ApiModelProperty("场所id")
private Long id;
}
@Data
@ApiModel("查询打卡用户")
public static class QueryClockUser{
@ApiModelProperty("场所ID")
private Long siteId;
@ApiModelProperty("进入时间")
private Long inTime;
@ApiModelProperty("出去时间")
private Long outTime;
}
}

18
health/src/main/java/com/ccsens/health/bean/dto/MemberDto.java

@ -33,17 +33,19 @@ public class MemberDto {
private String patientName;
@ApiModelProperty("病患学号")
private String patientMkno;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("学号")
private String wkno;
@ApiModelProperty("班级(所在机构)")
private String department;
// @ApiModelProperty("姓名")
// private String name;
// @ApiModelProperty("学号")
// private String wkno;
// @ApiModelProperty("班级(所在机构)")
// private String department;
@ApiModelProperty("出行方式 0铁路 1飞机 2客运车辆 3自驾 4船 5其他")
private Byte tripMode;
@ApiModelProperty("车次号")
private String carNo;
@ApiModelProperty("开始时间")
private String startTime;
private Long startTime;
@ApiModelProperty("结束时间")
private String endTime;
private Long endTime;
}
}

21
health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java

@ -75,4 +75,25 @@ public class ClockVo {
@ApiModelProperty("出二维码")
private String outUrl;
}
@ApiModel("成员打卡信息")
@Data
public static class ClockInMsg{
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("班级")
private String department;
@ApiModelProperty("学号")
private String no;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("场所ID")
private Long siteId;
@ApiModelProperty("场所名")
private String siteName;
@ApiModelProperty("进入打卡时间")
private Long time;
@ApiModelProperty("出去打卡时间")
private Long outTime;
}
}

30
health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java

@ -65,4 +65,34 @@ public class HealthVo {
//已打卡次数
private int times;
}
@Data
public static class HealthDetail{
@ApiModelProperty("打卡记录的id")
private Long id;
@ApiModelProperty("成员id")
private Long userId;
@ApiModelProperty("日期")
private Long time;
@ApiModelProperty("当前所在地区")
private String district;
@ApiModelProperty("当前所在详细地址")
private String address;
@ApiModelProperty("当前身体状态")
private Long healthTypeId;
@ApiModelProperty("就诊医院")
private String hospital;
@ApiModelProperty("有无湖北武汉接触史 0没有 1有")
private int touchHubei;
@ApiModelProperty("有无接触患者 0无 1有")
private int touchSick;
@ApiModelProperty("体温")
private BigDecimal animalHeat;
@ApiModelProperty("健康状态code")
private Byte code;
@ApiModelProperty("健康状态名字")
private String name;
private String quarantine;
private String independent;
}
}

16
health/src/main/java/com/ccsens/health/bean/vo/MemberVo.java

@ -7,7 +7,9 @@ import lombok.Data;
import javax.validation.constraints.Max;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Data
public class MemberVo {
@ -51,8 +53,6 @@ public class MemberVo {
@Data
@ApiModel("接触病患学生列表(校内打卡)")
public static class ContactPatientInside {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("学号")
@ -68,17 +68,19 @@ public class MemberVo {
@ApiModelProperty("体温")
private BigDecimal animalHeat;
@ApiModelProperty("状态 0:健康 1:治愈 2:隔离 3:疑似 4:确诊")
private int healthType;
private Byte healthType;
@ApiModelProperty("名字")
private String healthTypeName;
@ApiModelProperty("就诊医院")
private String hospital;
@ApiModelProperty("上报时详细地址")
private String address;
@ApiModelProperty("接触场所")
private List<String> contactSiteList;
private Set<String> contactSiteList = new HashSet<>();
@ApiModelProperty("接触病人")
private List<String> contactPatientList;
private String contactPatient;
@ApiModelProperty("打卡场所")
private List<ClockInSite> clockInSiteList;
private List<ClockInSite> clockInSiteList = new ArrayList<>();
}
@Data
@ -105,7 +107,7 @@ public class MemberVo {
private String wkno;
@ApiModelProperty("班级(所在机构)")
private String department;
@ApiModelProperty("'出行方式'")
@ApiModelProperty("出行方式")
private int tripMode;
@ApiModelProperty("车次号")
private String carNo;

8
health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java

@ -17,4 +17,12 @@ public interface HealthRecordsDao extends HealthRecordsMapper {
List<UserVo.HealthCode> getHealthQrCodeByEmployeeId(@Param("employeeId")Long employeeId, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
HealthVo.NotUpload getNotUpload( @Param("days")Long days, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
/**
* 根据user_id和endtime查询最新的一条健康上报信息
* @param userId
* @param endTime
* @return
*/
HealthVo.HealthDetail queryDetail(@Param("userId")Long userId, @Param("endTime") Long endTime);
}

16
health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java

@ -1,7 +1,9 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.bean.dto.MemberDto;
import com.ccsens.health.bean.po.Journey;
import com.ccsens.health.bean.vo.JourneyVo;
import com.ccsens.health.bean.vo.MemberVo;
import com.ccsens.health.persist.mapper.JourneyMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -25,4 +27,18 @@ public interface JourneyDao extends JourneyMapper {
* @return
*/
List<JourneyVo.ClassBack> classBackStatistics(@Param("endTime") Long endTime);
/**
* 根据学号姓名时间查询校外行程
* @param dto
* @return
*/
List<Journey> queryByNoAndName(MemberDto.ContactPatientDto dto);
/**
* 根据行程查询
* @param carNos
* @return
*/
List<MemberVo.ContactPatientOutside> queryByCarNo(List<MemberDto.ContactPatientDto> carNos);
}

17
health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java

@ -1,5 +1,7 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.bean.dto.ClockDto;
import com.ccsens.health.bean.dto.MemberDto;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.health.persist.mapper.SiteClockInMapper;
import org.apache.ibatis.annotations.Param;
@ -12,4 +14,19 @@ public interface SiteClockInDao extends SiteClockInMapper {
List<ClockVo.SiteClockInfo> selectHealthInfoByDate(@Param("employee")Long employee, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
int getClockInNumberBySiteId(@Param("siteId")Long siteId, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
/**
* 查询用户打卡信息
* @param dto
* @return
*/
List<ClockVo.ClockInMsg> queryRecord(MemberDto.ContactPatientDto dto);
/**
* 查询场所时间段内的打卡信息
* @param dtos
* @return
*/
List<ClockVo.ClockInMsg> queryRecordBySite(List<ClockVo.ClockInMsg> dtos);
}

143
health/src/main/java/com/ccsens/health/service/StudentService.java

@ -3,15 +3,13 @@ package com.ccsens.health.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
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.po.EmployeeExample;
import com.ccsens.health.bean.po.Member;
import com.ccsens.health.bean.po.MemberExample;
import com.ccsens.health.bean.po.RealNameAuthExample;
import com.ccsens.health.bean.po.*;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.health.bean.vo.HealthVo;
import com.ccsens.health.bean.vo.MemberVo;
import com.ccsens.health.persist.dao.EmployeeDao;
import com.ccsens.health.persist.dao.MemberDao;
import com.ccsens.health.persist.dao.RealNameAuthDao;
import com.ccsens.health.persist.dao.*;
import com.ccsens.health.util.HealthConstant;
import com.ccsens.util.*;
import com.ccsens.util.bean.dto.QueryDto;
@ -26,9 +24,13 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@ -48,6 +50,14 @@ public class StudentService implements IStudentService{
private RealNameAuthDao realNameAuthDao;
@Resource
private IAsyncService asyncService;
@Resource
private SiteClockInDao siteClockInDao;
@Resource
private HealthRecordsDao healthRecordsDao;
@Resource
private JourneyDao journeyDao;
/**
* 查询学生健康信息列表
* @param params
@ -174,9 +184,128 @@ public class StudentService implements IStudentService{
@Override
public MemberVo.ContactPatientVo getContactPatient(QueryDto<MemberDto.ContactPatientDto> params) {
log.info("查询接触病患学生列表:{}", params);
// 返回对象
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;
}
/**
* 查询学生的校外行程
* @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());
}
}
}

4
health/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: test
include: common, util-test
active: dev
include: common, util-dev

16
health/src/main/resources/mapper_dao/HealthRecordDao.xml

@ -103,4 +103,20 @@
WHERE
a.times &lt; #{days}
</select>
<select id="queryDetail" resultType="com.ccsens.health.bean.vo.HealthVo$HealthDetail">
select r.id, r.user_id as userId, r.time, r.district, r.address,
r.health_type_id as healthTypeId, r.touch_hubei as touchHubei,
r.touch_sick as touchSick, r.animal_heat as animalHeat,
t.code,t.name, t.quarantine, t.independent
from t_health_records r , t_health_type t
where r.health_type_id = t.id
<if test="userId != null">
and r.user_id = #{userId}
</if>
<if test="endTime != null">
and r.time &lt;=#{endTime}
</if>
and r.rec_status = 0
order by r.time desc limit 1
</select>
</mapper>

52
health/src/main/resources/mapper_dao/JourneyDao.xml

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.health.persist.dao.JourneyDao">
<resultMap id="BaseResultMap" type="com.ccsens.health.bean.po.Journey">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="trip_mode" jdbcType="TINYINT" property="tripMode" />
<result column="car_no" jdbcType="VARCHAR" property="carNo" />
<result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="journey_type" jdbcType="TINYINT" property="journeyType" />
<result column="together" jdbcType="VARCHAR" property="together" />
<result column="self_fill" jdbcType="TINYINT" property="selfFill" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<resultMap id="resultMap_journey" type="com.ccsens.health.bean.vo.JourneyVo$JourneyInfo">
<id column="jId" property="id"/>
<result column="jEmployeeId" property="employeeId"/>
@ -57,5 +71,43 @@
on t1.department = t2.department
</select>
<select id="queryByNoAndName" resultMap="BaseResultMap">
select j.* from t_journey j, t_real_name_auth a
where j.user_id = a.user_id
<if test="patientMkno != null and patientMkno != ''">
and a.no = #{patientMkno}
</if>
<if test="patientName != null and patientName != ''">
and a.name = #{patientName}
</if>
<if test="endTime != null">
and j.start_time &lt;= #{endTime}
</if>
<if test="startTime != null">
and j.end_time &gt;= #{startTime}
</if>
and j.rec_status = 0
</select>
<select id="queryByCarNo" resultType="com.ccsens.health.bean.vo.MemberVo$ContactPatientOutside">
select j.trip_mode as tripMode, j.car_no as carNo, j.start_time as startTime, j.end_time as endTime, j.journey_type as journeyType, j.together, a.no, a.name, m.department from t_journey j, t_real_name_auth a, t_member m
where j.user_id = a.user_id and a.no = m.wkno
and
<foreach collection="list" item="item" separator="or" open="(" close=")">
(j.car_no = #{item.carNo}
<if test="item.tripMode != null">
and j.trip_mode = #{item.tripMode}
</if>
<if test="item.endTime != null">
and j.start_time &lt;= #{item.endTime}
</if>
<if test="item.startTime != null">
and j.end_time &gt;= #{item.startTime}
</if>
)
</foreach>
and j.rec_status = 0
ORDER BY a.no, j.start_time
</select>
</mapper>

41
health/src/main/resources/mapper_dao/SiteClockInDao.xml

@ -43,5 +43,46 @@
and
c.time &gt;= #{startTime}
</select>
<select id="queryRecord" resultType="com.ccsens.health.bean.vo.ClockVo$ClockInMsg">
select i.user_id as userId, a.no, a.name, m.department, s.id as siteId,
s.site_name as siteName, i.time, i.out_time as outTime from
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.id
left join t_site s on i.site_id = s.id
left join t_member m on a.no = m.wkno
<where>
<if test="patientMkno !=null and patientMkno != ''">
and a.no = #{patientMkno}
</if>
<if test="patientName !=null and patientName != ''">
and a.name = #{patientName}
</if>
<if test="startTime !=null and endTime != null">
and (i.out_time &gt;= #{startTime} or i.time &lt;= #{endTime})
</if>
<if test="startTime !=null and endTime == null">
and (i.out_time &gt;= #{startTime} or i.time &gt;= #{startTime})
</if>
<if test="endTime !=null and startTime == null">
and (i.time &lt;= #{endTime} or i.out_time &lt;= #{endTime})
</if>
and i.rec_status = 0
</where>
order by i.time
</select>
<select id="queryRecordBySite" resultType="com.ccsens.health.bean.vo.ClockVo$ClockInMsg">
select i.user_id as userId, a.no, a.name, m.department, s.id as siteId,
s.site_name as siteName, i.time, i.out_time as outTime from
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.id
left join t_site s on i.site_id = s.id
left join t_member m on a.no = m.wkno
<where>
<foreach collection="lit" item="item" separator="or" open="(" close=")">
(s.id = #{item.siteId} and i.out_time &gt;= #{item.inTime} and i.time &lt;= #{item.outTime})
</foreach>
and i.rec_status = 0
</where>
order by a.no, i.time
</select>
</mapper>

1
util/src/main/java/com/ccsens/util/bean/dto/QueryDto.java

@ -22,5 +22,4 @@ public class QueryDto<T> {
private T param;
@ApiModelProperty("登录用户ID 前端不为userId赋值")
private Long userId;
}

Loading…
Cancel
Save