Browse Source

查看个人健康信息

master
zhangye 5 years ago
parent
commit
5ea1b4639d
  1. 7
      health/src/main/java/com/ccsens/health/api/HealthController.java
  2. 2
      health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java
  3. 6
      health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java
  4. 4
      health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java
  5. 12
      health/src/main/java/com/ccsens/health/bean/po/HealthRecords.java
  6. 58
      health/src/main/java/com/ccsens/health/bean/po/HealthRecordsExample.java
  7. 6
      health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java
  8. 8
      health/src/main/java/com/ccsens/health/persist/dao/HealthQRCodeDao.java
  9. 20
      health/src/main/java/com/ccsens/health/service/HealthService.java
  10. 2
      health/src/main/java/com/ccsens/health/service/IHealthService.java
  11. 9
      health/src/main/java/com/ccsens/health/service/JourneyService.java
  12. 4
      health/src/main/resources/application.yml
  13. 4
      health/src/main/resources/mapper_dao/HealthRecordDao.xml
  14. 30
      health/src/main/resources/mapper_raw/HealthRecordsMapper.xml

7
health/src/main/java/com/ccsens/health/api/HealthController.java

@ -35,8 +35,7 @@ public class HealthController {
@RequestMapping(value = "upload", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<HealthVo.HealthInfo> addHealthInfo(@ApiParam @Validated @RequestBody QueryDto<HealthDto.healthInfo> params) throws Exception {
log.info("健康打卡:{}",params);
// String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN);
HealthVo.HealthInfo healthInfo = healthService.addHealthInfo(null,params);
HealthVo.HealthInfo healthInfo = healthService.addHealthInfo(params);
return JsonResponse.newInstance().ok(healthInfo);
}
@ -62,9 +61,9 @@ public class HealthController {
@MustLogin
@ApiOperation(value = "健康类型统计", notes = "")
@RequestMapping(value = "statistics", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<HealthVo.HealthTypeStatistics>> getHealthTypeStatistics(@ApiParam @Validated @RequestBody JourneyDto.StatisticsDate date) throws Exception {
public JsonResponse<List<HealthVo.HealthTypeStatistics>> getHealthTypeStatistics(@ApiParam @Validated @RequestBody QueryDto<JourneyDto.StatisticsDate> params) throws Exception {
log.info("健康类型统计");
List<HealthVo.HealthTypeStatistics> healthTypeStatisticsList = healthService.getHealthTypeStatistics(date.getDate());
List<HealthVo.HealthTypeStatistics> healthTypeStatisticsList = healthService.getHealthTypeStatistics(params.getParam().getDate());
return JsonResponse.newInstance().ok(healthTypeStatisticsList);
}

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

@ -9,6 +9,8 @@ public class ClockDto {
@Data
@ApiModel("场景id")
public static class SiteDto{
@ApiModelProperty("token")
private Long token;
@ApiModelProperty("场景id")
private Long siteId;
}

6
health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java

@ -13,6 +13,8 @@ public class HealthDto {
@Data
@ApiModel("上报健康状况")
public static class healthInfo{
@ApiModelProperty("token")
private String token;
@ApiModelProperty("当前所在地区")
private String district;
@ApiModelProperty("当前所在详细地址")
@ -22,9 +24,9 @@ public class HealthDto {
@ApiModelProperty("就诊医院")
private String hospital;
@ApiModelProperty("有无湖北武汉接触史 0没有 1有")
private int touchHuBei;
private int touchHubei;
@ApiModelProperty("有无接触患者 0无 1有")
private Long touchSick;
private int touchSick;
@ApiModelProperty("体温")
private BigDecimal animalHeat;
}

4
health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java

@ -27,6 +27,8 @@ public class JourneyDto {
@Data
@ApiModel("查询的时间范围")
public static class SelectDate{
@ApiModelProperty("token")
private String token;
@ApiModelProperty("开始时间 默认今天零点")
private Long startTime;
@ApiModelProperty("结束时间 默认当前时间")
@ -36,7 +38,7 @@ public class JourneyDto {
@Data
@ApiModel("统计时的日期")
public static class StatisticsDate{
@ApiModelProperty("日期")
@ApiModelProperty("日期(格式:yy-[MM]-[dd])")
private String date;
}
}

12
health/src/main/java/com/ccsens/health/bean/po/HealthRecords.java

@ -15,7 +15,7 @@ public class HealthRecords implements Serializable {
private String address;
private String healthStatus;
private Long healthTypeId;
private String hospital;
@ -75,12 +75,12 @@ public class HealthRecords implements Serializable {
this.address = address == null ? null : address.trim();
}
public String getHealthStatus() {
return healthStatus;
public Long getHealthTypeId() {
return healthTypeId;
}
public void setHealthStatus(String healthStatus) {
this.healthStatus = healthStatus == null ? null : healthStatus.trim();
public void setHealthTypeId(Long healthTypeId) {
this.healthTypeId = healthTypeId;
}
public String getHospital() {
@ -158,7 +158,7 @@ public class HealthRecords implements Serializable {
sb.append(", time=").append(time);
sb.append(", district=").append(district);
sb.append(", address=").append(address);
sb.append(", healthStatus=").append(healthStatus);
sb.append(", healthTypeId=").append(healthTypeId);
sb.append(", hospital=").append(hospital);
sb.append(", touchHubei=").append(touchHubei);
sb.append(", touchSick=").append(touchSick);

58
health/src/main/java/com/ccsens/health/bean/po/HealthRecordsExample.java

@ -426,73 +426,63 @@ public class HealthRecordsExample {
return (Criteria) this;
}
public Criteria andHealthStatusIsNull() {
addCriterion("health_status is null");
public Criteria andHealthTypeIdIsNull() {
addCriterion("health_type_id is null");
return (Criteria) this;
}
public Criteria andHealthStatusIsNotNull() {
addCriterion("health_status is not null");
public Criteria andHealthTypeIdIsNotNull() {
addCriterion("health_type_id is not null");
return (Criteria) this;
}
public Criteria andHealthStatusEqualTo(String value) {
addCriterion("health_status =", value, "healthStatus");
public Criteria andHealthTypeIdEqualTo(Long value) {
addCriterion("health_type_id =", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusNotEqualTo(String value) {
addCriterion("health_status <>", value, "healthStatus");
public Criteria andHealthTypeIdNotEqualTo(Long value) {
addCriterion("health_type_id <>", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusGreaterThan(String value) {
addCriterion("health_status >", value, "healthStatus");
public Criteria andHealthTypeIdGreaterThan(Long value) {
addCriterion("health_type_id >", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusGreaterThanOrEqualTo(String value) {
addCriterion("health_status >=", value, "healthStatus");
public Criteria andHealthTypeIdGreaterThanOrEqualTo(Long value) {
addCriterion("health_type_id >=", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusLessThan(String value) {
addCriterion("health_status <", value, "healthStatus");
public Criteria andHealthTypeIdLessThan(Long value) {
addCriterion("health_type_id <", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusLessThanOrEqualTo(String value) {
addCriterion("health_status <=", value, "healthStatus");
public Criteria andHealthTypeIdLessThanOrEqualTo(Long value) {
addCriterion("health_type_id <=", value, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusLike(String value) {
addCriterion("health_status like", value, "healthStatus");
public Criteria andHealthTypeIdIn(List<Long> values) {
addCriterion("health_type_id in", values, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusNotLike(String value) {
addCriterion("health_status not like", value, "healthStatus");
public Criteria andHealthTypeIdNotIn(List<Long> values) {
addCriterion("health_type_id not in", values, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusIn(List<String> values) {
addCriterion("health_status in", values, "healthStatus");
public Criteria andHealthTypeIdBetween(Long value1, Long value2) {
addCriterion("health_type_id between", value1, value2, "healthTypeId");
return (Criteria) this;
}
public Criteria andHealthStatusNotIn(List<String> values) {
addCriterion("health_status not in", values, "healthStatus");
return (Criteria) this;
}
public Criteria andHealthStatusBetween(String value1, String value2) {
addCriterion("health_status between", value1, value2, "healthStatus");
return (Criteria) this;
}
public Criteria andHealthStatusNotBetween(String value1, String value2) {
addCriterion("health_status not between", value1, value2, "healthStatus");
public Criteria andHealthTypeIdNotBetween(Long value1, Long value2) {
addCriterion("health_type_id not between", value1, value2, "healthTypeId");
return (Criteria) this;
}

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

@ -25,13 +25,15 @@ public class HealthVo {
@ApiModelProperty("当前身体状态")
private Long healthTypeId;
@ApiModelProperty("就诊医院")
private Long hospital;
private String hospital;
@ApiModelProperty("有无湖北武汉接触史 0没有 1有")
private int touchHuBei;
private int touchHubei;
@ApiModelProperty("有无接触患者 0无 1有")
private int touchSick;
@ApiModelProperty("体温")
private BigDecimal animalHeat;
@ApiModelProperty("健康码等级 0正常 1隔离中或疑似 2确诊")
private int healthLevel;
@ApiModelProperty("健康码")
private String healthCode;
}

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

@ -0,0 +1,8 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.persist.mapper.HealthQRCodeMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface HealthQRCodeDao extends HealthQRCodeMapper {
}

20
health/src/main/java/com/ccsens/health/service/HealthService.java

@ -3,10 +3,12 @@ package com.ccsens.health.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.health.bean.dto.HealthDto;
import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.po.*;
import com.ccsens.health.bean.vo.HealthVo;
import com.ccsens.health.persist.dao.HealthQRCodeDao;
import com.ccsens.health.persist.dao.HealthRecordsDao;
import com.ccsens.health.persist.dao.HealthTypeDao;
import com.ccsens.util.DateUtil;
@ -31,7 +33,10 @@ public class HealthService implements IHealthService{
private HealthRecordsDao healthRecordsDao;
@Autowired
private HealthTypeDao healthTypeDao;
@Autowired
private HealthQRCodeDao healthQRCodeDao;
@Autowired
private TallFeignClient tallFeignClient;
/**
* 上报健康信息
@ -39,7 +44,7 @@ public class HealthService implements IHealthService{
* @return
*/
@Override
public HealthVo.HealthInfo addHealthInfo(String token ,QueryDto<HealthDto.healthInfo> params) throws IOException {
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws IOException {
//1、获取健康信息和userId
HealthDto.healthInfo healthInfo = params.getParam();
Long userId = params.getUserId();
@ -48,21 +53,22 @@ public class HealthService implements IHealthService{
//3、保存健康信息
HealthRecords healthRecords = new HealthRecords();
healthRecords.setId(snowflake.nextId());
healthRecords.setTime(System.currentTimeMillis());
healthRecords.setEmployeeId(employee.getId());
BeanUtil.copyProperties(healthInfo,healthRecords);
healthRecordsDao.insertSelective(healthRecords);
//4、生成健康码,返回地址
String qrcodeInfo = WebConstant.QRCODE_HEALTH + "?token=" + token + "&scene=1011";
String qrcodeInfo = WebConstant.QRCODE_HEALTH + "?token=" + healthInfo.getToken() + "&scene=1011";
String path = QrCodeUtil.urlToQRCode(qrcodeInfo,WebConstant.UPLOAD_PATH_BASE_HEALTH);
String qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + path;
//5、将健康码信息存入数据库
HealthQRCode healthQRCode = new HealthQRCode();
healthQRCode.setId(snowflake.nextId());
healthQRCode.setTime(System.currentTimeMillis());
healthQRCode.setHealthRecordsId(healthRecords.getId());
healthQRCode.setHealthTypeId(healthInfo.getHealthTypeId());
healthQRCode.setQrcodePath(qrcodePath);
healthQRCode.setTime(System.currentTimeMillis());
healthQRCodeDao.insertSelective(healthQRCode);
//6、查询健康信息和健康码地址返回前端
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo();
BeanUtil.copyProperties(healthRecords,healthInfoVo);
@ -82,10 +88,10 @@ public class HealthService implements IHealthService{
JourneyDto.SelectDate selectDate = params.getParam();
Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime();
Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime();
Long userId = params.getUserId();
String userId = tallFeignClient.getUserId(selectDate.getToken());
//2、通过userid查询出成员id
Employee employee = userService.getEmployeeByUserId(userId);
//3、查询该成员符合时间的行程记录
Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId));
//3、查询该成员符合时间的记录
List<HealthVo.HealthInfo> healthInfoList = healthRecordsDao.selectHealthInfoByDate(employee.getId(),startTime,endTime);
//4、返回
return healthInfoList;

2
health/src/main/java/com/ccsens/health/service/IHealthService.java

@ -9,7 +9,7 @@ import java.io.IOException;
import java.util.List;
public interface IHealthService {
HealthVo.HealthInfo addHealthInfo(String token,QueryDto<HealthDto.healthInfo> params) throws IOException;
HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws IOException;
List<HealthVo.HealthInfo> getHealthInfo(QueryDto<JourneyDto.SelectDate> params) throws Exception;

9
health/src/main/java/com/ccsens/health/service/JourneyService.java

@ -3,6 +3,7 @@ package com.ccsens.health.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.po.Employee;
import com.ccsens.health.bean.po.EmployeeExample;
@ -32,6 +33,8 @@ public class JourneyService implements IJourneyService{
private EmployeeDao employeeDao;
@Autowired
private JourneyDao journeyDao;
@Autowired
private TallFeignClient tallFeignClient;
/**
* 上报行程
@ -65,13 +68,13 @@ public class JourneyService implements IJourneyService{
*/
@Override
public List<JourneyVo.JourneyInfo> getJourney(QueryDto<JourneyDto.SelectDate> params) throws Exception {
//1、获取查询时间和userId
//1、获取查询时间和被查询成员的userId
JourneyDto.SelectDate selectDate = params.getParam();
Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime();
Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime();
Long userId = params.getUserId();
String userId = tallFeignClient.getUserId(selectDate.getToken());
//2、通过userid查询出成员id
Employee employee = userService.getEmployeeByUserId(userId);
Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId));
//3、查询该成员符合时间的行程记录
List<JourneyVo.JourneyInfo> journeyList = journeyDao.selectJourneyByDate(employee.getId(),startTime,endTime);
//4、返回

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

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

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

@ -9,7 +9,7 @@
<result column="hAddress" property="address"/>
<result column="hHealthTypeId" property="healthTypeId"/>
<result column="hHospital" property="hospital"/>
<result column="hTouchHuBei" property="touchHuBei"/>
<result column="hTouchHuBei" property="touchHubei"/>
<result column="hTouchSick" property="touchSick"/>
<result column="hAnimalHeat" property="animalHeat"/>
<result column="hHealthCode" property="healthCode"/>
@ -18,7 +18,7 @@
<select id="selectHealthInfoByDate" resultMap="resultMap_HealthInfo" parameterType="java.util.Map">
select
h.id as hId,
h.emplotee_id as hEmployeeId,
h.employee_id as hEmployeeId,
h.time as hTime,
h.district as hDistrict,
h.address as hAddress,

30
health/src/main/resources/mapper_raw/HealthRecordsMapper.xml

@ -7,7 +7,7 @@
<result column="time" jdbcType="BIGINT" property="time" />
<result column="district" jdbcType="VARCHAR" property="district" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="health_status" jdbcType="VARCHAR" property="healthStatus" />
<result column="health_type_id" jdbcType="BIGINT" property="healthTypeId" />
<result column="hospital" jdbcType="VARCHAR" property="hospital" />
<result column="touch_hubei" jdbcType="TINYINT" property="touchHubei" />
<result column="touch_sick" jdbcType="TINYINT" property="touchSick" />
@ -76,8 +76,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, employee_id, time, district, address, health_status, hospital, touch_hubei, touch_sick,
animal_heat, self_fill, created_at, updated_at, rec_status
id, employee_id, time, district, address, health_type_id, hospital, touch_hubei,
touch_sick, animal_heat, self_fill, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.health.bean.po.HealthRecordsExample" resultMap="BaseResultMap">
select
@ -111,12 +111,12 @@
</delete>
<insert id="insert" parameterType="com.ccsens.health.bean.po.HealthRecords">
insert into t_health_records (id, employee_id, time,
district, address, health_status,
district, address, health_type_id,
hospital, touch_hubei, touch_sick,
animal_heat, self_fill, created_at,
updated_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{employeeId,jdbcType=BIGINT}, #{time,jdbcType=BIGINT},
#{district,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{healthStatus,jdbcType=VARCHAR},
#{district,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{healthTypeId,jdbcType=BIGINT},
#{hospital,jdbcType=VARCHAR}, #{touchHubei,jdbcType=TINYINT}, #{touchSick,jdbcType=TINYINT},
#{animalHeat,jdbcType=DECIMAL}, #{selfFill,jdbcType=TINYINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
@ -139,8 +139,8 @@
<if test="address != null">
address,
</if>
<if test="healthStatus != null">
health_status,
<if test="healthTypeId != null">
health_type_id,
</if>
<if test="hospital != null">
hospital,
@ -183,8 +183,8 @@
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="healthStatus != null">
#{healthStatus,jdbcType=VARCHAR},
<if test="healthTypeId != null">
#{healthTypeId,jdbcType=BIGINT},
</if>
<if test="hospital != null">
#{hospital,jdbcType=VARCHAR},
@ -236,8 +236,8 @@
<if test="record.address != null">
address = #{record.address,jdbcType=VARCHAR},
</if>
<if test="record.healthStatus != null">
health_status = #{record.healthStatus,jdbcType=VARCHAR},
<if test="record.healthTypeId != null">
health_type_id = #{record.healthTypeId,jdbcType=BIGINT},
</if>
<if test="record.hospital != null">
hospital = #{record.hospital,jdbcType=VARCHAR},
@ -275,7 +275,7 @@
time = #{record.time,jdbcType=BIGINT},
district = #{record.district,jdbcType=VARCHAR},
address = #{record.address,jdbcType=VARCHAR},
health_status = #{record.healthStatus,jdbcType=VARCHAR},
health_type_id = #{record.healthTypeId,jdbcType=BIGINT},
hospital = #{record.hospital,jdbcType=VARCHAR},
touch_hubei = #{record.touchHubei,jdbcType=TINYINT},
touch_sick = #{record.touchSick,jdbcType=TINYINT},
@ -303,8 +303,8 @@
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="healthStatus != null">
health_status = #{healthStatus,jdbcType=VARCHAR},
<if test="healthTypeId != null">
health_type_id = #{healthTypeId,jdbcType=BIGINT},
</if>
<if test="hospital != null">
hospital = #{hospital,jdbcType=VARCHAR},
@ -339,7 +339,7 @@
time = #{time,jdbcType=BIGINT},
district = #{district,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
health_status = #{healthStatus,jdbcType=VARCHAR},
health_type_id = #{healthTypeId,jdbcType=BIGINT},
hospital = #{hospital,jdbcType=VARCHAR},
touch_hubei = #{touchHubei,jdbcType=TINYINT},
touch_sick = #{touchSick,jdbcType=TINYINT},

Loading…
Cancel
Save