|
@@ -1,18 +1,35 @@
|
|
package com.bofeng.wx.controller;
|
|
package com.bofeng.wx.controller;
|
|
|
|
|
|
|
|
+import com.bofeng.dao.UptownDoorMapper;
|
|
import com.bofeng.entity.SysUptownHouse;
|
|
import com.bofeng.entity.SysUptownHouse;
|
|
|
|
+import com.bofeng.entity.UptownDoor;
|
|
import com.bofeng.excel.ExcelUtils;
|
|
import com.bofeng.excel.ExcelUtils;
|
|
import com.bofeng.service.SweepCodeService;
|
|
import com.bofeng.service.SweepCodeService;
|
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
|
+import com.google.zxing.MultiFormatWriter;
|
|
|
|
+import com.google.zxing.WriterException;
|
|
|
|
+import com.google.zxing.client.j2se.MatrixToImageConfig;
|
|
|
|
+import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
import com.yvan.Model;
|
|
import com.yvan.Model;
|
|
|
|
+import com.yvan.PageDb;
|
|
|
|
+import com.yvan.mvc.Pd;
|
|
import com.yvan.springmvc.HttpParameterParser;
|
|
import com.yvan.springmvc.HttpParameterParser;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.Cleanup;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.http.MediaType;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@Api("进出扫码后台信息")
|
|
@Api("进出扫码后台信息")
|
|
@@ -22,6 +39,8 @@ public class ScanAdminController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SweepCodeService sweepCodeService;
|
|
private SweepCodeService sweepCodeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UptownDoorMapper uptownDoorMapper;
|
|
|
|
|
|
@ApiOperation("出入查询")
|
|
@ApiOperation("出入查询")
|
|
@GetMapping("/whepi/sweepCode/selectCode")
|
|
@GetMapping("/whepi/sweepCode/selectCode")
|
|
@@ -39,5 +58,55 @@ public class ScanAdminController {
|
|
ExcelUtils.writeSheet(SysUptownHouse.class, sysUptownHouses).export(resp,"扫码导出");
|
|
ExcelUtils.writeSheet(SysUptownHouse.class, sysUptownHouses).export(resp,"扫码导出");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation("小区进出二维码")
|
|
|
|
+ @PostMapping("/whepi/qrImg/scanQrImg")
|
|
|
|
+ public Model<List<UptownDoor>> scanQrImg(HttpParameterParser parser, PageDb pagination) {
|
|
|
|
+ List<UptownDoor> list = uptownDoorMapper.getAllUptownDoor(pagination, parser.getMap());
|
|
|
|
+ for (UptownDoor door : list) {
|
|
|
|
+ door.setInImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=1");
|
|
|
|
+ door.setOutImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=2");
|
|
|
|
+ }
|
|
|
|
+ return Model.newSuccess(pagination, list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取code
|
|
|
|
+ private static final String oauth2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=";
|
|
|
|
+ private static final String moreUrl = "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
|
|
|
|
+ @Value("${yvan.wechat.appID}")
|
|
|
|
+ private String appId;
|
|
|
|
+ @Value("${yvan.wechat.domain}")
|
|
|
|
+ private String domain;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成进出门二维码
|
|
|
|
+ * @param doorId 小区大门ID
|
|
|
|
+ * @param inType 1进入;2外出
|
|
|
|
+ * @param response
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws WriterException
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/whepi/scan/scan_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
+ public void scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType,
|
|
|
|
+ HttpServletResponse response) throws IOException, WriterException {
|
|
|
|
+ @Cleanup ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
+ String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
|
|
|
|
+ BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
|
|
|
|
+ msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
|
|
|
|
+ MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成校园巡逻二维码
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws WriterException
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/whepi/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
+ public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
|
|
|
|
+ @Cleanup ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
+ String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
|
|
|
|
+ BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
|
|
|
|
+ msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
|
|
|
|
+ MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|