Browse Source

获取场景二维码

master
zhangye 5 years ago
parent
commit
668121f378
  1. 13
      health/src/main/java/com/ccsens/health/api/ClockController.java
  2. 9
      health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java
  3. 4
      health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java
  4. 8
      health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java
  5. 45
      health/src/main/java/com/ccsens/health/service/ClockService.java
  6. 3
      health/src/main/java/com/ccsens/health/service/IClockService.java
  7. 6
      health/src/main/java/com/ccsens/health/service/UserService.java
  8. 3
      util/src/main/java/com/ccsens/util/CodeEnum.java

13
health/src/main/java/com/ccsens/health/api/ClockController.java

@ -50,9 +50,18 @@ public class ClockController {
@MustLogin
@ApiOperation(value = "扫码统计", notes = "")
@RequestMapping(value = "statistics", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<ClockVo.SiteClockStatistics>> getSiteClickStatistics(@ApiParam @Validated @RequestBody JourneyDto.StatisticsDate date) throws Exception {
public JsonResponse<List<ClockVo.SiteClockStatistics>> getSiteClickStatistics(@ApiParam @Validated @RequestBody QueryDto<JourneyDto.StatisticsDate> params) throws Exception {
log.info("扫码统计");
List<ClockVo.SiteClockStatistics> siteClockStatisticsList = clockService.getSiteClickStatistics(date.getDate());
List<ClockVo.SiteClockStatistics> siteClockStatisticsList = clockService.getSiteClickStatistics(params.getParam().getDate());
return JsonResponse.newInstance().ok(siteClockStatisticsList);
}
@MustLogin
@ApiOperation(value = "生成场所二维码", notes = "")
@RequestMapping(value = "qrCode", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> getQRCode(@ApiParam @Validated @RequestBody QueryDto<JourneyDto.CreateQRCode> params) throws Exception {
log.info("扫码统计");
String codePath = clockService.getQRCode(params);
return JsonResponse.newInstance().ok(codePath);
}
}

9
health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java

@ -41,4 +41,13 @@ public class JourneyDto {
@ApiModelProperty("日期(格式:yy-[MM]-[dd])")
private String date;
}
@Data
@ApiModel("生成场所二维码")
public static class CreateQRCode{
@ApiModelProperty("场所id")
private Long id;
@ApiModelProperty("0进 1出")
private int type;
}
}

4
health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java

@ -32,6 +32,10 @@ public class ClockVo {
private String siteName;
@ApiModelProperty("人数")
private Integer number;
@ApiModelProperty("经度")
private Long longitude;
@ApiModelProperty("纬度")
private Long latitude;
}
}

8
health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java

@ -0,0 +1,8 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.persist.mapper.SiteMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface SiteDao extends SiteMapper {
}

45
health/src/main/java/com/ccsens/health/service/ClockService.java

@ -1,15 +1,30 @@
package com.ccsens.health.service;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import com.ccsens.health.bean.dto.ClockDto;
import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.po.Site;
import com.ccsens.health.bean.po.SiteQrcode;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.health.persist.dao.SiteDao;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.QrCodeUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
@Service
public class ClockService implements IClockService {
@Autowired
private SiteDao siteDao;
@Autowired
private Snowflake snowflake;
/**
@ -18,7 +33,7 @@ public class ClockService implements IClockService {
*/
@Override
public void siteClockIn(QueryDto<ClockDto.SiteDto> params) {
//
}
/**
@ -40,4 +55,32 @@ public class ClockService implements IClockService {
public List<ClockVo.SiteClockStatistics> getSiteClickStatistics(String date) {
return null;
}
/**
* 获取场所的二维码
* @param params
* @return
*/
@Override
public String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws IOException {
JourneyDto.CreateQRCode createQRCode = params.getParam();
//根据id查找场馆信息
Site site = siteDao.selectByPrimaryKey(createQRCode.getId());
if(ObjectUtil.isNull(site)){
throw new BaseException(CodeEnum.NOT_SITE);
}
//添加场所二维码记录
SiteQrcode siteQrcode = new SiteQrcode();
siteQrcode.setId(snowflake.nextId());
siteQrcode.setOutOrIn((byte) createQRCode.getType());
String type = "in";
if(createQRCode.getType() == 1){
type = "out";
}
//生成二维码
String qrcodeInfo = WebConstant.QRCODE_SITE + "?siteId=" + siteQrcode.getId() + "&scene=1011" + "&siteName="+site.getSiteCode()+"&type="+type;
String path = QrCodeUtil.urlToQRCode(qrcodeInfo,WebConstant.UPLOAD_PATH_BASE_HEALTH);
String qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + path;
return qrcodePath;
}
}

3
health/src/main/java/com/ccsens/health/service/IClockService.java

@ -5,6 +5,7 @@ import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.util.bean.dto.QueryDto;
import java.io.IOException;
import java.util.List;
public interface IClockService {
@ -13,4 +14,6 @@ public interface IClockService {
List<ClockVo.SiteClockInfo> getSiteClock(QueryDto<JourneyDto.SelectDate> params);
List<ClockVo.SiteClockStatistics> getSiteClickStatistics(String date);
String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws IOException;
}

6
health/src/main/java/com/ccsens/health/service/UserService.java

@ -26,6 +26,7 @@ public class UserService implements IUserService{
*/
@Override
public UserVo.UserInfo getUserInfo(QueryDto params) {
//查询自己的信息
return null;
}
@ -37,7 +38,10 @@ public class UserService implements IUserService{
@Override
public UserVo.UserInfo addUserInfo(QueryDto<UserDto.UserInfo> params) {
//获取个人信息和tall的userId
//查询对应的成员id
//实名认证,检查是否属于该学校的学生
//保存信息
//返回
return null;
}

3
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -94,7 +94,8 @@ public enum CodeEnum {
NOT_SIGN_FIELD(77,"签到的字段不可用",true),
ALREADY_SIGN(78,"您已经签到过了,请勿重复签到",true),
ALREADY_ATTENTION(79,"您已经关注了这个项目",true),
NOT_EMPLOYEE(79,"未找到成员信息",true)
NOT_EMPLOYEE(79,"未找到成员信息",true),
NOT_SITE(79,"未找到该场所",true)
;
public CodeEnum addMsg(String msg){

Loading…
Cancel
Save