zhizhi wu 5 years ago
parent
commit
6e21d78fc8
  1. 11
      health/src/main/java/com/ccsens/health/api/ClockController.java
  2. 6
      health/src/main/java/com/ccsens/health/api/DebugController.java
  3. 2
      health/src/main/java/com/ccsens/health/api/UserController.java
  4. 7
      health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java
  5. 2
      health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java
  6. 2
      health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java
  7. 34
      health/src/main/java/com/ccsens/health/service/ClockService.java
  8. 4
      health/src/main/java/com/ccsens/health/service/IClockService.java
  9. 6
      util/src/main/java/com/ccsens/util/HttpsUtil.java
  10. 13
      util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

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

@ -58,7 +58,7 @@ public class ClockController {
}
@MustLogin
@ApiOperation(value = "获取所有场信息", notes = "")
@ApiOperation(value = "获取所有场信息", notes = "")
@RequestMapping(value = "siteInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<Site>> getAllSiteInfo() throws Exception {
log.info("获取所有场景信息");
@ -66,6 +66,15 @@ public class ClockController {
return JsonResponse.newInstance().ok(siteList);
}
@MustLogin
@ApiOperation(value = "通过二维码内的id获取场所的信息", notes = "")
@RequestMapping(value = "site", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ClockVo.SiteInfo> getSiteInfoById(@ApiParam @Validated @RequestBody QueryDto<ClockDto.CreateQRCodeId> params) throws Exception {
log.info("获取所有场景信息");
ClockVo.SiteInfo siteInfo = clockService.getSiteInfoById(params.getParam().getId());
return JsonResponse.newInstance().ok(siteInfo);
}
@MustLogin
@ApiOperation(value = "生成场所二维码", notes = "")
@RequestMapping(value = "qrCode", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})

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

@ -32,8 +32,12 @@ public class DebugController {
})
@RequestMapping(value="qrcode",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public JsonResponse qrcode(HttpServletRequest request) throws Exception {
WxXcxUtil.LineColor color = new WxXcxUtil.LineColor();
color.r = "129";
color.g = "216";
color.b = "65";
WxXcxUtil.getWxCode("pages/sign/sign"
,"scene=1011&siteName=TSG","/home/cloud/tall/uploads/112233.png");
,"d=1235756988936359936&t=0",color,"/home/cloud/tall/uploads/qrCode/2020-03-07/1583572671726.png");
return JsonResponse.newInstance().ok("完成");
}
}

2
health/src/main/java/com/ccsens/health/api/UserController.java

@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Api(tags = "个人信息相关" , description = "")
@RestController
@RequestMapping("/users")
@RequestMapping("/")
public class UserController {
@Autowired
private IUserService userService;

7
health/src/main/java/com/ccsens/health/bean/dto/ClockDto.java

@ -14,4 +14,11 @@ public class ClockDto {
@ApiModelProperty("场景二维码id")
private Long siteId;
}
@Data
@ApiModel("生成场所二维码")
public static class CreateQRCodeId{
@ApiModelProperty("场所id")
private Long id;
}
}

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

@ -52,4 +52,6 @@ public class JourneyDto {
@ApiModelProperty("0进 1出")
private int type;
}
}

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

@ -53,5 +53,7 @@ public class ClockVo {
private BigDecimal longitude;
@ApiModelProperty("纬度")
private BigDecimal latitude;
@ApiModelProperty("进还是出 0进 1出")
private int type;
}
}

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

@ -20,6 +20,7 @@ import com.ccsens.util.QrCodeUtil;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -127,7 +128,7 @@ public class ClockService implements IClockService {
* @return
*/
@Override
public String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws IOException {
public String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws Exception {
String qrcodePath = null;
JourneyDto.CreateQRCode createQRCode = params.getParam();
//根据id查找场馆信息
@ -150,14 +151,13 @@ public class ClockService implements IClockService {
siteQrcode.setId(snowflake.nextId());
siteQrcode.setSiteId(createQRCode.getId());
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);
qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + path;
String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
String path = WebConstant.UPLOAD_PATH_BASE+fileName;
WxXcxUtil.getWxCode(WebConstant.QRCODE_SITE
,"d="+siteQrcode.getId()+"&t="+createQRCode.getType(),null,path);
qrcodePath = WebConstant.TEST_URL_BASE_HEALTH + fileName;
siteQrcode.setQrcodePath(qrcodePath);
//添加数据库
siteQrcodeDao.insertSelective(siteQrcode);
@ -174,4 +174,22 @@ public class ClockService implements IClockService {
List<Site> siteList = siteDao.selectByExample(siteExample);
return siteList;
}
@Override
public ClockVo.SiteInfo getSiteInfoById(Long siteQrcodeId) {
SiteQrcode siteQrcode = siteQrcodeDao.selectByPrimaryKey(siteQrcodeId);
Site site = new Site();
if(ObjectUtil.isNotNull(siteQrcode)) {
site = siteDao.selectByPrimaryKey(siteQrcode.getId());
}
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;
}
}

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

@ -16,7 +16,9 @@ public interface IClockService {
List<ClockVo.SiteClockStatistics> getSiteClickStatistics(QueryDto<JourneyDto.StatisticsDate> params) throws Exception;
String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws IOException;
String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws Exception;
List<Site> getAllSiteInfo();
ClockVo.SiteInfo getSiteInfoById(Long id);
}

6
util/src/main/java/com/ccsens/util/HttpsUtil.java

@ -136,9 +136,13 @@ public class HttpsUtil {
}
// 从输入流读取返回内容
File file = new File(path);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
InputStream inputStream = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(inputStream);
OutputStream os = new FileOutputStream(new File(path));
OutputStream os = new FileOutputStream(file);
int len;
byte[] arr = new byte[1024];
while ((len = bis.read(arr)) != -1)

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

@ -66,10 +66,14 @@ public class WxXcxUtil {
public String page;
public Integer width;
public Boolean auto_color;
public Object line_color;
public LineColor line_color;
public Boolean is_hyaline;
}
public static class LineColor{
public String r;
public String g;
public String b;
}
/**
* Prepare pay
*/
@ -221,13 +225,14 @@ public class WxXcxUtil {
* @return
* @throws Exception
*/
public static void getWxCode(String page,String scene,String path) throws Exception {
public static void getWxCode(String page,String scene,LineColor color,String path) throws Exception {
String url = String.format(URL_GET_WX_CODE_B, WxGzhUtil.getAccessToken());
WechatCode wechatCode = new WechatCode();
wechatCode.page = page;
wechatCode.scene = scene;
wechatCode.line_color = "#800080";
wechatCode.line_color = color;
String postStr = JacksonUtil.beanToJson(wechatCode);
System.out.println(postStr);

Loading…
Cancel
Save