Browse Source

0401.1

master
zhangye 5 years ago
parent
commit
98a40e47a7
  1. 5
      health/src/main/java/com/ccsens/health/persist/dao/HealthAbnormalDao.java
  2. 79
      health/src/main/java/com/ccsens/health/service/AbnormalService.java
  3. 35
      health/src/main/java/com/ccsens/health/service/HealthService.java
  4. 2
      health/src/main/java/com/ccsens/health/service/IAbnormalService.java
  5. 4
      health/src/main/resources/application.yml
  6. 29
      health/src/main/resources/mapper_dao/HealthAbnormalDao.xml

5
health/src/main/java/com/ccsens/health/persist/dao/HealthAbnormalDao.java

@ -1,6 +1,7 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.bean.po.HealthAbnormal;
import com.ccsens.health.bean.po.HealthRecords;
import com.ccsens.health.bean.vo.AbnormalVo;
import com.ccsens.health.persist.mapper.HealthAbnormalMapper;
import org.apache.ibatis.annotations.Param;
@ -16,4 +17,8 @@ public interface HealthAbnormalDao extends HealthAbnormalMapper {
List<AbnormalVo.AbnormalOverview> abnormalOverview(@Param("department")String department, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
int selectJourneyNumber(@Param("department")String department, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
HealthAbnormal selectByUserId(@Param("userId")Long userId);
HealthRecords selectHealthRecordByWkno(@Param("wkno")String wkno);
}

79
health/src/main/java/com/ccsens/health/service/AbnormalService.java

@ -7,32 +7,46 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.health.bean.dto.AbnormalDto;
import com.ccsens.health.bean.po.HealthAbnormal;
import com.ccsens.health.bean.po.HealthQRCode;
import com.ccsens.health.bean.po.HealthQRCodeExample;
import com.ccsens.health.bean.po.HealthRecords;
import com.ccsens.health.bean.vo.AbnormalVo;
import com.ccsens.health.persist.dao.HealthAbnormalDao;
import com.ccsens.health.persist.dao.HealthQRCodeDao;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.wx.WxXcxUtil;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class AbnormalService implements IAbnormalService{
public class AbnormalService implements IAbnormalService {
@Autowired
private Snowflake snowflake;
@Autowired
private HealthAbnormalDao healthAbnormalDao;
@Autowired
private HealthQRCodeDao healthQRCodeDao;
@Autowired
private IAsyncService asyncService;
@Value("spring.profiles.active")
private String active;
/**
* 疫情概览
*
* @param params
* @return
*/
@ -42,14 +56,14 @@ public class AbnormalService implements IAbnormalService{
List<AbnormalVo.AbnormalOverview> abnormalOverviewList = new ArrayList<>();
//人员异常
abnormalOverviewList =
healthAbnormalDao.abnormalOverview(selectAbnormal.getDepartment(),selectAbnormal.getStartTime(),selectAbnormal.getEndTime());
if(CollectionUtil.isNotEmpty(abnormalOverviewList)){
for(AbnormalVo.AbnormalOverview abnormalOverview : abnormalOverviewList){
healthAbnormalDao.abnormalOverview(selectAbnormal.getDepartment(), selectAbnormal.getStartTime(), selectAbnormal.getEndTime());
if (CollectionUtil.isNotEmpty(abnormalOverviewList)) {
for (AbnormalVo.AbnormalOverview abnormalOverview : abnormalOverviewList) {
abnormalOverview.setAbnormalType(1);
}
}
//行程异常
int journeyNumber = healthAbnormalDao.selectJourneyNumber(selectAbnormal.getDepartment(),selectAbnormal.getStartTime(),selectAbnormal.getEndTime());
int journeyNumber = healthAbnormalDao.selectJourneyNumber(selectAbnormal.getDepartment(), selectAbnormal.getStartTime(), selectAbnormal.getEndTime());
AbnormalVo.AbnormalOverview abnormalOverview = new AbnormalVo.AbnormalOverview();
abnormalOverview.setAbnormalType(2);
abnormalOverview.setCode(5);
@ -64,16 +78,43 @@ public class AbnormalService implements IAbnormalService{
* @param params
*/
@Override
public AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto<AbnormalDto.AddAbnormal> params) {
public AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto<AbnormalDto.AddAbnormal> params) throws Exception {
AbnormalDto.AddAbnormal addAbnormal = params.getParam();
HealthAbnormal healthAbnormal = new HealthAbnormal();
healthAbnormal.setId(snowflake.nextId());
BeanUtil.copyProperties(addAbnormal,healthAbnormal);
BeanUtil.copyProperties(addAbnormal, healthAbnormal);
healthAbnormal.setHealthStatus((short) addAbnormal.getHealthType());
healthAbnormalDao.insertSelective(healthAbnormal);
//如果是确诊状态,检查该学生最新上报的健康信息,将二维码换成红色
Future<String> future = null;
if (addAbnormal.getHealthType() == 4) {
HealthRecords healthRecords = healthAbnormalDao.selectHealthRecordByWkno(addAbnormal.getWkno());
if (ObjectUtil.isNotNull(healthAbnormal)) {
if ("prod".equals(active)) {
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor();
color.r = "226";
color.g = "32";
color.b = "24";
future = asyncService.generateQRCode("d=" + healthRecords.getUserId(), color);
log.info("调用微信生成二维码");
HealthQRCodeExample healthQRCodeExample = new HealthQRCodeExample();
healthQRCodeExample.createCriteria().andHealthRecordsIdEqualTo(healthRecords.getId());
List<HealthQRCode> healthQRCodeList = healthQRCodeDao.selectByExample(healthQRCodeExample);
if(CollectionUtil.isNotEmpty(healthQRCodeList)){
HealthQRCode healthQRCode = healthQRCodeList.get(0);
if(future != null){
healthQRCode.setQrcodePath(future.get());
healthQRCodeDao.updateByPrimaryKeySelective(healthQRCode);
}
}
} else {
log.info("测试环境,不调用生成二维码");
}
}
}
AbnormalVo.AbnormalStatisticsVo abnormalStatisticsVo = new AbnormalVo.AbnormalStatisticsVo();
BeanUtil.copyProperties(healthAbnormal,abnormalStatisticsVo);
BeanUtil.copyProperties(healthAbnormal, abnormalStatisticsVo);
abnormalStatisticsVo.setHealthType(healthAbnormal.getHealthStatus());
return abnormalStatisticsVo;
}
@ -94,38 +135,39 @@ public class AbnormalService implements IAbnormalService{
/**
* 修改异常人员信息
*
* @param params
*/
@Override
public void updateAbnormal(QueryDto<AbnormalDto.UpdateAbnormal> params) {
AbnormalDto.UpdateAbnormal updateAbnormal = params.getParam();
HealthAbnormal healthAbnormal = healthAbnormalDao.selectByPrimaryKey(updateAbnormal.getId());
if(ObjectUtil.isNull(healthAbnormal)){
if (ObjectUtil.isNull(healthAbnormal)) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
//修改信息
if(StrUtil.isNotEmpty(updateAbnormal.getWkno())){
if (StrUtil.isNotEmpty(updateAbnormal.getWkno())) {
healthAbnormal.setWkno(updateAbnormal.getWkno());
}
if(StrUtil.isNotEmpty(updateAbnormal.getName())){
if (StrUtil.isNotEmpty(updateAbnormal.getName())) {
healthAbnormal.setName(updateAbnormal.getName());
}
if(StrUtil.isNotEmpty(updateAbnormal.getDepartment())){
if (StrUtil.isNotEmpty(updateAbnormal.getDepartment())) {
healthAbnormal.setDepartment(updateAbnormal.getDepartment());
}
if(ObjectUtil.isNotNull(updateAbnormal.getAnimalHeat())){
if (ObjectUtil.isNotNull(updateAbnormal.getAnimalHeat())) {
healthAbnormal.setAnimalHeat(updateAbnormal.getAnimalHeat());
}
if(StrUtil.isNotEmpty(updateAbnormal.getReason())){
if (StrUtil.isNotEmpty(updateAbnormal.getReason())) {
healthAbnormal.setReason(updateAbnormal.getReason());
}
if(ObjectUtil.isNotNull(updateAbnormal.getHealthType())){
if (ObjectUtil.isNotNull(updateAbnormal.getHealthType())) {
healthAbnormal.setHealthStatus((short) updateAbnormal.getHealthType());
}
if(ObjectUtil.isNotNull(updateAbnormal.getStartTime())){
if (ObjectUtil.isNotNull(updateAbnormal.getStartTime())) {
healthAbnormal.setStartTime(updateAbnormal.getStartTime());
}
if(ObjectUtil.isNotNull(updateAbnormal.getEndTime())){
if (ObjectUtil.isNotNull(updateAbnormal.getEndTime())) {
healthAbnormal.setEndTime(updateAbnormal.getEndTime());
}
healthAbnormalDao.updateByPrimaryKeySelective(healthAbnormal);
@ -133,12 +175,13 @@ public class AbnormalService implements IAbnormalService{
/**
* 删除异常人员信息
*
* @param params
*/
@Override
public void delAbnormal(QueryDto<AbnormalDto.DelAbnormal> params) {
HealthAbnormal healthAbnormal = healthAbnormalDao.selectByPrimaryKey(params.getParam().getId());
if(ObjectUtil.isNull(healthAbnormal)){
if (ObjectUtil.isNull(healthAbnormal)) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
healthAbnormal.setRecStatus((byte) 2);

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

@ -11,10 +11,7 @@ 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.HealthRemarkFileDao;
import com.ccsens.health.persist.dao.HealthTypeDao;
import com.ccsens.health.persist.dao.*;
import com.ccsens.health.util.HealthConstant;
import com.ccsens.util.*;
import com.ccsens.util.bean.dto.QueryDto;
@ -54,6 +51,8 @@ public class HealthService implements IHealthService {
@Autowired
private HealthRemarkFileDao healthRemarkFileDao;
@Autowired
private HealthAbnormalDao healthAbnormalDao;
@Autowired
private RedisUtil redisUtil;
@Autowired
private IAsyncService asyncService;
@ -99,7 +98,10 @@ public class HealthService implements IHealthService {
//健康码颜色(默认绿色)
Future<String> future = null;
if ("prod".equals(active)) {
WxXcxUtil.LineColor color = getLineColor(healthType);
//检查上报人员是否是已确诊
Boolean flag = isAbnormal(userId);
WxXcxUtil.LineColor color = getLineColor(healthType,flag);
future = asyncService.generateQRCode("d=" + userId, color);
log.info("调用微信生成二维码");
} else {
@ -121,13 +123,6 @@ public class HealthService implements IHealthService {
if(ObjectUtil.isNotNull(healthType)){
//如果健康状态异常,健康码为橙色
if(healthType.getQuarantine() != 0){
//如果选择其他状态,检查温度是否正常(36.0°~37.3°)
BigDecimal minAnimalHeat = BigDecimal.valueOf(30.0);
BigDecimal maxAnimalHeat = BigDecimal.valueOf(45.0);
if (healthInfo.getAnimalHeat().compareTo(minAnimalHeat) == -1 ||
healthInfo.getAnimalHeat().compareTo(maxAnimalHeat) == 1) {
throw new BaseException(CodeEnum.ANIMAL_HEAT_ERROR);
}
healthInfoVo.setHealthLevel(1);
} else {
//如果选择状态正常,检查温度是否正常(36.0°~37.3°)
@ -192,8 +187,22 @@ public class HealthService implements IHealthService {
return healthInfoVo;
}
private WxXcxUtil.LineColor getLineColor(HealthVo.HealthTypeRedis healthType) {
private Boolean isAbnormal(Long userId) {
HealthAbnormal healthAbnormal = healthAbnormalDao.selectByUserId(userId);
if(ObjectUtil.isNotNull(healthAbnormal) && healthAbnormal.getHealthStatus() == 4){
return true;
}
return false;
}
private WxXcxUtil.LineColor getLineColor(HealthVo.HealthTypeRedis healthType,Boolean flag) {
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor();
if(flag){
color.r = "226";
color.g = "32";
color.b = "24";
return color;
}
if(healthType.getQuarantine() != 0) {
color.r = "243";
color.g = "139";

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

@ -9,7 +9,7 @@ import java.util.List;
public interface IAbnormalService {
List<AbnormalVo.AbnormalOverview> abnormalOverview(QueryDto<AbnormalDto.SelectAbnormal> params) throws Exception;
AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto<AbnormalDto.AddAbnormal> params);
AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto<AbnormalDto.AddAbnormal> params) throws Exception;
List<AbnormalVo.AbnormalStatisticsVo> abnormalStatistics(QueryDto<AbnormalDto.AbnormalStatisticsDto> params);

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

29
health/src/main/resources/mapper_dao/HealthAbnormalDao.xml

@ -112,4 +112,33 @@
j.end_time &gt;= #{startTime}
</if>
</select>
<select id="selectByUserId" resultType="com.ccsens.health.bean.po.HealthAbnormal" parameterType="java.util.Map">
select
a.id as id,
a.wkno as wkno,
a.health_status as healthStatus
from
t_health_abnormal a join t_real_name_auth r on a.wkno = r.no
where
a.rec_status = 0
and
r.user_id = #{userId}
order by a.created_at DESC
limit 1
</select>
<select id="selectHealthRecordByWkno" resultType="com.ccsens.health.bean.po.HealthRecords" parameterType="java.util.Map">
select
hr.id as id,
hr.user_id as userId
from
t_real_name_auth r join t_health_records hr on hr.user_id = r.user_id
where
hr.rec_status = 0
and
r.no = #{wkno}
order by hr.time DESC
limit 1
</select>
</mapper>
Loading…
Cancel
Save