|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
|
package com.epmet.controller; |
|
|
package com.epmet.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; |
|
|
import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.annotation.RequirePermission; |
|
|
import com.epmet.commons.tools.annotation.RequirePermission; |
|
@ -34,11 +35,20 @@ import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
import com.epmet.send.SendMqMsgUtil; |
|
|
import com.epmet.send.SendMqMsgUtil; |
|
|
import com.epmet.service.AgencyService; |
|
|
import com.epmet.service.AgencyService; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
|
|
|
import com.google.zxing.BarcodeFormat; |
|
|
|
|
|
import com.google.zxing.EncodeHintType; |
|
|
|
|
|
import com.google.zxing.MultiFormatWriter; |
|
|
|
|
|
import com.google.zxing.WriterException; |
|
|
|
|
|
import com.google.zxing.client.j2se.MatrixToImageWriter; |
|
|
|
|
|
import com.google.zxing.common.BitMatrix; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.nio.file.FileSystems; |
|
|
|
|
|
import java.nio.file.Path; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
@ -360,4 +370,48 @@ public class AgencyController { |
|
|
return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type)); |
|
|
return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("qr") |
|
|
|
|
|
public void qr(){ |
|
|
|
|
|
try { |
|
|
|
|
|
write(); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (WriterException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void write() throws IOException, WriterException { |
|
|
|
|
|
String filePath = "/Volumes/self"; |
|
|
|
|
|
String fileName = "qr.png"; |
|
|
|
|
|
//二维码内容场景一:json数据
|
|
|
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
|
|
json.put("baidu","http://www.baidu.com");//二维码一般就是存储链接
|
|
|
|
|
|
// json.put("author", "lzz");//还可存储值(员工工号,员工姓名,年会二维码门票)
|
|
|
|
|
|
String content = json.toJSONString();//json 内容
|
|
|
|
|
|
//二维码内容场景二:直接某个超链接
|
|
|
|
|
|
// content="http://www.baidu.com";//直接某个超链接
|
|
|
|
|
|
int width = 200; // 图像宽度
|
|
|
|
|
|
int height = 200; // 图像高度
|
|
|
|
|
|
String format = "png";// 图像类型
|
|
|
|
|
|
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); |
|
|
|
|
|
|
|
|
|
|
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
|
|
|
|
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, |
|
|
|
|
|
BarcodeFormat.QR_CODE, width, height, hints);// 生成矩阵
|
|
|
|
|
|
Path path = FileSystems.getDefault().getPath(filePath, fileName); |
|
|
|
|
|
MatrixToImageWriter.writeToPath(bitMatrix, format, path);// 输出图像
|
|
|
|
|
|
System.out.println("输出成功."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
try { |
|
|
|
|
|
write(); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (WriterException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |