|
|
@ -41,7 +41,7 @@ import java.util.concurrent.Future; |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class HealthService implements IHealthService{ |
|
|
|
public class HealthService implements IHealthService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private Snowflake snowflake; |
|
|
@ -83,13 +83,13 @@ public class HealthService implements IHealthService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 上报健康信息 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws Exception { |
|
|
|
log.info("保存健康码:{}", params); |
|
|
|
|
|
|
|
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo(); |
|
|
|
//1、获取健康信息和userId
|
|
|
|
HealthDto.healthInfo healthInfo = params.getParam(); |
|
|
@ -112,7 +112,7 @@ public class HealthService implements IHealthService{ |
|
|
|
healthRecords.setId(snowflake.nextId()); |
|
|
|
healthRecords.setTime(System.currentTimeMillis()); |
|
|
|
healthRecords.setUserId(userId); |
|
|
|
BeanUtil.copyProperties(healthInfo,healthRecords); |
|
|
|
BeanUtil.copyProperties(healthInfo, healthRecords); |
|
|
|
healthRecordsDao.insertSelective(healthRecords); |
|
|
|
|
|
|
|
healthInfoVo.setHealthLevel(0); |
|
|
@ -122,17 +122,18 @@ public class HealthService implements IHealthService{ |
|
|
|
//如果健康状态异常,健康码为橙色
|
|
|
|
if(healthType.getQuarantine() != 0){ |
|
|
|
healthInfoVo.setHealthLevel(1); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
//如果选择状态正常,检查温度是否正常(36.0°~37.3°)
|
|
|
|
BigDecimal minAnimalHeat = BigDecimal.valueOf(36.0); |
|
|
|
BigDecimal maxAnimalHeat = BigDecimal.valueOf(37.3); |
|
|
|
if(healthInfo.getAnimalHeat().compareTo(minAnimalHeat) == -1 || |
|
|
|
healthInfo.getAnimalHeat().compareTo(maxAnimalHeat) == 1){ |
|
|
|
if (healthInfo.getAnimalHeat().compareTo(minAnimalHeat) == -1 || |
|
|
|
healthInfo.getAnimalHeat().compareTo(maxAnimalHeat) == 1) { |
|
|
|
throw new BaseException(CodeEnum.ANIMAL_HEAT_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
healthInfoVo.setHealthTypeName(healthType.getName()); |
|
|
|
} |
|
|
|
Long aa2 = System.currentTimeMillis(); |
|
|
|
//TODO 4、生成健康码,返回地址
|
|
|
|
// String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
|
|
|
|
// String path = WebConstant.UPLOAD_PATH_BASE+fileName;
|
|
|
@ -140,25 +141,24 @@ public class HealthService implements IHealthService{ |
|
|
|
// ,"d="+userId,color,path);
|
|
|
|
// String qrcodePath = PropUtil.qrCode + fileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//关联备注文件信息
|
|
|
|
List<HealthVo.HealthRemarkFileInfo> healthRemarkFileInfoList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(healthInfo.getFileIdList())){ |
|
|
|
for(Long fileId : healthInfo.getFileIdList()){ |
|
|
|
List<String> filePath = new ArrayList<>(); |
|
|
|
if (CollectionUtil.isNotEmpty(healthInfo.getFileIdList())) { |
|
|
|
for (Long fileId : healthInfo.getFileIdList()) { |
|
|
|
HealthRemarkFile healthRemarkFile = healthRemarkFileDao.selectByPrimaryKey(fileId); |
|
|
|
if(ObjectUtil.isNull(healthRemarkFile)){ |
|
|
|
if (ObjectUtil.isNull(healthRemarkFile)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_DELIVER_FILE); |
|
|
|
} |
|
|
|
healthRemarkFile.setHealthRecordsId(healthRecords.getId()); |
|
|
|
healthRemarkFileDao.updateByPrimaryKeySelective(healthRemarkFile); |
|
|
|
//添加至返回信息
|
|
|
|
HealthVo.HealthRemarkFileInfo fileInfo = new HealthVo.HealthRemarkFileInfo(); |
|
|
|
fileInfo.setFileId(healthRemarkFile.getId()); |
|
|
|
fileInfo.setFileName(healthRemarkFile.getName()); |
|
|
|
fileInfo.setFilePath(healthRemarkFile.getPath()); |
|
|
|
fileInfo.setTime(healthRemarkFile.getTime()); |
|
|
|
healthRemarkFileInfoList.add(fileInfo); |
|
|
|
filePath.add(healthRemarkFile.getPath()); |
|
|
|
// HealthVo.HealthRemarkFileInfo fileInfo = new HealthVo.HealthRemarkFileInfo();
|
|
|
|
// fileInfo.setFileId(healthRemarkFile.getId());
|
|
|
|
// fileInfo.setFileName(healthRemarkFile.getName());
|
|
|
|
// fileInfo.setFilePath(healthRemarkFile.getPath());
|
|
|
|
// fileInfo.setTime(healthRemarkFile.getTime());
|
|
|
|
// healthRemarkFileInfoList.add(fileInfo);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -175,11 +175,13 @@ public class HealthService implements IHealthService{ |
|
|
|
healthQRCode.setQrcodePath(qrcodePath); |
|
|
|
healthQRCode.setTime(System.currentTimeMillis()); |
|
|
|
healthQRCodeDao.insertSelective(healthQRCode); |
|
|
|
|
|
|
|
//6、查询健康信息和健康码地址返回前端
|
|
|
|
BeanUtil.copyProperties(healthRecords,healthInfoVo); |
|
|
|
BeanUtil.copyProperties(healthRecords, healthInfoVo); |
|
|
|
healthInfoVo.setUserId(userId); |
|
|
|
healthInfoVo.setHealthCode(qrcodePath); |
|
|
|
healthInfoVo.setFileInfoList(healthRemarkFileInfoList); |
|
|
|
healthInfoVo.setFilePath(filePath); |
|
|
|
|
|
|
|
return healthInfoVo; |
|
|
|
} |
|
|
|
|
|
|
@ -199,6 +201,7 @@ public class HealthService implements IHealthService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取个人健康信息 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -209,34 +212,32 @@ public class HealthService implements IHealthService{ |
|
|
|
Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime(); |
|
|
|
Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime(); |
|
|
|
Long userId = params.getUserId(); |
|
|
|
// if(StrUtil.isEmpty(userId)){
|
|
|
|
// throw new BaseException(CodeEnum.NOT_LOGIN);
|
|
|
|
// }
|
|
|
|
// //2、通过userid查询出成员id
|
|
|
|
// Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId));
|
|
|
|
//3、查询该成员符合时间的记录
|
|
|
|
List<HealthVo.HealthInfo> healthInfoList = healthRecordsDao.selectHealthInfoByDate(userId,startTime,endTime); |
|
|
|
if(CollectionUtil.isNotEmpty(healthInfoList)){ |
|
|
|
for(HealthVo.HealthInfo healthInfo : healthInfoList){ |
|
|
|
healthInfo.setHealthLevel(0); |
|
|
|
//获取健康状态
|
|
|
|
HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId()); |
|
|
|
if(ObjectUtil.isNotNull(healthType)){ |
|
|
|
//如果健康状态异常,健康码为橙色
|
|
|
|
if(healthType.getQuarantine() != 0){ |
|
|
|
healthInfo.setHealthLevel(1); |
|
|
|
} |
|
|
|
healthInfo.setHealthTypeName(healthType.getName()); |
|
|
|
} |
|
|
|
log.info("获取个人健康打卡记录 userid:{}", userId); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//3、查询该成员符合时间的记录
|
|
|
|
List<HealthVo.HealthInfo> healthInfoList = healthRecordsDao.selectHealthInfoByDate(userId, startTime, endTime); |
|
|
|
// if(CollectionUtil.isNotEmpty(healthInfoList)){
|
|
|
|
// for(HealthVo.HealthInfo healthInfo : healthInfoList){
|
|
|
|
// healthInfo.setHealthLevel(0);
|
|
|
|
// //获取健康状态
|
|
|
|
// HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId());
|
|
|
|
// if(ObjectUtil.isNotNull(healthType)){
|
|
|
|
// //如果健康状态异常,健康码为橙色
|
|
|
|
// if(healthType.getQuarantine() != 0){
|
|
|
|
// healthInfo.setHealthLevel(1);
|
|
|
|
// }
|
|
|
|
// healthInfo.setHealthTypeName(healthType.getName());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//4、返回
|
|
|
|
return healthInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取健康类型 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
@ -246,8 +247,8 @@ public class HealthService implements IHealthService{ |
|
|
|
HealthTypeExample healthTypeExample = new HealthTypeExample(); |
|
|
|
healthTypeExample.clear(); |
|
|
|
List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(healthTypeList)){ |
|
|
|
for(HealthType healthType : healthTypeList){ |
|
|
|
if (CollectionUtil.isNotEmpty(healthTypeList)) { |
|
|
|
for (HealthType healthType : healthTypeList) { |
|
|
|
HealthVo.HealthTypeVo healthTypeVo = new HealthVo.HealthTypeVo(); |
|
|
|
healthTypeVo.setId(healthType.getId()); |
|
|
|
healthTypeVo.setName(healthType.getName()); |
|
|
@ -259,6 +260,7 @@ public class HealthService implements IHealthService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 健康状态统计 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -270,47 +272,81 @@ public class HealthService implements IHealthService{ |
|
|
|
Long startTime = statisticsDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : statisticsDate.getStartTime(); |
|
|
|
Long endTime = statisticsDate.getEndTime() == null ? System.currentTimeMillis() : statisticsDate.getEndTime(); |
|
|
|
|
|
|
|
//2、获取所有健康状态
|
|
|
|
int otherNumber = 0; |
|
|
|
HealthTypeExample healthTypeExample = new HealthTypeExample(); |
|
|
|
healthTypeExample.clear(); |
|
|
|
List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(healthTypeList)){ |
|
|
|
for(HealthType healthType : healthTypeList){ |
|
|
|
//3、若需要单独统计则单独返回,否则都归为其他类返回总数
|
|
|
|
if(healthType.getIndependent() == 1){ |
|
|
|
//查询此状态在时间内的打卡人数
|
|
|
|
int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime); |
|
|
|
|
|
|
|
List<HealthVo.HealthTypeNumber> healthTypeNumberList = healthRecordsDao.selectHealthTypeNumber(startTime, endTime); |
|
|
|
int other = 0; |
|
|
|
if(CollectionUtil.isNotEmpty(healthTypeNumberList)){ |
|
|
|
for(HealthVo.HealthTypeNumber healthTypeNumber : healthTypeNumberList){ |
|
|
|
if(healthTypeNumber.getIndependent() == 0){ |
|
|
|
other += healthTypeNumber.getNumber(); |
|
|
|
}else { |
|
|
|
HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics(); |
|
|
|
healthTypeStatistics.setName(healthType.getName()); |
|
|
|
healthTypeStatistics.setNumber(number); |
|
|
|
healthTypeStatistics.setName(healthTypeNumber.getName()); |
|
|
|
healthTypeStatistics.setNumber(healthTypeNumber.getNumber()); |
|
|
|
healthTypeStatisticsList.add(healthTypeStatistics); |
|
|
|
}else { |
|
|
|
//查询此状态在时间内的打卡人数
|
|
|
|
int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime); |
|
|
|
otherNumber += number; |
|
|
|
} |
|
|
|
} |
|
|
|
HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics(); |
|
|
|
healthTypeStatistics.setName("其他"); |
|
|
|
healthTypeStatistics.setNumber(otherNumber); |
|
|
|
healthTypeStatistics.setNumber(other); |
|
|
|
healthTypeStatisticsList.add(healthTypeStatistics); |
|
|
|
} |
|
|
|
|
|
|
|
//获取查询的天数(正常应该一天打卡一次)
|
|
|
|
Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1; |
|
|
|
//未上报的次数
|
|
|
|
HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days, startTime, endTime); |
|
|
|
|
|
|
|
//获取查询的天数(正常应该一天打卡一次)
|
|
|
|
Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1; |
|
|
|
//未上报的次数
|
|
|
|
HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days,startTime,endTime); |
|
|
|
|
|
|
|
HealthVo.HealthTypeStatistics notUploadStatistics = new HealthVo.HealthTypeStatistics(); |
|
|
|
notUploadStatistics.setName("未上报"); |
|
|
|
if(ObjectUtil.isNotNull(notUpload)){ |
|
|
|
notUploadStatistics.setNumber((int) (notUpload.getNumber() * days - notUpload.getTimes())); |
|
|
|
}else { |
|
|
|
notUploadStatistics.setNumber(0); |
|
|
|
} |
|
|
|
healthTypeStatisticsList.add(notUploadStatistics); |
|
|
|
HealthVo.HealthTypeStatistics notUploadStatistics = new HealthVo.HealthTypeStatistics(); |
|
|
|
notUploadStatistics.setName("未上报"); |
|
|
|
if (ObjectUtil.isNotNull(notUpload)) { |
|
|
|
notUploadStatistics.setNumber((int) (notUpload.getNumber() * days - notUpload.getTimes())); |
|
|
|
} else { |
|
|
|
notUploadStatistics.setNumber(0); |
|
|
|
} |
|
|
|
healthTypeStatisticsList.add(notUploadStatistics); |
|
|
|
|
|
|
|
// //2、获取所有健康状态
|
|
|
|
// int otherNumber = 0;
|
|
|
|
// HealthTypeExample healthTypeExample = new HealthTypeExample();
|
|
|
|
// healthTypeExample.clear();
|
|
|
|
// List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample);
|
|
|
|
// if(CollectionUtil.isNotEmpty(healthTypeList)){
|
|
|
|
// for(HealthType healthType : healthTypeList){
|
|
|
|
// //3、若需要单独统计则单独返回,否则都归为其他类返回总数
|
|
|
|
// if(healthType.getIndependent() == 1){
|
|
|
|
// //查询此状态在时间内的打卡人数
|
|
|
|
// int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime);
|
|
|
|
// HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics();
|
|
|
|
// healthTypeStatistics.setName(healthType.getName());
|
|
|
|
// healthTypeStatistics.setNumber(number);
|
|
|
|
// healthTypeStatisticsList.add(healthTypeStatistics);
|
|
|
|
// }else {
|
|
|
|
// //查询此状态在时间内的打卡人数
|
|
|
|
// int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime);
|
|
|
|
// otherNumber += number;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics();
|
|
|
|
// healthTypeStatistics.setName("其他");
|
|
|
|
// healthTypeStatistics.setNumber(otherNumber);
|
|
|
|
// healthTypeStatisticsList.add(healthTypeStatistics);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// //获取查询的天数(正常应该一天打卡一次)
|
|
|
|
// Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1;
|
|
|
|
// //未上报的次数
|
|
|
|
// HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days,startTime,endTime);
|
|
|
|
//
|
|
|
|
// HealthVo.HealthTypeStatistics notUploadStatistics = new HealthVo.HealthTypeStatistics();
|
|
|
|
// notUploadStatistics.setName("未上报");
|
|
|
|
// if(ObjectUtil.isNotNull(notUpload)){
|
|
|
|
// notUploadStatistics.setNumber((int) (notUpload.getNumber() * days - notUpload.getTimes()));
|
|
|
|
// }else {
|
|
|
|
// notUploadStatistics.setNumber(0);
|
|
|
|
// }
|
|
|
|
// healthTypeStatisticsList.add(notUploadStatistics);
|
|
|
|
// }
|
|
|
|
return healthTypeStatisticsList; |
|
|
|
} |
|
|
|
|
|
|
@ -324,6 +360,7 @@ public class HealthService implements IHealthService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 上传备注文件 |
|
|
|
* |
|
|
|
* @param filePath |
|
|
|
* @param name |
|
|
|
* @return |
|
|
|