|
|
|
@ -17,7 +17,6 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
@ -64,6 +63,11 @@ public class DeptMaCodeServiceImpl extends BaseServiceImpl<DeptMaCodeDao, DeptMa |
|
|
|
@Autowired |
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* 小程序首页 |
|
|
|
*/ |
|
|
|
private static String MA_FRONT_PAGE_URL = "pages/index/index"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<DeptMaCodeDTO> page(Map<String, Object> params) { |
|
|
|
String leaderFlag = (String) params.get("leaderFlag"); |
|
|
|
@ -143,31 +147,10 @@ public class DeptMaCodeServiceImpl extends BaseServiceImpl<DeptMaCodeDao, DeptMa |
|
|
|
if (CollUtil.isEmpty(gridIdList)) { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
String page = "pages/index/index"; |
|
|
|
|
|
|
|
Result<String> ossResult; |
|
|
|
File wxaCodeUnlimit; |
|
|
|
UploadToOssDTO uploadDto; |
|
|
|
|
|
|
|
DeptMaCodeEntity entity; |
|
|
|
WxMaQrcodeService qrcodeService = wxMaServiceUtils.normalWxMaService().getQrcodeService(); |
|
|
|
for (Long gridId : gridIdList) { |
|
|
|
try { |
|
|
|
wxaCodeUnlimit = qrcodeService.createWxaCodeUnlimit(String.valueOf(gridId), page); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
log.error("->initDeptMaCode::createWxaCodeUnlimit error::deptId={}", gridId); |
|
|
|
continue; |
|
|
|
} |
|
|
|
uploadDto = new UploadToOssDTO(); |
|
|
|
uploadDto.setFileByte(this.fileToByteArray(wxaCodeUnlimit)); |
|
|
|
uploadDto.setFileName(wxaCodeUnlimit.getName()); |
|
|
|
ossResult = ossFeignClient.uploadFile(uploadDto); |
|
|
|
if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { |
|
|
|
log.error("->initDeptMaCode::oss uploadFile error::deptId={}", gridId); |
|
|
|
continue; |
|
|
|
} |
|
|
|
entity = new DeptMaCodeEntity(); |
|
|
|
entity.setCodeUrl(ossResult.getData()); |
|
|
|
entity.setCodeUrl(this.createMaCode(String.valueOf(gridId), MA_FRONT_PAGE_URL)); |
|
|
|
entity.setGridId(gridId); |
|
|
|
this.baseDao.insert(entity); |
|
|
|
} |
|
|
|
@ -177,7 +160,7 @@ public class DeptMaCodeServiceImpl extends BaseServiceImpl<DeptMaCodeDao, DeptMa |
|
|
|
@Override |
|
|
|
public Result createDeptMaCode(String gridId) { |
|
|
|
DeptMaCodeEntity entity = new DeptMaCodeEntity(); |
|
|
|
entity.setCodeUrl(this.createMaCode(gridId, "pages/index/index")); |
|
|
|
entity.setCodeUrl(this.createMaCode(gridId, MA_FRONT_PAGE_URL)); |
|
|
|
entity.setGridId(Long.parseLong(gridId)); |
|
|
|
entity.setLeaderFlag(YesOrNoEnum.NO.value()); |
|
|
|
this.baseDao.insert(entity); |
|
|
|
@ -193,7 +176,7 @@ public class DeptMaCodeServiceImpl extends BaseServiceImpl<DeptMaCodeDao, DeptMa |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
DeptMaCodeEntity entity = new DeptMaCodeEntity(); |
|
|
|
entity.setCodeUrl(this.createMaCode("gridLeader", "pages/index/index")); |
|
|
|
entity.setCodeUrl(this.createMaCode("gridLeader", MA_FRONT_PAGE_URL)); |
|
|
|
entity.setLeaderFlag(YesOrNoEnum.YES.value()); |
|
|
|
this.baseDao.insert(entity); |
|
|
|
return new Result(); |
|
|
|
@ -211,7 +194,8 @@ public class DeptMaCodeServiceImpl extends BaseServiceImpl<DeptMaCodeDao, DeptMa |
|
|
|
private String createMaCode(String param, String pageUrl) { |
|
|
|
File wxaCodeUnlimit; |
|
|
|
try { |
|
|
|
wxaCodeUnlimit = wxMaServiceUtils.normalWxMaService().getQrcodeService().createWxaCodeUnlimit(param, pageUrl); |
|
|
|
wxaCodeUnlimit = wxMaServiceUtils.normalWxMaService().getQrcodeService() |
|
|
|
.createWxaCodeUnlimit(param, pageUrl, 1280, true, null, false); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
throw new RenException("请求微信接口失败"); |
|
|
|
} |
|
|
|
|