|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
import com.ccsens.health.bean.dto.HealthDto; |
|
|
import com.ccsens.health.bean.dto.HealthDto; |
|
|
import com.ccsens.health.bean.dto.JourneyDto; |
|
|
import com.ccsens.health.bean.dto.JourneyDto; |
|
@ -14,6 +15,7 @@ import com.ccsens.health.persist.dao.HealthQRCodeDao; |
|
|
import com.ccsens.health.persist.dao.HealthRecordsDao; |
|
|
import com.ccsens.health.persist.dao.HealthRecordsDao; |
|
|
import com.ccsens.health.persist.dao.HealthRemarkFileDao; |
|
|
import com.ccsens.health.persist.dao.HealthRemarkFileDao; |
|
|
import com.ccsens.health.persist.dao.HealthTypeDao; |
|
|
import com.ccsens.health.persist.dao.HealthTypeDao; |
|
|
|
|
|
import com.ccsens.health.util.HealthConstant; |
|
|
import com.ccsens.util.*; |
|
|
import com.ccsens.util.*; |
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
@ -24,6 +26,7 @@ import com.github.pagehelper.PageInfo; |
|
|
import io.micrometer.shaded.org.pcollections.PCollection; |
|
|
import io.micrometer.shaded.org.pcollections.PCollection; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
@ -33,6 +36,8 @@ import java.io.File; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
@ -48,6 +53,33 @@ public class HealthService implements IHealthService{ |
|
|
private HealthQRCodeDao healthQRCodeDao; |
|
|
private HealthQRCodeDao healthQRCodeDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private HealthRemarkFileDao healthRemarkFileDao; |
|
|
private HealthRemarkFileDao healthRemarkFileDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IAsyncService asyncService; |
|
|
|
|
|
@Value("spring.profiles.active") |
|
|
|
|
|
private String active; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public HealthVo.HealthTypeRedis readHealthType(long healthTypeId) { |
|
|
|
|
|
String key = HealthConstant.getHealthTypeKey(healthTypeId); |
|
|
|
|
|
Object o = redisUtil.get(key); |
|
|
|
|
|
log.info("redis读取健康状态类型:{},{}", healthTypeId, o); |
|
|
|
|
|
if (o!=null && StrUtil.isNotEmpty((String)o)) { |
|
|
|
|
|
return JSONObject.parseObject((String)o, HealthVo.HealthTypeRedis.class); |
|
|
|
|
|
} |
|
|
|
|
|
HealthType healthType = healthTypeDao.selectByPrimaryKey(healthTypeId); |
|
|
|
|
|
log.info("数据库查询健康状态:{},{}", healthTypeId, healthType); |
|
|
|
|
|
if (healthType == null) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
HealthVo.HealthTypeRedis redis = new HealthVo.HealthTypeRedis(); |
|
|
|
|
|
redis.setName(healthType.getName()); |
|
|
|
|
|
redis.setIndependent(healthType.getIndependent()); |
|
|
|
|
|
redis.setQuarantine(healthType.getQuarantine()); |
|
|
|
|
|
redisUtil.set(key, JSONObject.toJSONString(redis)); |
|
|
|
|
|
return redis; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 上报健康信息 |
|
|
* 上报健康信息 |
|
@ -56,11 +88,25 @@ public class HealthService implements IHealthService{ |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws Exception { |
|
|
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws Exception { |
|
|
|
|
|
log.info("保存健康码:{}", params); |
|
|
|
|
|
|
|
|
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo(); |
|
|
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo(); |
|
|
//1、获取健康信息和userId
|
|
|
//1、获取健康信息和userId
|
|
|
HealthDto.healthInfo healthInfo = params.getParam(); |
|
|
HealthDto.healthInfo healthInfo = params.getParam(); |
|
|
Long userId = params.getUserId(); |
|
|
Long userId = params.getUserId(); |
|
|
|
|
|
|
|
|
|
|
|
HealthVo.HealthTypeRedis healthType = readHealthType(healthInfo.getHealthTypeId()); |
|
|
|
|
|
//健康码颜色(默认绿色)
|
|
|
|
|
|
Future<String> future = null; |
|
|
|
|
|
if ("prod".equals(active)) { |
|
|
|
|
|
WxXcxUtil.LineColor color = getLineColor(healthType); |
|
|
|
|
|
future = asyncService.generateQRCode("d=" + userId, color); |
|
|
|
|
|
log.info("调用微信生成二维码"); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.info("测试环境,不调用生成二维码"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3、保存健康信息
|
|
|
//3、保存健康信息
|
|
|
HealthRecords healthRecords = new HealthRecords(); |
|
|
HealthRecords healthRecords = new HealthRecords(); |
|
|
healthRecords.setId(snowflake.nextId()); |
|
|
healthRecords.setId(snowflake.nextId()); |
|
@ -69,20 +115,12 @@ public class HealthService implements IHealthService{ |
|
|
BeanUtil.copyProperties(healthInfo,healthRecords); |
|
|
BeanUtil.copyProperties(healthInfo,healthRecords); |
|
|
healthRecordsDao.insertSelective(healthRecords); |
|
|
healthRecordsDao.insertSelective(healthRecords); |
|
|
|
|
|
|
|
|
//健康码颜色(默认绿色)
|
|
|
|
|
|
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor(); |
|
|
|
|
|
color.r = "134"; |
|
|
|
|
|
color.g = "219"; |
|
|
|
|
|
color.b = "71"; |
|
|
|
|
|
healthInfoVo.setHealthLevel(0); |
|
|
healthInfoVo.setHealthLevel(0); |
|
|
//获取健康状态
|
|
|
//获取健康状态
|
|
|
HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId()); |
|
|
// HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId());
|
|
|
if(ObjectUtil.isNotNull(healthType)){ |
|
|
if(ObjectUtil.isNotNull(healthType)){ |
|
|
//如果健康状态异常,健康码为橙色
|
|
|
//如果健康状态异常,健康码为橙色
|
|
|
if(healthType.getQuarantine() != 0){ |
|
|
if(healthType.getQuarantine() != 0){ |
|
|
color.r = "243"; |
|
|
|
|
|
color.g = "139"; |
|
|
|
|
|
color.b = "0"; |
|
|
|
|
|
healthInfoVo.setHealthLevel(1); |
|
|
healthInfoVo.setHealthLevel(1); |
|
|
}else { |
|
|
}else { |
|
|
//如果选择状态正常,检查温度是否正常(36.0°~37.3°)
|
|
|
//如果选择状态正常,检查温度是否正常(36.0°~37.3°)
|
|
@ -96,21 +134,13 @@ public class HealthService implements IHealthService{ |
|
|
healthInfoVo.setHealthTypeName(healthType.getName()); |
|
|
healthInfoVo.setHealthTypeName(healthType.getName()); |
|
|
} |
|
|
} |
|
|
//TODO 4、生成健康码,返回地址
|
|
|
//TODO 4、生成健康码,返回地址
|
|
|
|
|
|
// String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
|
|
|
|
|
|
// String path = WebConstant.UPLOAD_PATH_BASE+fileName;
|
|
|
|
|
|
// WxXcxUtil.getWxCode(WebConstant.QRCODE_HEALTH
|
|
|
|
|
|
// ,"d="+userId,color,path);
|
|
|
|
|
|
// String qrcodePath = PropUtil.qrCode + fileName;
|
|
|
|
|
|
|
|
|
String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; |
|
|
|
|
|
String path = WebConstant.UPLOAD_PATH_BASE+fileName; |
|
|
|
|
|
WxXcxUtil.getWxCode(WebConstant.QRCODE_HEALTH |
|
|
|
|
|
,"d="+userId,color,path); |
|
|
|
|
|
String qrcodePath = PropUtil.qrCode + fileName; |
|
|
|
|
|
|
|
|
|
|
|
//5、将健康码信息存入数据库
|
|
|
|
|
|
HealthQRCode healthQRCode = new HealthQRCode(); |
|
|
|
|
|
healthQRCode.setId(snowflake.nextId()); |
|
|
|
|
|
healthQRCode.setHealthRecordsId(healthRecords.getId()); |
|
|
|
|
|
healthQRCode.setHealthTypeId(healthInfo.getHealthTypeId()); |
|
|
|
|
|
healthQRCode.setQrcodePath(qrcodePath); |
|
|
|
|
|
healthQRCode.setTime(System.currentTimeMillis()); |
|
|
|
|
|
healthQRCodeDao.insertSelective(healthQRCode); |
|
|
|
|
|
|
|
|
|
|
|
//关联备注文件信息
|
|
|
//关联备注文件信息
|
|
|
List<HealthVo.HealthRemarkFileInfo> healthRemarkFileInfoList = new ArrayList<>(); |
|
|
List<HealthVo.HealthRemarkFileInfo> healthRemarkFileInfoList = new ArrayList<>(); |
|
@ -131,6 +161,20 @@ public class HealthService implements IHealthService{ |
|
|
healthRemarkFileInfoList.add(fileInfo); |
|
|
healthRemarkFileInfoList.add(fileInfo); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String qrcodePath = "https://test.tall.wiki/gateway/health/uploads//qrCode/2020-03-27/1585298741978.png"; |
|
|
|
|
|
if (future != null) { |
|
|
|
|
|
qrcodePath = future.get(); |
|
|
|
|
|
} |
|
|
|
|
|
log.info("二维码路径:{}", qrcodePath); |
|
|
|
|
|
//5、将健康码信息存入数据库
|
|
|
|
|
|
HealthQRCode healthQRCode = new HealthQRCode(); |
|
|
|
|
|
healthQRCode.setId(snowflake.nextId()); |
|
|
|
|
|
healthQRCode.setHealthRecordsId(healthRecords.getId()); |
|
|
|
|
|
healthQRCode.setHealthTypeId(healthInfo.getHealthTypeId()); |
|
|
|
|
|
healthQRCode.setQrcodePath(qrcodePath); |
|
|
|
|
|
healthQRCode.setTime(System.currentTimeMillis()); |
|
|
|
|
|
healthQRCodeDao.insertSelective(healthQRCode); |
|
|
//6、查询健康信息和健康码地址返回前端
|
|
|
//6、查询健康信息和健康码地址返回前端
|
|
|
BeanUtil.copyProperties(healthRecords,healthInfoVo); |
|
|
BeanUtil.copyProperties(healthRecords,healthInfoVo); |
|
|
healthInfoVo.setUserId(userId); |
|
|
healthInfoVo.setUserId(userId); |
|
@ -139,6 +183,20 @@ public class HealthService implements IHealthService{ |
|
|
return healthInfoVo; |
|
|
return healthInfoVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WxXcxUtil.LineColor getLineColor(HealthVo.HealthTypeRedis healthType) { |
|
|
|
|
|
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor(); |
|
|
|
|
|
if(healthType.getQuarantine() != 0) { |
|
|
|
|
|
color.r = "243"; |
|
|
|
|
|
color.g = "139"; |
|
|
|
|
|
color.b = "0"; |
|
|
|
|
|
} else { |
|
|
|
|
|
color.r = "134"; |
|
|
|
|
|
color.g = "219"; |
|
|
|
|
|
color.b = "71"; |
|
|
|
|
|
} |
|
|
|
|
|
return color; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取个人健康信息 |
|
|
* 获取个人健康信息 |
|
|
* @param params |
|
|
* @param params |
|
|