|
|
@ -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); |
|
|
|