Commit 1da02a7f by zhengxj

finish 技工管理列表查询条件整合 on 20191009

by zhengxj 

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24150 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 25c5dd07
...@@ -321,26 +321,32 @@ public class WechatUtils { ...@@ -321,26 +321,32 @@ public class WechatUtils {
} }
@SuppressWarnings({ "rawtypes", "unchecked", }) @SuppressWarnings({ "rawtypes", "unchecked", })
public Map<String, Object> getwxacodeunlimit(String sceneStr) throws Exception { public Map<String, String> getWxacodeUnlimit(String sceneStr) {
// { Map<String, String> returnMap = new HashMap<>(4);
// "scene": "a=1" returnMap.put("code", "500");
// } String prefix = "data:image/png;base64,";
String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID); String appid = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_APPID);
String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET); String secret = PropertiesUtil.getProperty(Constants.WECHAT_MINI_SERVICE_SECRET);
String page = "pages/index"; String page = "pages/index";
String accessToken = this.getWechatToken(appid, secret); String accessToken = null;
try {
accessToken = this.getWechatToken(appid, secret);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 二维码存放路径 // 二维码存放路径
// String filePath = "C:/Users/wangqiulin/Desktop/1.png"; // String filePath = "C:/Users/wangqiulin/Desktop/1.png";
String filePath = "F:/test/" + System.currentTimeMillis() + ".png"; // String filePath = "F:/test/" + System.currentTimeMillis() + ".png";
RestTemplate rest = new RestTemplate(); RestTemplate rest = new RestTemplate();
InputStream inputStream = null; // InputStream inputStream = null;
OutputStream outputStream = null; // OutputStream outputStream = null;
try {
String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken); String url = this.GET_WXACODE_UNLIMIT.replace("$ACCESS_TOKEN$", accessToken);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("scene", sceneStr); param.put("scene", sceneStr);
param.put("page", page); // param.put("page", page);
param.put("width", 430); param.put("width", 430);
param.put("auto_color", false); param.put("auto_color", false);
Map<String, Object> line_color = new HashMap<>(); Map<String, Object> line_color = new HashMap<>();
...@@ -356,41 +362,49 @@ public class WechatUtils { ...@@ -356,41 +362,49 @@ public class WechatUtils {
logger.info("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody()); logger.info("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody());
byte[] result = entity.getBody(); byte[] result = entity.getBody();
String base64String = new String(result).replaceAll("\n", ""); String img = Base64.encodeBase64String(result);
logger.info(base64String);
logger.info(Base64.encodeBase64String(result)); if (img.startsWith("/9j/")) {
inputStream = new ByteArrayInputStream(result); // 二维码生成成功
logger.info(Base64.encodeBase64String(result));
returnMap.put("img", prefix + img);
returnMap.put("code", "200");
File file = new File(filePath);
if (!file.exists()) {
file.createNewFile();
}
outputStream = new FileOutputStream(file);
int len = 0;
byte[] buf = new byte[1024];
while ((len = inputStream.read(buf, 0, 1024)) != -1) {
outputStream.write(buf, 0, len);
}
outputStream.flush();
} catch (Exception e) {
logger.error("调用小程序生成微信永久小程序码URL接口异常", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
}
return null; // inputStream = new ByteArrayInputStream(result);
//
// File file = new File(filePath);
// if (!file.exists()) {
// file.createNewFile();
// }
// outputStream = new FileOutputStream(file);
// int len = 0;
// byte[] buf = new byte[1024];
// while ((len = inputStream.read(buf, 0, 1024)) != -1) {
// outputStream.write(buf, 0, len);
// }
// outputStream.flush();
logger.error("调用小程序生成微信永久小程序码URL接口异常");
// finally {
// if (inputStream != null) {
// try {
// inputStream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// if (outputStream != null) {
// try {
// outputStream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
return returnMap;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package com.glsx.usercenter.controller; package com.glsx.usercenter.controller;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -62,4 +63,11 @@ public class MechanicController extends BaseReportController { ...@@ -62,4 +63,11 @@ public class MechanicController extends BaseReportController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null);
} }
@PostMapping("/verify")
public ResultObject verify(Integer id, String bankCarkImgUrl, String IDCardFrontImgUrl, String IDCardBackImgUrl) {
// TODO 调用腾讯的api,
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null);
}
} }
...@@ -1267,12 +1267,14 @@ public class UserController extends BaseController { ...@@ -1267,12 +1267,14 @@ public class UserController extends BaseController {
*/ */
@RequestMapping(value = "/getWxacodeUnlimit", method = { RequestMethod.POST }) @RequestMapping(value = "/getWxacodeUnlimit", method = { RequestMethod.POST })
public ResultObject getWxacodeUnlimit(String spId, String spName) { public ResultObject getWxacodeUnlimit(String spId, String spName) {
String sceneStr = "13456";
try { String sceneStr = "spId=" + spId + "&" + "spName=" + spName;
wechatUtils.getwxacodeunlimit(sceneStr);
} catch (Exception e) { Map<String, String> map = wechatUtils.getWxacodeUnlimit(sceneStr);
throw BusinessException.create("服务商二维码生成出错!"); if (map.containsKey("img")) {
// TODO 更新二维码
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), map.get("img"));
} }
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return new ResultObject(ResultCodeEnum.FAIL.getCode(), "生成服务商二维码出错!");
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!