Browse Source

0308.1

master
zhangye 6 years ago
parent
commit
ceba838ae8
  1. 3
      health/src/main/java/com/ccsens/health/api/DebugController.java
  2. 49
      health/src/main/java/com/ccsens/health/service/ClockService.java
  3. 29
      util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

3
health/src/main/java/com/ccsens/health/api/DebugController.java

@ -38,6 +38,9 @@ public class DebugController {
color.b = "0"; color.b = "0";
WxXcxUtil.getWxCode("pages/user-code/user-code" WxXcxUtil.getWxCode("pages/user-code/user-code"
,"d=1217647686598135808",color,"/home/cloud/tall/uploads/qrCode/2020-03-07/158357267174.png"); ,"d=1217647686598135808",color,"/home/cloud/tall/uploads/qrCode/2020-03-07/158357267174.png");
// WxXcxUtil.getWxCodeTest("pages/user-code/user-code?d=1217647686598135808"
// ,"d=1217647686598135808",color,"/home/cloud/tall/uploads/qrCode/2020-03-07/158357267174.png");
return JsonResponse.newInstance().ok("完成"); return JsonResponse.newInstance().ok("完成");
} }
} }

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

@ -48,6 +48,7 @@ public class ClockService implements IClockService {
/** /**
* 场景扫码打卡 * 场景扫码打卡
*
* @param params * @param params
*/ */
@Override @Override
@ -69,6 +70,7 @@ public class ClockService implements IClockService {
/** /**
* 查看打卡记录 * 查看打卡记录
*
* @param params * @param params
* @return * @return
*/ */
@ -79,19 +81,20 @@ public class ClockService implements IClockService {
Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime(); Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime();
Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime(); Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime();
String userId = tallFeignClient.getUserId(selectDate.getToken()); String userId = tallFeignClient.getUserId(selectDate.getToken());
if(StrUtil.isEmpty(userId)){ if (StrUtil.isEmpty(userId)) {
throw new BaseException(CodeEnum.NOT_LOGIN); throw new BaseException(CodeEnum.NOT_LOGIN);
} }
// //2、通过userid查询出成员id // //2、通过userid查询出成员id
// Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId)); // Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId));
//3、查询该成员符合时间的记录 //3、查询该成员符合时间的记录
List<ClockVo.SiteClockInfo> siteClockInfoList = siteClockInDao.selectHealthInfoByDate(Long.valueOf(userId),startTime,endTime); List<ClockVo.SiteClockInfo> siteClockInfoList = siteClockInDao.selectHealthInfoByDate(Long.valueOf(userId), startTime, endTime);
//4、返回 //4、返回
return siteClockInfoList; return siteClockInfoList;
} }
/** /**
* 场所扫码统计 * 场所扫码统计
*
* @param * @param
* @return * @return
*/ */
@ -107,10 +110,10 @@ public class ClockService implements IClockService {
SiteExample siteExample = new SiteExample(); SiteExample siteExample = new SiteExample();
siteExample.createCriteria().andParentCodeEqualTo("SXDX"); siteExample.createCriteria().andParentCodeEqualTo("SXDX");
List<Site> siteList = siteDao.selectByExample(siteExample); List<Site> siteList = siteDao.selectByExample(siteExample);
if(CollectionUtil.isNotEmpty(siteList)){ if (CollectionUtil.isNotEmpty(siteList)) {
for(Site site:siteList){ for (Site site : siteList) {
//2、获取场景的二维码(包括进出),查找每个二维码下的打卡记录 //2、获取场景的二维码(包括进出),查找每个二维码下的打卡记录
int number = siteClockInDao.getClockInNumberBySiteId(site.getId(),startTime,endTime); int number = siteClockInDao.getClockInNumberBySiteId(site.getId(), startTime, endTime);
ClockVo.SiteClockStatistics siteClockStatistics = new ClockVo.SiteClockStatistics(); ClockVo.SiteClockStatistics siteClockStatistics = new ClockVo.SiteClockStatistics();
siteClockStatistics.setSiteId(site.getId()); siteClockStatistics.setSiteId(site.getId());
siteClockStatistics.setSiteName(site.getSiteName()); siteClockStatistics.setSiteName(site.getSiteName());
@ -126,6 +129,7 @@ public class ClockService implements IClockService {
/** /**
* 获取场所的二维码 * 获取场所的二维码
*
* @param params * @param params
* @return * @return
*/ */
@ -135,7 +139,7 @@ public class ClockService implements IClockService {
JourneyDto.CreateQRCode createQRCode = params.getParam(); JourneyDto.CreateQRCode createQRCode = params.getParam();
//根据id查找场馆信息 //根据id查找场馆信息
Site site = siteDao.selectByPrimaryKey(createQRCode.getId()); Site site = siteDao.selectByPrimaryKey(createQRCode.getId());
if(ObjectUtil.isNull(site)){ if (ObjectUtil.isNull(site)) {
throw new BaseException(CodeEnum.NOT_SITE); throw new BaseException(CodeEnum.NOT_SITE);
} }
//查询已生成的二维码 //查询已生成的二维码
@ -144,9 +148,9 @@ public class ClockService implements IClockService {
.andOutOrInEqualTo((byte) createQRCode.getType()); .andOutOrInEqualTo((byte) createQRCode.getType());
List<SiteQrcode> siteQrcodeList = siteQrcodeDao.selectByExample(siteQrcodeExample); List<SiteQrcode> siteQrcodeList = siteQrcodeDao.selectByExample(siteQrcodeExample);
//如果有,直接返回 //如果有,直接返回
if(CollectionUtil.isNotEmpty(siteQrcodeList)){ if (CollectionUtil.isNotEmpty(siteQrcodeList)) {
qrcodePath = siteQrcodeList.get(0).getQrcodePath(); qrcodePath = siteQrcodeList.get(0).getQrcodePath();
}else { } else {
//否则新加一条 //否则新加一条
//添加场所二维码记录 //添加场所二维码记录
SiteQrcode siteQrcode = new SiteQrcode(); SiteQrcode siteQrcode = new SiteQrcode();
@ -156,9 +160,9 @@ public class ClockService implements IClockService {
//生成二维码 //生成二维码
String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
String path = WebConstant.UPLOAD_PATH_BASE+fileName; String path = WebConstant.UPLOAD_PATH_BASE + fileName;
WxXcxUtil.getWxCode(WebConstant.QRCODE_SITE WxXcxUtil.getWxCode(WebConstant.QRCODE_SITE
,"d="+siteQrcode.getId()+"&t="+createQRCode.getType(),null,path); , "d=" + siteQrcode.getId() + "&t=" + createQRCode.getType(), null, path);
qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + fileName; qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + fileName;
siteQrcode.setQrcodePath(qrcodePath); siteQrcode.setQrcodePath(qrcodePath);
//添加数据库 //添加数据库
@ -186,20 +190,21 @@ public class ClockService implements IClockService {
@Override @Override
public ClockVo.SiteInfo getSiteInfoById(Long siteQrcodeId) { public ClockVo.SiteInfo getSiteInfoById(Long siteQrcodeId) {
SiteQrcode siteQrcode = siteQrcodeDao.selectByPrimaryKey(siteQrcodeId); SiteQrcode siteQrcode = siteQrcodeDao.selectByPrimaryKey(siteQrcodeId);
Site site = new Site(); if (ObjectUtil.isNull(siteQrcode)) {
if(ObjectUtil.isNotNull(siteQrcode)) { throw new BaseException(CodeEnum.NOT_SITE);
site = siteDao.selectByPrimaryKey(siteQrcode.getSiteId());
} }
ClockVo.SiteInfo siteInfo = null; Site site = siteDao.selectByPrimaryKey(siteQrcode.getSiteId());
if(ObjectUtil.isNotNull(site)) { if (ObjectUtil.isNull(site)) {
siteInfo = new ClockVo.SiteInfo(); throw new BaseException(CodeEnum.NOT_SITE);
siteInfo.setId(site.getId());
siteInfo.setSiteCode(site.getSiteCode());
siteInfo.setSiteName(site.getSiteName());
siteInfo.setLongitude(site.getLongitude());
siteInfo.setLatitude(site.getLatitude());
siteInfo.setType(siteQrcode.getOutOrIn());
} }
ClockVo.SiteInfo siteInfo = new ClockVo.SiteInfo();
siteInfo.setId(site.getId());
siteInfo.setSiteCode(site.getSiteCode());
siteInfo.setSiteName(site.getSiteName());
siteInfo.setLongitude(site.getLongitude());
siteInfo.setLatitude(site.getLatitude());
siteInfo.setType(siteQrcode.getOutOrIn());
return siteInfo; return siteInfo;
} }
} }

29
util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

@ -64,6 +64,7 @@ public class WxXcxUtil {
public static class WechatCode{ public static class WechatCode{
public String scene; public String scene;
public String page; public String page;
// public String path;
public Integer width; public Integer width;
public Boolean auto_color; public Boolean auto_color;
public LineColor line_color; public LineColor line_color;
@ -74,6 +75,14 @@ public class WxXcxUtil {
public String g; public String g;
public String b; public String b;
} }
public static class WechatCodeA{
public String path;
public Integer width;
public Boolean auto_color;
public LineColor line_color;
public Boolean is_hyaline;
}
/** /**
* Prepare pay * Prepare pay
*/ */
@ -231,6 +240,7 @@ public class WxXcxUtil {
WechatCode wechatCode = new WechatCode(); WechatCode wechatCode = new WechatCode();
wechatCode.page = page; wechatCode.page = page;
wechatCode.scene = scene; wechatCode.scene = scene;
// wechatCode.path = page+"?"+scene;
wechatCode.line_color = color; wechatCode.line_color = color;
@ -239,6 +249,25 @@ public class WxXcxUtil {
HttpsUtil.httpsRequest(url,"POST",postStr,path); HttpsUtil.httpsRequest(url,"POST",postStr,path);
} }
// /**
// * 获取小程序二维码/小程序码
// * @return
// * @throws Exception
// */
// public static void getWxCodeTest(String page,String scene,LineColor color,String path) throws Exception {
// String url = String.format(URL_GET_WX_CODE_C, WxGzhUtil.getAccessToken());
//
// WechatCodeA wechatCodeA = new WechatCodeA();
// wechatCodeA.path = page;
//// wechatCode.path = page+"?"+scene;
//
//// WechatCodeA.line_color = color;
//
// String postStr = JacksonUtil.beanToJson(wechatCodeA);
// System.out.println(postStr);
// HttpsUtil.httpsRequest(url,"POST",postStr,path);
// }
/** /**
* 统一下单 * 统一下单
*/ */

Loading…
Cancel
Save