diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java index 2f2d72a9..2617b86a 100644 --- a/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java @@ -30,6 +30,16 @@ import java.util.Map; @FeignClient(name = "tall", path = "v1.0", fallbackFactory = TallFeignClientFallBack.class) public interface TallFeignClient { + + /** + * 输入两个userid将两个账号合并(保留企业用户的id) + * @param userId 需要保存的userid + * @param uselessId 不需要保存的userid + * @return + */ + @GetMapping("/users/mergeUserId") + JsonResponse mergeUserId(@RequestParam(required = true, name = "userId") Long userId,@RequestParam(required = true, name = "uselessId") Long uselessId); + /** * 获取 * @@ -159,6 +169,11 @@ class TallFeignClientFallBack implements FallbackFactory { log.error(msg); } return new TallFeignClient() { + @Override + public JsonResponse mergeUserId(Long userId, Long uselessId) { + return JsonResponse.newInstance().fail(); + } + @Override public String get(QueryParam map) { return "hello world"; diff --git a/health/src/main/java/com/ccsens/health/api/HealthController.java b/health/src/main/java/com/ccsens/health/api/HealthController.java index a629253a..b248c41c 100644 --- a/health/src/main/java/com/ccsens/health/api/HealthController.java +++ b/health/src/main/java/com/ccsens/health/api/HealthController.java @@ -10,6 +10,7 @@ import com.ccsens.health.service.IHealthService; import com.ccsens.util.JsonResponse; import com.ccsens.util.WebConstant; import com.ccsens.util.bean.dto.QueryDto; +import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -68,4 +69,12 @@ public class HealthController { return JsonResponse.newInstance().ok(healthTypeStatisticsList); } + @MustLogin + @ApiOperation(value = "健康类型统计", notes = "") + @PostMapping("list") + public JsonResponse> list(@RequestBody QueryDto params){ + + PageInfo pageInfo = healthService.list(params); + return JsonResponse.newInstance().ok(pageInfo); + } } diff --git a/health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java b/health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java index 35f749f5..f6944f68 100644 --- a/health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java +++ b/health/src/main/java/com/ccsens/health/bean/dto/HealthDto.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import java.math.BigDecimal; @Data @@ -30,4 +32,26 @@ public class HealthDto { @ApiModelProperty("体温") private BigDecimal animalHeat; } + + @ApiModel("查询健康上报列表参数") + @Data + public static class QueryList{ + @ApiModelProperty("学号") + private String no; + @ApiModelProperty("姓名") + private String name; + @ApiModelProperty("班级") + private String department; + @ApiModelProperty("开始时间") + private Long startTime ; + @ApiModelProperty("开始时间") + private Long endTime ; + @ApiModelProperty("第几页") + @Min(value = 1) + private int pageNum = 1; + @ApiModelProperty("每页多少条") + @Min(value = 1) + @Max(value=100) + private int pageSize = 10; + } } diff --git a/health/src/main/java/com/ccsens/health/bean/po/SiteClockIn.java b/health/src/main/java/com/ccsens/health/bean/po/SiteClockIn.java index 9494456d..22307df7 100644 --- a/health/src/main/java/com/ccsens/health/bean/po/SiteClockIn.java +++ b/health/src/main/java/com/ccsens/health/bean/po/SiteClockIn.java @@ -7,7 +7,7 @@ import java.util.Date; public class SiteClockIn implements Serializable { private Long id; - private Long qrcodeId; + private Long siteId; private Long time; @@ -15,6 +15,12 @@ public class SiteClockIn implements Serializable { private BigDecimal locationLatitude; + private Long outTime; + + private BigDecimal outLocationLongitude; + + private BigDecimal outLocationLatitude; + private Long userId; private Date createdAt; @@ -33,12 +39,12 @@ public class SiteClockIn implements Serializable { this.id = id; } - public Long getQrcodeId() { - return qrcodeId; + public Long getSiteId() { + return siteId; } - public void setQrcodeId(Long qrcodeId) { - this.qrcodeId = qrcodeId; + public void setSiteId(Long siteId) { + this.siteId = siteId; } public Long getTime() { @@ -65,6 +71,30 @@ public class SiteClockIn implements Serializable { this.locationLatitude = locationLatitude; } + public Long getOutTime() { + return outTime; + } + + public void setOutTime(Long outTime) { + this.outTime = outTime; + } + + public BigDecimal getOutLocationLongitude() { + return outLocationLongitude; + } + + public void setOutLocationLongitude(BigDecimal outLocationLongitude) { + this.outLocationLongitude = outLocationLongitude; + } + + public BigDecimal getOutLocationLatitude() { + return outLocationLatitude; + } + + public void setOutLocationLatitude(BigDecimal outLocationLatitude) { + this.outLocationLatitude = outLocationLatitude; + } + public Long getUserId() { return userId; } @@ -104,10 +134,13 @@ public class SiteClockIn implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); - sb.append(", qrcodeId=").append(qrcodeId); + sb.append(", siteId=").append(siteId); sb.append(", time=").append(time); sb.append(", locationLongitude=").append(locationLongitude); sb.append(", locationLatitude=").append(locationLatitude); + sb.append(", outTime=").append(outTime); + sb.append(", outLocationLongitude=").append(outLocationLongitude); + sb.append(", outLocationLatitude=").append(outLocationLatitude); sb.append(", userId=").append(userId); sb.append(", createdAt=").append(createdAt); sb.append(", updatedAt=").append(updatedAt); diff --git a/health/src/main/java/com/ccsens/health/bean/po/SiteClockInExample.java b/health/src/main/java/com/ccsens/health/bean/po/SiteClockInExample.java index 15f4f730..8bbee140 100644 --- a/health/src/main/java/com/ccsens/health/bean/po/SiteClockInExample.java +++ b/health/src/main/java/com/ccsens/health/bean/po/SiteClockInExample.java @@ -166,63 +166,63 @@ public class SiteClockInExample { return (Criteria) this; } - public Criteria andQrcodeIdIsNull() { - addCriterion("qrcode_id is null"); + public Criteria andSiteIdIsNull() { + addCriterion("site_id is null"); return (Criteria) this; } - public Criteria andQrcodeIdIsNotNull() { - addCriterion("qrcode_id is not null"); + public Criteria andSiteIdIsNotNull() { + addCriterion("site_id is not null"); return (Criteria) this; } - public Criteria andQrcodeIdEqualTo(Long value) { - addCriterion("qrcode_id =", value, "qrcodeId"); + public Criteria andSiteIdEqualTo(Long value) { + addCriterion("site_id =", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdNotEqualTo(Long value) { - addCriterion("qrcode_id <>", value, "qrcodeId"); + public Criteria andSiteIdNotEqualTo(Long value) { + addCriterion("site_id <>", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdGreaterThan(Long value) { - addCriterion("qrcode_id >", value, "qrcodeId"); + public Criteria andSiteIdGreaterThan(Long value) { + addCriterion("site_id >", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdGreaterThanOrEqualTo(Long value) { - addCriterion("qrcode_id >=", value, "qrcodeId"); + public Criteria andSiteIdGreaterThanOrEqualTo(Long value) { + addCriterion("site_id >=", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdLessThan(Long value) { - addCriterion("qrcode_id <", value, "qrcodeId"); + public Criteria andSiteIdLessThan(Long value) { + addCriterion("site_id <", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdLessThanOrEqualTo(Long value) { - addCriterion("qrcode_id <=", value, "qrcodeId"); + public Criteria andSiteIdLessThanOrEqualTo(Long value) { + addCriterion("site_id <=", value, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdIn(List values) { - addCriterion("qrcode_id in", values, "qrcodeId"); + public Criteria andSiteIdIn(List values) { + addCriterion("site_id in", values, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdNotIn(List values) { - addCriterion("qrcode_id not in", values, "qrcodeId"); + public Criteria andSiteIdNotIn(List values) { + addCriterion("site_id not in", values, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdBetween(Long value1, Long value2) { - addCriterion("qrcode_id between", value1, value2, "qrcodeId"); + public Criteria andSiteIdBetween(Long value1, Long value2) { + addCriterion("site_id between", value1, value2, "siteId"); return (Criteria) this; } - public Criteria andQrcodeIdNotBetween(Long value1, Long value2) { - addCriterion("qrcode_id not between", value1, value2, "qrcodeId"); + public Criteria andSiteIdNotBetween(Long value1, Long value2) { + addCriterion("site_id not between", value1, value2, "siteId"); return (Criteria) this; } @@ -406,6 +406,186 @@ public class SiteClockInExample { return (Criteria) this; } + public Criteria andOutTimeIsNull() { + addCriterion("out_time is null"); + return (Criteria) this; + } + + public Criteria andOutTimeIsNotNull() { + addCriterion("out_time is not null"); + return (Criteria) this; + } + + public Criteria andOutTimeEqualTo(Long value) { + addCriterion("out_time =", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeNotEqualTo(Long value) { + addCriterion("out_time <>", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeGreaterThan(Long value) { + addCriterion("out_time >", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeGreaterThanOrEqualTo(Long value) { + addCriterion("out_time >=", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeLessThan(Long value) { + addCriterion("out_time <", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeLessThanOrEqualTo(Long value) { + addCriterion("out_time <=", value, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeIn(List values) { + addCriterion("out_time in", values, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeNotIn(List values) { + addCriterion("out_time not in", values, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeBetween(Long value1, Long value2) { + addCriterion("out_time between", value1, value2, "outTime"); + return (Criteria) this; + } + + public Criteria andOutTimeNotBetween(Long value1, Long value2) { + addCriterion("out_time not between", value1, value2, "outTime"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeIsNull() { + addCriterion("out_location_longitude is null"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeIsNotNull() { + addCriterion("out_location_longitude is not null"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeEqualTo(BigDecimal value) { + addCriterion("out_location_longitude =", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeNotEqualTo(BigDecimal value) { + addCriterion("out_location_longitude <>", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeGreaterThan(BigDecimal value) { + addCriterion("out_location_longitude >", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("out_location_longitude >=", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeLessThan(BigDecimal value) { + addCriterion("out_location_longitude <", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeLessThanOrEqualTo(BigDecimal value) { + addCriterion("out_location_longitude <=", value, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeIn(List values) { + addCriterion("out_location_longitude in", values, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeNotIn(List values) { + addCriterion("out_location_longitude not in", values, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("out_location_longitude between", value1, value2, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLongitudeNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("out_location_longitude not between", value1, value2, "outLocationLongitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeIsNull() { + addCriterion("out_location_latitude is null"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeIsNotNull() { + addCriterion("out_location_latitude is not null"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeEqualTo(BigDecimal value) { + addCriterion("out_location_latitude =", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeNotEqualTo(BigDecimal value) { + addCriterion("out_location_latitude <>", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeGreaterThan(BigDecimal value) { + addCriterion("out_location_latitude >", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("out_location_latitude >=", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeLessThan(BigDecimal value) { + addCriterion("out_location_latitude <", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeLessThanOrEqualTo(BigDecimal value) { + addCriterion("out_location_latitude <=", value, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeIn(List values) { + addCriterion("out_location_latitude in", values, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeNotIn(List values) { + addCriterion("out_location_latitude not in", values, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("out_location_latitude between", value1, value2, "outLocationLatitude"); + return (Criteria) this; + } + + public Criteria andOutLocationLatitudeNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("out_location_latitude not between", value1, value2, "outLocationLatitude"); + return (Criteria) this; + } + public Criteria andUserIdIsNull() { addCriterion("user_id is null"); return (Criteria) this; diff --git a/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java b/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java index 397d1676..8e714f97 100644 --- a/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java +++ b/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java @@ -16,12 +16,18 @@ public class ClockVo { private Long siteId; @ApiModelProperty("场所名称") private String siteName; - @ApiModelProperty("打卡时间") + @ApiModelProperty("进门打卡时间") private Long time; - @ApiModelProperty("经度") + @ApiModelProperty("进门定位-经度") private BigDecimal longitude; - @ApiModelProperty("纬度") + @ApiModelProperty("进门定位-纬度") private BigDecimal latitude; + @ApiModelProperty("出门打卡时间") + private Long outTime; + @ApiModelProperty("出门定位-经度") + private BigDecimal outLongitude; + @ApiModelProperty("出门定位-纬度") + private BigDecimal outLatitude; } diff --git a/health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java b/health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java index 1d1a6676..c9685cd5 100644 --- a/health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java +++ b/health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java @@ -95,4 +95,38 @@ public class HealthVo { private String quarantine; private String independent; } + + @Data + public static class HealthList{ + @ApiModelProperty("打卡记录的id") + private Long id; + @ApiModelProperty("成员id") + private Long userId; + @ApiModelProperty("日期") + private Long time; + @ApiModelProperty("当前所在地区") + private String district; + @ApiModelProperty("当前所在详细地址") + private String address; + @ApiModelProperty("当前身体状态") + private Long healthTypeId; + @ApiModelProperty("就诊医院") + private String hospital; + @ApiModelProperty("有无湖北武汉接触史 0没有 1有") + private int touchHubei; + @ApiModelProperty("有无接触患者 0无 1有") + private int touchSick; + @ApiModelProperty("体温") + private BigDecimal animalHeat; + @ApiModelProperty("健康状态code") + private Byte code; + @ApiModelProperty("健康状态名字") + private String codeName; + @ApiModelProperty("工号") + private String no; + @ApiModelProperty("学生名字") + private String name; + @ApiModelProperty("部门") + private String department; + } } diff --git a/health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java b/health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java index 0c9e7f72..c0464f9d 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java +++ b/health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java @@ -1,5 +1,6 @@ package com.ccsens.health.persist.dao; +import com.ccsens.health.bean.dto.HealthDto; import com.ccsens.health.bean.vo.HealthVo; import com.ccsens.health.bean.vo.UserVo; import com.ccsens.health.persist.mapper.HealthRecordsMapper; @@ -25,4 +26,11 @@ public interface HealthRecordsDao extends HealthRecordsMapper { * @return */ HealthVo.HealthDetail queryDetail(@Param("userId")Long userId, @Param("endTime") Long endTime); + + /** + * 查询健康信息 + * @param param + * @return + */ + List list(HealthDto.QueryList param); } diff --git a/health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java b/health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java index 9bd26923..417281a2 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java +++ b/health/src/main/java/com/ccsens/health/persist/dao/SiteClockInDao.java @@ -2,6 +2,7 @@ package com.ccsens.health.persist.dao; import com.ccsens.health.bean.dto.ClockDto; import com.ccsens.health.bean.dto.MemberDto; +import com.ccsens.health.bean.po.SiteClockIn; import com.ccsens.health.bean.vo.ClockVo; import com.ccsens.health.persist.mapper.SiteClockInMapper; import org.apache.ibatis.annotations.Param; @@ -29,4 +30,10 @@ public interface SiteClockInDao extends SiteClockInMapper { */ List queryRecordBySite(List dtos); + /** + * 查询上一个校园打卡记录 + * @param userId + * @return + */ + SiteClockIn getPrevClockIn(@Param("userId") Long userId); } diff --git a/health/src/main/java/com/ccsens/health/service/ClockService.java b/health/src/main/java/com/ccsens/health/service/ClockService.java index b5453835..a42f87b7 100644 --- a/health/src/main/java/com/ccsens/health/service/ClockService.java +++ b/health/src/main/java/com/ccsens/health/service/ClockService.java @@ -15,6 +15,7 @@ import com.ccsens.health.bean.vo.HealthVo; import com.ccsens.health.persist.dao.SiteClockInDao; import com.ccsens.health.persist.dao.SiteDao; import com.ccsens.health.persist.dao.SiteQrcodeDao; +import com.ccsens.health.util.HealthConstant; import com.ccsens.util.*; import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.exception.BaseException; @@ -28,6 +29,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; +import java.sql.Struct; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -61,6 +63,10 @@ public class ClockService implements IClockService { Long userId = params.getUserId(); //获取场所ID SiteQrcode siteQrcode = siteQrcodeDao.selectByPrimaryKey(clickIn.getSiteId()); + log.info("打卡二维码:{}", siteQrcode); + if (siteQrcode == null) { + throw new BaseException(CodeEnum.PARAM_ERROR); + } Site site = siteDao.selectByPrimaryKey(siteQrcode.getSiteId()); log.info("场所信息:{}", site); if (site == null) { @@ -77,17 +83,86 @@ public class ClockService implements IClockService { // //2、通过userId获取成员id // Employee employee = userService.getEmployeeByUserId(userId); //添加打卡记录 + + SiteClockIn prevClockIn = siteClockInDao.getPrevClockIn(userId); + log.info("上一条打卡:{}", prevClockIn); + if (prevClockIn == null) { + saveClockIn(userId, site.getId(), siteQrcode.getOutOrIn(), clickIn); + } else if (siteQrcode.getOutOrIn().byteValue() == HealthConstant.SITE_IN) { + // 进场打卡 + //1.判断上一打卡记录,判断是否有结束时间,无则设置当前时间为上一个场所的结束时间 + if (prevClockIn.getOutTime() == null || prevClockIn.getOutTime().longValue() == 0) { + prevClockIn.setOutTime(System.currentTimeMillis()); + siteClockInDao.updateByPrimaryKeySelective(prevClockIn); + } + //2.保存当前打卡 + saveClockIn(userId, site.getId(), siteQrcode.getOutOrIn(), clickIn); + } else { + // 出去打卡 + //1.判断上一个打卡场所是否为本场所+出去打卡时间为空 + if (prevClockIn.getSiteId().longValue() == site.getId().longValue() + && (prevClockIn.getOutTime() == null || prevClockIn.getOutTime().longValue() == 0)) { + prevClockIn.setOutTime(System.currentTimeMillis()); + prevClockIn.setOutLocationLatitude(clickIn.getLocationLatitude()); + prevClockIn.setOutLocationLongitude(clickIn.getLocationLongitude()); + siteClockInDao.updateByPrimaryKeySelective(prevClockIn); + } else if (prevClockIn.getOutTime() != null && prevClockIn.getOutTime().longValue() != 0) { + //进门未打卡 + saveOutClockIn(userId, site.getId(), prevClockIn.getOutTime(), clickIn); + } else { + //上一次出场所未打卡 + 进来未打卡 + prevClockIn.setOutTime(System.currentTimeMillis()); + siteClockInDao.updateByPrimaryKeySelective(prevClockIn); + saveOutClockIn(userId, site.getId(), prevClockIn.getTime(), clickIn); + } + } + } + + /** + * 新增出门打卡记录(进入时未打卡) + * @param userId + * @param siteId + * @param inTimem + * @param clickIn + */ + private void saveOutClockIn(Long userId, Long siteId, Long inTimem, ClockDto.SiteDto clickIn) { SiteClockIn siteClockIn = new SiteClockIn(); siteClockIn.setId(snowflake.nextId()); siteClockIn.setUserId(userId); - siteClockIn.setQrcodeId(clickIn.getSiteId()); - siteClockIn.setTime(System.currentTimeMillis()); - siteClockIn.setLocationLatitude(clickIn.getLocationLatitude()); - siteClockIn.setLocationLongitude(clickIn.getLocationLongitude()); + siteClockIn.setSiteId(siteId); + siteClockIn.setTime(inTimem); + siteClockIn.setOutTime(System.currentTimeMillis()); + siteClockIn.setOutLocationLatitude(clickIn.getLocationLatitude()); + siteClockIn.setOutLocationLongitude(clickIn.getLocationLongitude()); + log.info("新添加一条打卡记录"); + siteClockInDao.insertSelective(siteClockIn); + } + /** + * 存储打卡记录 + * @param userId + * @param siteId + * @param outOrIn + * @param clickIn + */ + private void saveClockIn(Long userId, Long siteId, byte outOrIn, ClockDto.SiteDto clickIn){ + SiteClockIn siteClockIn = new SiteClockIn(); + siteClockIn.setId(snowflake.nextId()); + siteClockIn.setUserId(userId); + siteClockIn.setSiteId(siteId); + if (outOrIn == HealthConstant.SITE_IN) { + //进场打卡 + siteClockIn.setTime(System.currentTimeMillis()); + siteClockIn.setLocationLatitude(clickIn.getLocationLatitude()); + siteClockIn.setLocationLongitude(clickIn.getLocationLongitude()); + } else { + // 出场打卡 + siteClockIn.setTime(DateUtil.parse(DateUtil.today()).getTime()); + siteClockIn.setOutTime(System.currentTimeMillis()); + siteClockIn.setOutLocationLatitude(clickIn.getLocationLatitude()); + siteClockIn.setOutLocationLongitude(clickIn.getLocationLongitude()); + } siteClockInDao.insertSelective(siteClockIn); - } - /** * 查看打卡记录 * @@ -100,9 +175,12 @@ public class ClockService implements IClockService { JourneyDto.SelectDate selectDate = params.getParam(); Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime(); Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime(); - String userId = tallFeignClient.getUserId(selectDate.getToken()); - if (StrUtil.isEmpty(userId)) { - throw new BaseException(CodeEnum.NOT_LOGIN); + String userId = String.valueOf(params.getUserId()); + if (StrUtil.isNotBlank(selectDate.getToken())) { + userId = tallFeignClient.getUserId(selectDate.getToken()); + if (StrUtil.isEmpty(userId)) { + throw new BaseException(CodeEnum.NOT_LOGIN); + } } // //2、通过userid查询出成员id // Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId)); diff --git a/health/src/main/java/com/ccsens/health/service/HealthService.java b/health/src/main/java/com/ccsens/health/service/HealthService.java index 547fd52a..cd82eaa9 100644 --- a/health/src/main/java/com/ccsens/health/service/HealthService.java +++ b/health/src/main/java/com/ccsens/health/service/HealthService.java @@ -20,6 +20,8 @@ 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 com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import io.micrometer.shaded.org.pcollections.PCollection; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -27,6 +29,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.validation.Valid; import java.io.File; import java.io.IOException; import java.math.BigDecimal; @@ -233,4 +236,12 @@ public class HealthService implements IHealthService{ } return healthTypeStatisticsList; } + + @Override + public PageInfo list(QueryDto params) { + HealthDto.QueryList param = params.getParam(); + PageHelper.startPage(param.getPageNum(), param.getPageSize()); + List vos = healthRecordsDao.list(param); + return new PageInfo<>(vos); + } } diff --git a/health/src/main/java/com/ccsens/health/service/IHealthService.java b/health/src/main/java/com/ccsens/health/service/IHealthService.java index 792ca975..73ec40a0 100644 --- a/health/src/main/java/com/ccsens/health/service/IHealthService.java +++ b/health/src/main/java/com/ccsens/health/service/IHealthService.java @@ -4,6 +4,7 @@ import com.ccsens.health.bean.dto.HealthDto; import com.ccsens.health.bean.dto.JourneyDto; import com.ccsens.health.bean.vo.HealthVo; import com.ccsens.util.bean.dto.QueryDto; +import com.github.pagehelper.PageInfo; import java.io.IOException; import java.util.List; @@ -16,4 +17,11 @@ public interface IHealthService { List getHealthType(); List getHealthTypeStatistics(QueryDto params) throws Exception; + + /** + * 健康列表 + * @param params + * @return + */ + PageInfo list(QueryDto params); } diff --git a/health/src/main/java/com/ccsens/health/service/UserService.java b/health/src/main/java/com/ccsens/health/service/UserService.java index 52f2d1b3..3a610c30 100644 --- a/health/src/main/java/com/ccsens/health/service/UserService.java +++ b/health/src/main/java/com/ccsens/health/service/UserService.java @@ -15,6 +15,7 @@ import com.ccsens.health.persist.dao.*; import com.ccsens.health.util.HealthConstant; import com.ccsens.util.CodeEnum; import com.ccsens.util.DateUtil; +import com.ccsens.util.JsonResponse; import com.ccsens.util.bean.dto.QueryDto; import com.ccsens.util.exception.BaseException; import lombok.extern.slf4j.Slf4j; @@ -185,8 +186,14 @@ public class UserService implements IUserService{ * @return */ private void bindUser(Long sourceUserId, Long targetUserId) { + log.info("sourceUserId:{}, targetUserId:{}", sourceUserId, targetUserId); //TODO 帐号绑定 - + JsonResponse jsonResponse = tallFeignClient.mergeUserId(targetUserId, sourceUserId); + log.info("绑定帐号结果:{}", jsonResponse); + if (jsonResponse.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) { + log.info("绑定帐号失败:{}", jsonResponse); + throw new BaseException(jsonResponse.getCode(), jsonResponse.getMsg()); + } // 绑定实名认证 RealNameAuth auth = new RealNameAuth(); auth.setUserId(targetUserId); diff --git a/health/src/main/java/com/ccsens/health/util/HealthConstant.java b/health/src/main/java/com/ccsens/health/util/HealthConstant.java index 6a3c4435..9d31cd15 100644 --- a/health/src/main/java/com/ccsens/health/util/HealthConstant.java +++ b/health/src/main/java/com/ccsens/health/util/HealthConstant.java @@ -31,4 +31,10 @@ public class HealthConstant { public static final byte JOURNEY_BACK_SCHOOL = 1; /**行程类型: 日常外出*/ public static final byte JOURNEY_OUT_SCHOOL = 1; + /**场所进出:进*/ + public static final byte SITE_IN = 0; + /**场所进出:出*/ + public static final byte SITE_OUT = 1; + /**第一次打卡漏打默认两小时*/ + public static final long DEFAULT_CLOCK_TIME = 2 *60 * 60 * 1000; } diff --git a/health/src/main/resources/mapper_dao/HealthRecordDao.xml b/health/src/main/resources/mapper_dao/HealthRecordDao.xml index 4d9167df..10856dec 100644 --- a/health/src/main/resources/mapper_dao/HealthRecordDao.xml +++ b/health/src/main/resources/mapper_dao/HealthRecordDao.xml @@ -119,4 +119,28 @@ and r.rec_status = 0 order by r.time desc limit 1 + \ No newline at end of file diff --git a/health/src/main/resources/mapper_dao/SiteClockInDao.xml b/health/src/main/resources/mapper_dao/SiteClockInDao.xml index d3058653..8f0bcf38 100644 --- a/health/src/main/resources/mapper_dao/SiteClockInDao.xml +++ b/health/src/main/resources/mapper_dao/SiteClockInDao.xml @@ -7,6 +7,22 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/health/src/main/resources/mapper_raw/SiteClockInMapper.xml b/health/src/main/resources/mapper_raw/SiteClockInMapper.xml index c44ed3fb..ba3fa013 100644 --- a/health/src/main/resources/mapper_raw/SiteClockInMapper.xml +++ b/health/src/main/resources/mapper_raw/SiteClockInMapper.xml @@ -3,10 +3,13 @@ - + + + + @@ -71,8 +74,8 @@ - id, qrcode_id, time, location_longitude, location_latitude, user_id, created_at, - updated_at, rec_status + id, site_id, time, location_longitude, location_latitude, out_time, out_location_longitude, + out_location_latitude, user_id, created_at, updated_at, rec_status