diff --git a/health/src/main/java/com/ccsens/health/api/ClockController.java b/health/src/main/java/com/ccsens/health/api/ClockController.java index 1c853438..bedfbd60 100644 --- a/health/src/main/java/com/ccsens/health/api/ClockController.java +++ b/health/src/main/java/com/ccsens/health/api/ClockController.java @@ -116,7 +116,7 @@ public class ClockController { @ApiOperation(value = "场所统计概览", notes = "") @RequestMapping(value = "overview", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse> selectSiteOverview(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { - log.info("修改场所信息:{}", params); + log.info("场所统计概览:{}", params); List siteOverviewList = clockService.selectSiteOverview(params.getParam()); return JsonResponse.newInstance().ok(siteOverviewList); } @@ -124,9 +124,18 @@ public class ClockController { @MustLogin @ApiOperation(value = "场所内人员列表", notes = "") @RequestMapping(value = "member", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse> selectSiteMemberList(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { - log.info("修改场所信息:{}", params); - List siteOverviewList = clockService.selectSiteMemberList(params.getParam()); + public JsonResponse> selectSiteMemberList(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("场所内人员列表:{}", params); + PageInfo siteOverviewList = clockService.selectSiteMemberList(params.getParam()); + return JsonResponse.newInstance().ok(siteOverviewList); + } + + @MustLogin + @ApiOperation(value = "场所实时统计", notes = "") + @RequestMapping(value = "real_time_statistics", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> getRealTimeStatistics(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("场所实时统计:{}", params); + List siteOverviewList = clockService.getRealTimeStatistics(params.getParam()); return JsonResponse.newInstance().ok(siteOverviewList); } } diff --git a/health/src/main/java/com/ccsens/health/api/JourneyController.java b/health/src/main/java/com/ccsens/health/api/JourneyController.java index c4b022ad..11d0e5d3 100644 --- a/health/src/main/java/com/ccsens/health/api/JourneyController.java +++ b/health/src/main/java/com/ccsens/health/api/JourneyController.java @@ -52,9 +52,9 @@ public class JourneyController { @MustLogin @ApiOperation(value = "查询学生校外行程", notes = "") @RequestMapping(value = "infoList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse> getJourneyInfoList(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { - log.info("查询行程:{}",params); - List journeyInfoList = journeyService.getJourneyInfoList(params.getParam(),params.getUserId()); + public JsonResponse> getJourneyInfoList(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("查询学生校外行程:{}",params); + PageInfo journeyInfoList = journeyService.getJourneyInfoList(params.getParam(),params.getUserId()); return JsonResponse.newInstance().ok(journeyInfoList); } diff --git a/health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java b/health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java index 9abcaf23..5965170d 100644 --- a/health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java +++ b/health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java @@ -49,17 +49,17 @@ public class ClockDto { @Data @ApiModel("时间段内场所人数统计") public static class SiteOverview{ - @ApiModelProperty("场所ID") + @ApiModelProperty("场所名") private String siteName; @ApiModelProperty("开始时间") - private Long startTime; + private Long time; } @Data @ApiModel("查找场所内的学生列表") public static class SelectSiteMember{ - @ApiModelProperty("场所ID") - private Long siteId; + @ApiModelProperty("场所名") + private Long siteName; @ApiModelProperty("姓名") private String name; @ApiModelProperty("学号") @@ -78,4 +78,15 @@ public class ClockDto { @Max(value=100) private int pageSize = 10; } + + @Data + @ApiModel("场所实时统计") + public static class RealTimeStatistics{ + @ApiModelProperty("场所名") + private String siteName; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + } } diff --git a/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java b/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java index aa16ac65..808ec7d9 100644 --- a/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java +++ b/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java @@ -53,18 +53,18 @@ public class JourneyDto { public static class SelectJourneyByName{ @Size(max = 6,min = 0,message = "信息格式错误") @ApiModelProperty("学生姓名") - private Long name; + private String name; @Size(max = 16,min = 0,message = "信息格式错误") @ApiModelProperty("学号") - private Long wkno; + private String wkno; @ApiModelProperty("出行方式 0铁路 1飞机 2客运车辆 3自驾 4船 5其他") private int tripMode; @Size(max = 12,min = 0,message = "信息格式错误") @ApiModelProperty("车次号") private String carNo; - @ApiModelProperty("开始时间 默认今天零点") + @ApiModelProperty("开始时间") private Long startTime; - @ApiModelProperty("结束时间 默认当前时间") + @ApiModelProperty("结束时间") private Long endTime; @ApiModelProperty("第几页") @Min(value = 1) 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 da7e08ed..1a00c27a 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 @@ -129,11 +129,22 @@ public class ClockVo { @ApiModelProperty("班级") private String department; @ApiModelProperty("进入打卡时间") - private Long time; + private Long inTime; @ApiModelProperty("出去打卡时间") private Long outTime; @ApiModelProperty("健康状态") private Long healthType; } + + @Data + @ApiModel("实时统计场所的出入次数") + public static class RealTimeStatistics{ + @ApiModelProperty("时间") + private String time; + @ApiModelProperty("进入打卡次数") + private int inCount; + @ApiModelProperty("出去打卡次数") + private int outCount; + } } diff --git a/health/src/main/java/com/ccsens/health/persist/dao/JourneyAbnormalDao.java b/health/src/main/java/com/ccsens/health/persist/dao/JourneyAbnormalDao.java index a4a78c08..c74c1bf6 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/JourneyAbnormalDao.java +++ b/health/src/main/java/com/ccsens/health/persist/dao/JourneyAbnormalDao.java @@ -2,6 +2,7 @@ package com.ccsens.health.persist.dao; import com.ccsens.health.bean.vo.JourneyVo; import com.ccsens.health.persist.mapper.JourneyAbnormalMapper; +import com.github.pagehelper.PageInfo; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; diff --git a/health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java b/health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java index 5678c209..b0e8c288 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java +++ b/health/src/main/java/com/ccsens/health/persist/dao/JourneyDao.java @@ -42,4 +42,11 @@ public interface JourneyDao extends JourneyMapper { * @return */ List queryByCarNo(List carNos); + + /** + * 查询学生校外行程 + * @param param + * @return + */ + List getJourneyInfoList(JourneyDto.SelectJourneyByName param); } diff --git a/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java b/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java index 91ce6adf..2ef39560 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java +++ b/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java @@ -1,8 +1,11 @@ package com.ccsens.health.persist.dao; +import com.ccsens.health.bean.dto.ClockDto; import com.ccsens.health.bean.dto.JourneyDto; import com.ccsens.health.bean.vo.ClockVo; import com.ccsens.health.persist.mapper.SiteMapper; +import com.github.pagehelper.PageInfo; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -15,4 +18,10 @@ public interface SiteDao extends SiteMapper { * @return */ List queryAll(JourneyDto.Query query); + + List selectSiteOverview(@Param("siteName") String siteName, @Param("time")Long time); + + List selectSiteMemberList(ClockDto.SelectSiteMember param); + + List getRealTimeStatistics(ClockDto.RealTimeStatistics param); } 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 950e524a..1af39b4e 100644 --- a/health/src/main/java/com/ccsens/health/service/ClockService.java +++ b/health/src/main/java/com/ccsens/health/service/ClockService.java @@ -13,6 +13,7 @@ import com.ccsens.health.bean.dto.JourneyDto; import com.ccsens.health.bean.po.*; import com.ccsens.health.bean.vo.ClockVo; import com.ccsens.health.bean.vo.HealthVo; +import com.ccsens.health.bean.vo.JourneyVo; import com.ccsens.health.persist.dao.RealNameAuthDao; import com.ccsens.health.persist.dao.SiteClockInDao; import com.ccsens.health.persist.dao.SiteDao; @@ -53,7 +54,9 @@ public class ClockService implements IClockService { @Autowired private RedisUtil redisUtil; @Autowired - private HealthService healthService; + private IHealthService healthService; + @Autowired + private IConstantService constantService; @Autowired private IUserService userService; @Autowired @@ -88,8 +91,11 @@ public class ClockService implements IClockService { throw new BaseException(CodeEnum.PARAM_ERROR); } + //获取打卡范围常量 + String r = "0.8"; + r = constantService.getByKey("radius"); //判断经纬度是否正确 - boolean inCircle = DistanceUtil.isInCircle(site.getLongitude(), site.getLatitude(), clickIn.getLocationLongitude(), clickIn.getLocationLatitude(), "0.8"); + boolean inCircle = DistanceUtil.isInCircle(site.getLongitude(), site.getLatitude(), clickIn.getLocationLongitude(), clickIn.getLocationLatitude(), r); log.info("是否在半径内:{}", inCircle); if (!inCircle) { throw new BaseException(CodeEnum.LOCATION_LONG); @@ -424,11 +430,20 @@ public class ClockService implements IClockService { @Override public List selectSiteOverview(ClockDto.SiteOverview param) { - return null; + List siteOverviewList = siteDao.selectSiteOverview(param.getSiteName(),param.getTime()); + return siteOverviewList; + } + + @Override + public PageInfo selectSiteMemberList(ClockDto.SelectSiteMember param) { + PageHelper.startPage(param.getPageNum(), param.getPageSize()); + List siteMemberList = siteDao.selectSiteMemberList(param); + return new PageInfo<>(siteMemberList); } @Override - public List selectSiteMemberList(ClockDto.SelectSiteMember param) { - return null; + public List getRealTimeStatistics(ClockDto.RealTimeStatistics param) { + List realTimeStatisticsList = siteDao.getRealTimeStatistics(param); + return realTimeStatisticsList; } } diff --git a/health/src/main/java/com/ccsens/health/service/IClockService.java b/health/src/main/java/com/ccsens/health/service/IClockService.java index 6188165c..b05e1825 100644 --- a/health/src/main/java/com/ccsens/health/service/IClockService.java +++ b/health/src/main/java/com/ccsens/health/service/IClockService.java @@ -31,5 +31,7 @@ public interface IClockService { List selectSiteOverview(ClockDto.SiteOverview param); - List selectSiteMemberList(ClockDto.SelectSiteMember param); + PageInfo selectSiteMemberList(ClockDto.SelectSiteMember param); + + List getRealTimeStatistics(ClockDto.RealTimeStatistics param); } diff --git a/health/src/main/java/com/ccsens/health/service/IJourneyService.java b/health/src/main/java/com/ccsens/health/service/IJourneyService.java index 5187b988..fe667e35 100644 --- a/health/src/main/java/com/ccsens/health/service/IJourneyService.java +++ b/health/src/main/java/com/ccsens/health/service/IJourneyService.java @@ -46,5 +46,5 @@ public interface IJourneyService { */ PageInfo classBackStatistics(JourneyDto.BackClass backClass); - List getJourneyInfoList(JourneyDto.SelectJourneyByName param, Long userId); + PageInfo getJourneyInfoList(JourneyDto.SelectJourneyByName param, Long userId); } diff --git a/health/src/main/java/com/ccsens/health/service/JourneyService.java b/health/src/main/java/com/ccsens/health/service/JourneyService.java index 7ed721c3..471ec035 100644 --- a/health/src/main/java/com/ccsens/health/service/JourneyService.java +++ b/health/src/main/java/com/ccsens/health/service/JourneyService.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil; import com.ccsens.cloudutil.feign.TallFeignClient; import com.ccsens.health.bean.dto.JourneyDto; import com.ccsens.health.bean.po.*; +import com.ccsens.health.bean.vo.ClockVo; import com.ccsens.health.bean.vo.JourneyVo; import com.ccsens.health.bean.vo.UserVo; import com.ccsens.health.persist.dao.EmployeeDao; @@ -158,9 +159,10 @@ public class JourneyService implements IJourneyService{ * 查询学生校外行程 */ @Override - public List getJourneyInfoList(JourneyDto.SelectJourneyByName param, Long userId) { -// List studentJourneyInfos = - return null; + public PageInfo getJourneyInfoList(JourneyDto.SelectJourneyByName param, Long userId) { + PageHelper.startPage(param.getPageNum(), param.getPageSize()); + List studentJourneyInfos = journeyDao.getJourneyInfoList(param); + return new PageInfo<>(studentJourneyInfos); } /** @@ -195,7 +197,6 @@ public class JourneyService implements IJourneyService{ PageHelper.startPage(page, 10); List addAbnormalJourneyList = journeyAbnormalDao.selectAbnormalJourney(abnormalJourney.getCarNo(),abnormalJourney.getTripMode(),abnormalJourney.getStartTime(),abnormalJourney.getEndTime()); - return addAbnormalJourneyList; } diff --git a/health/src/main/resources/application.yml b/health/src/main/resources/application.yml index c3b11fb6..2fb38e57 100644 --- a/health/src/main/resources/application.yml +++ b/health/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: test - include: common, util-test + active: dev + include: common, util-dev diff --git a/health/src/main/resources/mapper_dao/JourneyDao.xml b/health/src/main/resources/mapper_dao/JourneyDao.xml index 2498ed7e..714dde52 100644 --- a/health/src/main/resources/mapper_dao/JourneyDao.xml +++ b/health/src/main/resources/mapper_dao/JourneyDao.xml @@ -113,5 +113,45 @@ ORDER BY a.no, j.start_time - + \ No newline at end of file diff --git a/health/src/main/resources/mapper_dao/SiteDao.xml b/health/src/main/resources/mapper_dao/SiteDao.xml index e1cb1f56..b6e8a2ea 100644 --- a/health/src/main/resources/mapper_dao/SiteDao.xml +++ b/health/src/main/resources/mapper_dao/SiteDao.xml @@ -22,4 +22,121 @@ (select * from t_site_qrcode where out_or_in = 1) t2 on t.id = t2.site_id + + + + + + + select FROM_UNIXTIME(sc.time/1000,'%Y-%m-%d %H') as time, count(*) as inCount from t_site s, t_site_clock_in sc where s.id = sc.site_id + + and s.site_name = #{siteName} + + + and sc.time >= #{startTime} + + + and sc.time <= #{endTime} + + group by FROM_UNIXTIME(sc.time/1000,'%Y-%m-%d %H') + + + select FROM_UNIXTIME(sc.out_time/1000,'%Y-%m-%d %H') as time, count(*) as outCount from t_site s, t_site_clock_in sc where s.id = sc.site_id + + and s.site_name = #{siteName} + + + and sc.out_time >= #{startTime} + + + and sc.out_time <= #{endTime} + + group by FROM_UNIXTIME(sc.out_time/1000,'%Y-%m-%d %H') + + + \ No newline at end of file