|
@@ -1,5 +1,6 @@
|
|
|
package com.minpay.mt.machine.action;
|
|
|
|
|
|
+import com.itextpdf.text.pdf.qrcode.WriterException;
|
|
|
import com.min.util.CommonUtil;
|
|
|
import com.minpay.common.bean.User;
|
|
|
import com.minpay.common.constant.Constant;
|
|
@@ -7,6 +8,7 @@ import com.minpay.common.format.IFormatService;
|
|
|
import com.minpay.common.service.IPropertiesService;
|
|
|
import com.minpay.common.service.IPublicService;
|
|
|
import com.minpay.common.util.DateUtil;
|
|
|
+import com.minpay.common.util.UpLoadFile;
|
|
|
import com.minpay.db.table.mapper.VmEquipmentInfMapper;
|
|
|
import com.minpay.db.table.mapper.VmProEquRelMapper;
|
|
|
import com.minpay.db.table.model.VmEquipmentInf;
|
|
@@ -14,6 +16,7 @@ import com.minpay.db.table.model.VmEquipmentInfExample;
|
|
|
import com.minpay.db.table.model.VmProEquRel;
|
|
|
import com.minpay.db.table.model.VmProEquRelExample;
|
|
|
import com.minpay.db.table.own.mapper.MachineManageMapper;
|
|
|
+import com.minpay.huicai.util.EquCodeCreateUtil;
|
|
|
import com.startup.minpay.frame.business.IMINAction;
|
|
|
import com.startup.minpay.frame.business.res.MINActionResult;
|
|
|
import com.startup.minpay.frame.constant.IMINBusinessConstant;
|
|
@@ -28,6 +31,7 @@ import com.startup.minpay.frame.target.MINAction;
|
|
|
import com.startup.minpay.frame.target.MINComponent;
|
|
|
import com.startup.minpay.frame.target.MINParam;
|
|
|
|
|
|
+import java.io.*;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -102,6 +106,8 @@ public class MachineManageAction implements IMINAction {
|
|
|
|
|
|
/**一键设置商品价格*/
|
|
|
public final static String EDIT_PROEQUREL_PRICE = "editProEquRelPrice";
|
|
|
+ /** 生成包含字符串信息的二维码图片**/
|
|
|
+ public static final String CREATE_QRCODE = "createQrCode";
|
|
|
private boolean contains;
|
|
|
|
|
|
|
|
@@ -1183,4 +1189,63 @@ public class MachineManageAction implements IMINAction {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 生成包含字符串信息的二维码图片
|
|
|
+ * @param flash 是否刷新
|
|
|
+ */
|
|
|
+ @MINAction(value = CREATE_QRCODE, transaction = IMINTransactionEnum.CMT)
|
|
|
+ public static MINActionResult createQrCode(
|
|
|
+ @MINParam(key = "flash") String flash,
|
|
|
+ @MINParam(key = "equId") String equId,
|
|
|
+ MINSession session)throws MINBusinessException, FileNotFoundException, WriterException, IOException {
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+ //获取当前用户信息
|
|
|
+ User u = session.getUser();
|
|
|
+ //获取用户id
|
|
|
+ String userId = u.getBranchId();
|
|
|
+ //刷新,生成
|
|
|
+ //开发环境修改配置
|
|
|
+ String basePath = "/home/images/"+ userId+".jpg"; //与nginx配置相同
|
|
|
+ String os = System.getProperty("os.name");
|
|
|
+ if(os.toLowerCase().startsWith("win")){
|
|
|
+ System.out.println(os + " can't gunzip");
|
|
|
+ basePath = "D:/images/"+ userId+".jpg"; //与nginx配置相同
|
|
|
+ }
|
|
|
+
|
|
|
+ File file = new File(basePath);
|
|
|
+ //获取父目录
|
|
|
+ File fileParent = file.getParentFile();
|
|
|
+ //判断是否存在
|
|
|
+ if (!fileParent.exists()) {
|
|
|
+ fileParent.mkdirs();
|
|
|
+ }
|
|
|
+ //获取渠道号
|
|
|
+ String channel = "V01";
|
|
|
+ String address = Service.lookup(IPropertiesService.class)
|
|
|
+ .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();// 为nginx根路径
|
|
|
+ // 加密客户号
|
|
|
+ OutputStream outputStream = new FileOutputStream(file);
|
|
|
+ String serviceUrl = Service.lookup(IPropertiesService.class)
|
|
|
+ .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();
|
|
|
+ serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(equId));
|
|
|
+ //String urlString = URLEncoder.encode(, "GBK");
|
|
|
+
|
|
|
+ // 生成二维码图片到本地
|
|
|
+ try {
|
|
|
+ EquCodeCreateUtil.createQrCode(outputStream,serviceUrl,900,"JPEG");
|
|
|
+ } catch (com.google.zxing.WriterException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ outputStream.close();
|
|
|
+ // 上传图片到服务器
|
|
|
+ InputStream inputSteam = new FileInputStream(file);
|
|
|
+ String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
|
|
|
+
|
|
|
+ inputSteam.close();
|
|
|
+ // 删除本地图片
|
|
|
+ file.delete();
|
|
|
+ res.set("url", url);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|