server/platform/src/main/java/com/doumee/api/business/LocksController.java
@@ -8,6 +8,7 @@ import com.doumee.core.model.ApiResponse; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.dao.business.model.Bikes; import com.doumee.dao.business.model.Locks; import com.doumee.service.business.DeviceService; import com.doumee.service.business.LocksService; @@ -119,4 +120,9 @@ locks.setSiteId(siteId); return ApiResponse.success(locksService.findLockBase64List(locks)); } @ApiOperation("获取电车小程序二维码") @GetMapping("/findBikeBase") public ApiResponse<Bikes> findBikeBase(@RequestParam String bikeId){ return ApiResponse.success(locksService.findBikeBase(bikeId)); } } server/services/src/main/java/com/doumee/core/constants/Constants.java
@@ -52,6 +52,7 @@ public static final String HEART_TIME_EXPIRE_TIME ="HEART_TIME_EXPIRE_TIME" ; public static final String PARK_LAT_LNG_LIST = "PARK_LAT_LNG_LIST"; public static final String LOW_BIKE_VOLTAGE ="LOW_BIKE_VOLTAGE" ; public static final String EBIKE_PREFIX ="ebike-" ; public static String REDIS_DEBUG_STR="test_"; public static final String AD = "AD"; public static String REPAIR = "REPAIR"; server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
@@ -11,6 +11,7 @@ import com.doumee.core.utils.ImageDesignerUtil; import com.doumee.dao.business.RefundMapper; import com.doumee.dao.business.TransactionsMapper; import com.doumee.dao.business.model.Bikes; import com.doumee.dao.business.model.Locks; import com.doumee.dao.business.model.Refund; import com.doumee.dao.business.model.Transactions; @@ -290,6 +291,41 @@ e.printStackTrace(); } } public void generateEbikeWXMiniCode(Bikes bikes, String token, String prePath, String path){ if(Objects.isNull(token)){ return; } String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+ token; String release = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.MINI_PROGRAMME_REALEASE).getCode(); //生成图片上传OSS Map<String,Object> body = new HashMap<>(); // 场景码,与前端约定,最终是需要前端解析 body.put("scene", Constants.EBIKE_PREFIX +bikes.getCode() ); // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。 // body.put("env_version", "release"); body.put("env_version", StringUtils.defaultString(release, "release")); // 透明,根据你的场景自行设置body参数 body.put("is_hyaline", false); body.put("check_path", false); body.put("width", 290); body.put("page","pages/index/index"); log.info("=========================================="+url+"\n"+JSONObject.toJSONString(body)); try { InputStream inputStream =HttpsUtil.postJson(url,JSONObject.toJSONString(body));; if (inputStream !=null) { String nowDate = DateUtil.getNowShortDate(); String name =Constants.EBIKE_PREFIX+bikes.getCode()+"-"+nowDate+".png"; String fileName =prePath+path+"/"+name; // File file = new File(prePath+path,locks.getSiteId()+"-"+locks.getCode()+"-"+nowDate+".png"); // FileUtils.copyInputStreamToFile(inputStream,file); if(ImageDesignerUtil.graphicsGenerationIs(bikes.getCode(),inputStream,fileName)){ bikes.setImgurl(name); } } } catch (Exception e) { e.printStackTrace(); } } /** * 生成小程序码 * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html server/services/src/main/java/com/doumee/dao/business/model/Bikes.java
@@ -129,6 +129,10 @@ @ApiModelProperty(value = "是否低电量 0否 1是") @TableField(exist = false ) private Integer lowVoltage; @ApiModelProperty(value = "强制还车结果备注") @ExcelColumn(name="强制还车结果备注") private String forceBackInfo; @ApiModelProperty(value = "小程序码") private String imgurl; } server/services/src/main/java/com/doumee/service/business/LocksService.java
@@ -2,6 +2,7 @@ import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.dao.business.model.Bikes; import com.doumee.dao.business.model.Locks; import javax.servlet.http.HttpServletResponse; @@ -107,4 +108,6 @@ long count(Locks locks); void exportImages(String siteid, HttpServletResponse response); Bikes findBikeBase(String bikeId); } server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
@@ -3,6 +3,7 @@ import com.doumee.core.exception.BusinessException; import com.doumee.core.model.LoginUserInfo; import com.doumee.core.wx.WxMiniConfig; import com.doumee.dao.business.BikesMapper; import com.google.common.collect.Lists; import com.doumee.biz.system.SystemDictDataBiz; @@ -67,6 +68,8 @@ @Autowired private SystemDictDataBiz systemDictDataBiz; @Autowired private BikesMapper bikesMapper; @Override public String create(Locks locks) { @@ -155,6 +158,36 @@ } return new ArrayList<>(); } @Override public Bikes findBikeBase(String bikeId) { Locks re = new Locks(); LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); String fullPath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode() ; Bikes bikes = bikesMapper.selectById(bikeId); if(bikes == null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } String code = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); String prePath = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.IMG_DIR).getCode(); // 检查是否有图片信息没有更新保存图片 if (StringUtils.isBlank(bikes.getImgurl())){ try { wxMiniUtilService.generateEbikeWXMiniCode(bikes, WxMiniConfig.wxMaService.getAccessToken(),prePath,code); }catch (Exception e){ } if (StringUtils.isNotBlank(bikes.getImgurl())){ bikes.setEditor(loginUserInfo.getId()); bikes.setEditDate(new Date()); bikesMapper.updateById(bikes); } } if (StringUtils.isNotBlank(bikes.getImgurl())){ bikes.setImgurl(fullPath+bikes.getInfo()); } return bikes; } @Override server/services/src/main/java/com/doumee/service/business/impl/MemberRidesServiceImpl.java
@@ -392,14 +392,14 @@ bike.setLastBackDate(model.getRentDate()); bike.setStatus(Constants.ZERO); bike.setType(Constants.ZERO); bike.setInfo("强制还车绑定"); bike.setForceBackInfo("强制还车绑定"); bikesMapper.insert(bike); } }else{ //如果是电车,请求web端接口关闭车辆信息 bike = sendCloseElecBikeRequest(memberRides.getBikeCode(),Constants.ONE); } logInfo = bike!=null?bike.getInfo():null; logInfo = bike!=null?bike.getForceBackInfo():null; Integer freeRentTime = Integer.valueOf(collect.get(Constants.FREE_RENT_TIME).getCode()); Integer rideTime = DateUtil.betweenMin(model.getRentDate(), update.getBackDate()); //计算骑行计费时长 @@ -446,7 +446,7 @@ if(bike == null){ return null; } bike.setInfo("强制还车关闭车锁失败!"); bike.setForceBackInfo("强制还车关闭车锁失败!"); if(StringUtils.isNotBlank(bike.getDeviceSn())){ try { //请求地址 @@ -458,15 +458,15 @@ JSONObject json = JSONObject.parseObject(res); if(json.get("code").equals("200")){ //发起指令成功 bike.setInfo("强制还车关闭车锁成功!"); bike.setForceBackInfo("强制还车关闭车锁成功!"); }else{ bike.setInfo("强制还车关闭车锁失败!"+json.get("msg")); bike.setForceBackInfo("强制还车关闭车锁失败!"+json.get("msg")); } }catch (Exception e){ e.printStackTrace(); } }else{ bike.setInfo("强制还车关闭车锁失败,未绑定控制器sn!"); bike.setForceBackInfo("强制还车关闭车锁失败,未绑定控制器sn!"); } bikesMapper.updateById(bike); return bike;