Commit 2b767dae by 高鹏

Merge branch 'zhuyajie' into 'master'

社群码导出

See merge request rays/pcloud-book!12
parents 259a1385 bd0fcc80
......@@ -298,4 +298,11 @@ public interface BookDao extends BaseDao<Book> {
* @return
*/
List<BookDto> listSimpleBookGroup4Adviser(Map<String, Object> paramMap);
/**
* 获取社群书列表(编辑)
* @param paramMap
* @return
*/
List<BookDto> listBookGroup4Adviser(Map<String, Object> paramMap);
}
......@@ -285,4 +285,9 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {
public List<BookDto> listSimpleBookGroup4Adviser(Map<String, Object> paramMap) {
return super.getSqlSession().selectList(getStatement("listSimpleBookGroup4Adviser"), paramMap);
}
@Override
public List<BookDto> listBookGroup4Adviser(Map<String, Object> paramMap) {
return super.getSqlSession().selectList(getStatement("listBookGroup4Adviser"),paramMap);
}
}
package com.pcloud.book.group.biz;
import java.util.List;
import java.util.Map;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.QrcodeNameAndProIdDTO;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import java.util.List;
import java.util.Map;
/**
* Description 社群书群二维码业务逻辑层接口
* Created by PENG on 2019/4/17.
......@@ -194,4 +196,10 @@ public interface BookGroupBiz {
* @Date:2019/5/30 16:36
*/
Boolean isHaveQrcode(Long bookId, Long channelId, Long adviserId);
/**
* 社群码导出
* @param paramMap
*/
void exportGroupQrcode4Adviser(Map<String, Object> paramMap, Long adviserId);
}
package com.pcloud.book.group.biz.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookDao;
......@@ -28,15 +18,23 @@ import com.pcloud.book.group.dto.QrcodeNameAndProIdDTO;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.biz.MessageBiz;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.core.dto.SendNotifyDto;
import com.pcloud.common.core.enums.NotifyOriginTypeEnum;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.entity.UploadResultInfo;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.zip.CompressUtils;
import com.pcloud.labelcenter.label.service.LabelService;
import com.pcloud.resourcecenter.product.dto.AddAppProductParamDTO;
import com.pcloud.resourcecenter.product.dto.UpdateAppProductParamDTO;
......@@ -45,14 +43,35 @@ import com.pcloud.resourcecenter.product.service.ProductService;
import com.pcloud.settlementcenter.record.service.SettlementService;
import com.pcloud.wechatgroup.group.service.GroupMemberService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
* Description 社群书群二维码业务逻辑层接口实现类
* Created by PENG on 2019/4/17.
*/
@Component("bookGroupBiz")
public class BookGroupBizImpl implements BookGroupBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(BookGroupBizImpl.class);
private final static String DEFAULT_PRODUCT_COVER_IMG = "https://oss.5rs.me/oss/uploadfe/png/1c5da08d2c9598a5f0b0252acb84d8b8.png";
private static final ExecutorService EXECUTOR_SINGLE_SERVICE = Executors.newSingleThreadExecutor();
@Value("${book.group.qrcode.domain}")
private String bookGroupQrcodeDomain;
......@@ -79,6 +98,9 @@ public class BookGroupBizImpl implements BookGroupBiz {
private GroupMemberService groupMemberService;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private MessageBiz messageBiz;
/**
* 创建社群书时生成群二维码
......@@ -469,4 +491,75 @@ public class BookGroupBizImpl implements BookGroupBiz {
return true;
}
}
@Override
public void exportGroupQrcode4Adviser(Map<String, Object> paramMap, Long adviserId) {
EXECUTOR_SINGLE_SERVICE.execute(() -> {
// 生成文件名
String fileName = "社群码导出_" + DateUtils.getShortDateStr();
Boolean isSuccess = true;
String zipUrl = "";
try {
Map<String, List<String[]>> zipFileMap = new HashMap<>();
List<String[]> qrcodePicUrls = new ArrayList<String[]>();
// 设置查询参数
List<BookDto> bookDtos = bookDao.listBookGroup4Adviser(paramMap);
if (ListUtils.isEmpty(bookDtos)) {
return;
}
Integer noName = 0;
for (BookDto bookDto : bookDtos) {
String bookName = null != bookDto.getBookName() ? StringUtil.addBracket(bookDto.getBookName()) : null;
String groupQrcodeName = bookDto.getGroupQrcodeName();
String qrcodeUrl = bookDto.getGroupQrcodeUrl() == null ? null : bookDto.getGroupQrcodeUrl().replace("oss.5rs.me", "file.5rs.me");
String qrcodeName;
if (!StringUtil.isEmpty(bookName)) {
qrcodeName = bookName;
if (!StringUtil.isEmpty(groupQrcodeName)) {
qrcodeName = qrcodeName + groupQrcodeName;
}
} else {
if (!StringUtil.isEmpty(groupQrcodeName)) {
qrcodeName = groupQrcodeName;
} else {
noName = noName + 1;
qrcodeName = "未命名" + noName;
}
}
// 加入二维码图片
String[] qrcodePicurl = {qrcodeName, qrcodeUrl};
qrcodePicUrls.add(qrcodePicurl);
}
zipFileMap.put(fileName, qrcodePicUrls);
UploadResultInfo zipUrlInfo = CompressUtils.zipByCatalog(zipFileMap, fileName);
zipUrl = zipUrlInfo != null ? zipUrlInfo.getUrl() : null;
} catch (Exception e) {
LOGGER.error("生成导出文件失败", e);
isSuccess = false;
}
// 发送消息
if (isSuccess) {
JSONObject content = new JSONObject();
content.put("commitTime", DateUtils.formatDate(new Date()));
content.put("type", "社群码导出");
SendNotifyDto sendNotifyDto = new SendNotifyDto();
sendNotifyDto.setCreatedTime(new Date());
sendNotifyDto.setFromId(adviserId);
sendNotifyDto.setToId(adviserId);
sendNotifyDto.setNotifyContent(content.toJSONString());
sendNotifyDto.setSystemCode(SystemCode.adviser.code);
sendNotifyDto.setTypeCode("qrcode_download");
sendNotifyDto.setResourceId(zipUrl);
sendNotifyDto.setFileName(fileName);
sendNotifyDto.setOriginType(NotifyOriginTypeEnum.BOOK_GROUP.value);
try {
messageBiz.sendLetter(sendNotifyDto);
} catch (Exception e) {
LOGGER.error("【站内信(消)】发送站内信.[sendLetter]:" + e.getMessage(), e);
}
}
});
}
}
......@@ -186,4 +186,32 @@ public interface BookGroupFacade {
@RequestMapping(value = "isSpecialAgent", method = RequestMethod.GET)
ResponseDto<Boolean> isSpecialAgent(@RequestHeader("token") String token) throws BizException, PermissionException, JsonParseException;
@ApiOperation(value = "导出社群码(编辑)", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", dataType = "string", paramType = "header"),
@ApiImplicitParam(name = "bookName", value = "书籍名称", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "isbn", value = "isbn", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "channelId", value = "渠道标识", dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "typeCode", value = "书刊类型", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "isMainEditor", value = "只看我是主编辑", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "isFundSupport", value = "只看基金支持", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "bookId", value = "书籍标识", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query"),
})
@RequestMapping(value = "exportGroupQrcode4Adviser", method = RequestMethod.GET)
ResponseDto<?> exportGroupQrcode4Adviser(@RequestHeader("token") String token,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "bookName", required = false) String bookName,
@RequestParam(value = "isbn", required = false) String isbn,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "typeCode", required = false) String typeCode,
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate)
throws BizException, PermissionException;
}
package com.pcloud.book.group.facade.impl;
import java.util.HashMap;
import java.util.Map;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.JsonParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.BookGroupClassifyBiz;
......@@ -29,6 +15,22 @@ import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.string.StringUtil;
import org.codehaus.jackson.JsonParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
import io.swagger.annotations.ApiOperation;
/**
* Description 社群书群二维码接口实现类
* Created by PENG on 2019/4/17.
......@@ -262,4 +264,38 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
Long agentId = (Long) SessionUtil.getVlaue(token, SessionUtil.TENANT_ID);
return new ResponseDto<Boolean>(bookGroupBiz.isSpecialAgent(agentId));
}
@Override
@ApiOperation(value = "导出社群码(编辑)", httpMethod = "GET")
@RequestMapping(value = "exportGroupQrcode4Adviser", method = RequestMethod.GET)
public ResponseDto<?> exportGroupQrcode4Adviser(@RequestHeader("token") String token,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "bookName", required = false) String bookName,
@RequestParam(value = "isbn", required = false) String isbn,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "typeCode", required = false) String typeCode,
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate)
throws BizException, PermissionException{
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("adviserId", adviserId);
paramMap.put("isMainEditor", isMainEditor);
paramMap.put("isFundSupport", isFundSupport);
paramMap.put("channelId", channelId);
paramMap.put("name", name != null && "".equals(name.trim()) ? null : name);
paramMap.put("isbn", isbn != null && "".equals(isbn.trim()) ? null : isbn);
paramMap.put("bookName", bookName != null && "".equals(bookName.trim()) ? null : bookName);
paramMap.put("typeCode", typeCode != null && "".equals(typeCode.trim()) ? null : typeCode);
paramMap.put("bookId", bookId);
if (!StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) {
paramMap.put("startDate", startDate + " 00:00:00");
paramMap.put("endDate", endDate + " 23:59:59");
}
bookGroupBiz.exportGroupQrcode4Adviser(paramMap, adviserId);
return new ResponseDto<>();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment