From 98a40e47a76c97e5354209b0e53248b99a3c12c5 Mon Sep 17 00:00:00 2001 From: zhangye <654600784@qq.com> Date: Wed, 1 Apr 2020 10:30:09 +0800 Subject: [PATCH] 0401.1 --- .../health/persist/dao/HealthAbnormalDao.java | 5 ++ .../health/service/AbnormalService.java | 79 ++++++++++++++----- .../ccsens/health/service/HealthService.java | 35 +++++--- .../health/service/IAbnormalService.java | 2 +- health/src/main/resources/application.yml | 4 +- .../mapper_dao/HealthAbnormalDao.xml | 29 +++++++ 6 files changed, 120 insertions(+), 34 deletions(-) diff --git a/health/src/main/java/com/ccsens/health/persist/dao/HealthAbnormalDao.java b/health/src/main/java/com/ccsens/health/persist/dao/HealthAbnormalDao.java index c7cb0e24..f46433a7 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/HealthAbnormalDao.java +++ b/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 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); } diff --git a/health/src/main/java/com/ccsens/health/service/AbnormalService.java b/health/src/main/java/com/ccsens/health/service/AbnormalService.java index 7333f2bf..c59f18ab 100644 --- a/health/src/main/java/com/ccsens/health/service/AbnormalService.java +++ b/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 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 params) { + public AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto 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 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 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 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 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); diff --git a/health/src/main/java/com/ccsens/health/service/HealthService.java b/health/src/main/java/com/ccsens/health/service/HealthService.java index 7e0cf9d8..a15a1b35 100644 --- a/health/src/main/java/com/ccsens/health/service/HealthService.java +++ b/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 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"; diff --git a/health/src/main/java/com/ccsens/health/service/IAbnormalService.java b/health/src/main/java/com/ccsens/health/service/IAbnormalService.java index 8ac9b932..ec45abd5 100644 --- a/health/src/main/java/com/ccsens/health/service/IAbnormalService.java +++ b/health/src/main/java/com/ccsens/health/service/IAbnormalService.java @@ -9,7 +9,7 @@ import java.util.List; public interface IAbnormalService { List abnormalOverview(QueryDto params) throws Exception; - AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto params); + AbnormalVo.AbnormalStatisticsVo addAbnormal(QueryDto params) throws Exception; List abnormalStatistics(QueryDto params); diff --git a/health/src/main/resources/application.yml b/health/src/main/resources/application.yml index 2fb38e57..c3b11fb6 100644 --- a/health/src/main/resources/application.yml +++ b/health/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: dev - include: common, util-dev + active: test + include: common, util-test diff --git a/health/src/main/resources/mapper_dao/HealthAbnormalDao.xml b/health/src/main/resources/mapper_dao/HealthAbnormalDao.xml index 63be32d7..4d60b6b4 100644 --- a/health/src/main/resources/mapper_dao/HealthAbnormalDao.xml +++ b/health/src/main/resources/mapper_dao/HealthAbnormalDao.xml @@ -112,4 +112,33 @@ j.end_time >= #{startTime} + + + + \ No newline at end of file