|
|
@ -5,6 +5,7 @@ import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.ZipUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.health.bean.dto.ClockDto; |
|
|
|
import com.ccsens.health.bean.dto.HealthDto; |
|
|
@ -50,6 +51,10 @@ public class ClockService implements IClockService { |
|
|
|
@Autowired |
|
|
|
private RealNameAuthDao realNameAuthDao; |
|
|
|
@Autowired |
|
|
|
private RedisUtil redisUtil; |
|
|
|
@Autowired |
|
|
|
private HealthService healthService; |
|
|
|
@Autowired |
|
|
|
private IUserService userService; |
|
|
|
@Autowired |
|
|
|
private TallFeignClient tallFeignClient; |
|
|
@ -60,7 +65,7 @@ public class ClockService implements IClockService { |
|
|
|
* @param params |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void siteClockIn(QueryDto<ClockDto.SiteDto> params) { |
|
|
|
public void siteClockIn(QueryDto<ClockDto.SiteDto> params) throws Exception { |
|
|
|
//1、获取打卡信息和userId
|
|
|
|
ClockDto.SiteDto clickIn = params.getParam(); |
|
|
|
Long userId = params.getUserId(); |
|
|
@ -84,16 +89,32 @@ public class ClockService implements IClockService { |
|
|
|
} |
|
|
|
|
|
|
|
//判断经纬度是否正确
|
|
|
|
boolean inCircle = DistanceUtil.isInCircle(site.getLongitude(), site.getLatitude(), clickIn.getLocationLongitude(), clickIn.getLocationLatitude(), "1"); |
|
|
|
boolean inCircle = DistanceUtil.isInCircle(site.getLongitude(), site.getLatitude(), clickIn.getLocationLongitude(), clickIn.getLocationLatitude(), "0.1"); |
|
|
|
log.info("是否在半径内:{}", inCircle); |
|
|
|
if (!inCircle) { |
|
|
|
throw new BaseException(CodeEnum.LOCATION_LONG); |
|
|
|
} |
|
|
|
//判断该学生健康状态
|
|
|
|
String key = HealthConstant.getHealthRecordKey(userId); |
|
|
|
Object o = redisUtil.get(key); |
|
|
|
log.info("redis读取健康状态:{},{}", userId, o); |
|
|
|
if(o == null || StrUtil.isEmpty((String)o)){ |
|
|
|
//如果redis为空,查询数据库
|
|
|
|
JourneyDto.SelectDate selectDate = new JourneyDto.SelectDate(); |
|
|
|
List<HealthVo.HealthInfo> healthInfoList = healthService.getHealthInfo(selectDate,userId); |
|
|
|
if(CollectionUtil.isEmpty(healthInfoList)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_HEALTH_RECORD); |
|
|
|
} |
|
|
|
if(healthInfoList.get(0).getHealthLevel() != 0){ |
|
|
|
throw new BaseException(CodeEnum.HEALTH_TYPE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
HealthVo.HealthRecordRedis healthRecordRedis = JSONObject.parseObject((String)o, HealthVo.HealthRecordRedis.class); |
|
|
|
if(healthRecordRedis.getHealthLevel() != 0){ |
|
|
|
throw new BaseException(CodeEnum.HEALTH_TYPE_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
// //2、通过userId获取成员id
|
|
|
|
// Employee employee = userService.getEmployeeByUserId(userId);
|
|
|
|
//添加打卡记录
|
|
|
|
|
|
|
|
SiteClockIn prevClockIn = siteClockInDao.getPrevClockIn(userId); |
|
|
|
log.info("上一条打卡:{}", prevClockIn); |
|
|
|
if (prevClockIn == null) { |
|
|
|