|
|
@ -19,6 +19,7 @@ import com.ccsens.util.QrCodeUtil; |
|
|
|
import com.ccsens.util.WebConstant; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.ccsens.util.wx.WxXcxUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@ -48,7 +49,8 @@ public class HealthService implements IHealthService{ |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws IOException { |
|
|
|
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws Exception { |
|
|
|
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo(); |
|
|
|
//1、获取健康信息和userId
|
|
|
|
HealthDto.healthInfo healthInfo = params.getParam(); |
|
|
|
Long userId = params.getUserId(); |
|
|
@ -59,10 +61,33 @@ public class HealthService implements IHealthService{ |
|
|
|
healthRecords.setUserId(userId); |
|
|
|
BeanUtil.copyProperties(healthInfo,healthRecords); |
|
|
|
healthRecordsDao.insertSelective(healthRecords); |
|
|
|
|
|
|
|
//健康码颜色(默认绿色)
|
|
|
|
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor(); |
|
|
|
color.r = "134"; |
|
|
|
color.g = "219"; |
|
|
|
color.b = "71"; |
|
|
|
healthInfoVo.setHealthLevel(0); |
|
|
|
//获取健康状态
|
|
|
|
HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId()); |
|
|
|
if(ObjectUtil.isNotNull(healthType)){ |
|
|
|
//如果健康状态异常,健康码为橙色
|
|
|
|
if(healthType.getQuarantine() != 0){ |
|
|
|
color.r = "243"; |
|
|
|
color.g = "139"; |
|
|
|
color.b = "0"; |
|
|
|
healthInfoVo.setHealthLevel(0); |
|
|
|
} |
|
|
|
healthInfoVo.setHealthTypeName(healthType.getName()); |
|
|
|
} |
|
|
|
//TODO 4、生成健康码,返回地址
|
|
|
|
String qrcodeInfo = WebConstant.QRCODE_HEALTH + "?token=" + healthInfo.getToken() + "&scene=1011"; |
|
|
|
String path = QrCodeUtil.urlToQRCode(qrcodeInfo,WebConstant.UPLOAD_PATH_BASE); |
|
|
|
String qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + path; |
|
|
|
|
|
|
|
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 = WebConstant.TEST_URL_BASE_HEALTH + fileName; |
|
|
|
|
|
|
|
//5、将健康码信息存入数据库
|
|
|
|
HealthQRCode healthQRCode = new HealthQRCode(); |
|
|
|
healthQRCode.setId(snowflake.nextId()); |
|
|
@ -72,7 +97,6 @@ public class HealthService implements IHealthService{ |
|
|
|
healthQRCode.setTime(System.currentTimeMillis()); |
|
|
|
healthQRCodeDao.insertSelective(healthQRCode); |
|
|
|
//6、查询健康信息和健康码地址返回前端
|
|
|
|
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo(); |
|
|
|
BeanUtil.copyProperties(healthRecords,healthInfoVo); |
|
|
|
healthInfoVo.setUserId(userId); |
|
|
|
healthInfoVo.setHealthCode(qrcodePath); |
|
|
|