Commit 11660368 by 田超

Merge branch 'feature/erp' into 'master'

feat: [erp融合] 内部接口改成外部接口

See merge request rays/pcloud-book!853
parents 39355fa6 f3a72e9c
...@@ -6,6 +6,8 @@ package com.pcloud.book.book.facade; ...@@ -6,6 +6,8 @@ package com.pcloud.book.book.facade;
import com.pcloud.book.base.dto.CountDto; import com.pcloud.book.base.dto.CountDto;
import com.pcloud.book.book.dto.BookAdviserDto; import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.book.dto.BookCountDto; import com.pcloud.book.book.dto.BookCountDto;
import com.pcloud.book.book.dto.BookResourceStatisticsDTO;
import com.pcloud.book.book.dto.MapResourceTotalCountDTO;
import com.pcloud.book.book.entity.BookAdviser; import com.pcloud.book.book.entity.BookAdviser;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -16,6 +18,7 @@ import org.springframework.cloud.netflix.feign.FeignClient; ...@@ -16,6 +18,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @描述:编辑推广书籍接口类 * @描述:编辑推广书籍接口类
...@@ -216,4 +219,8 @@ public interface BookAdviserFacade { ...@@ -216,4 +219,8 @@ public interface BookAdviserFacade {
@RequestMapping(value = "setIsPrint", method = RequestMethod.POST) @RequestMapping(value = "setIsPrint", method = RequestMethod.POST)
ResponseDto<?> setIsPrint(@RequestHeader("token") String token, ResponseDto<?> setIsPrint(@RequestHeader("token") String token,
@RequestBody BookAdviser bookAdviser) throws BizException, PermissionException, JsonParseException; @RequestBody BookAdviser bookAdviser) throws BizException, PermissionException, JsonParseException;
@ApiOperation("获取书下资源总数(包括现代纸书、1V1、小睿、社群码)")
@PostMapping("mapResourceTotalCount")
ResponseDto<Map<String, BookResourceStatisticsDTO>> mapResourceTotalCount(@RequestBody MapResourceTotalCountDTO mapResourceTotalCountDTO);
} }
...@@ -759,4 +759,15 @@ public interface BookFacade { ...@@ -759,4 +759,15 @@ public interface BookFacade {
public ResponseDto<?> getAdviserBooks4Applet( public ResponseDto<?> getAdviserBooks4Applet(
@RequestBody @Validated BookSearchParamVO bookSearchParamVO @RequestBody @Validated BookSearchParamVO bookSearchParamVO
) throws BizException, PermissionException; ) throws BizException, PermissionException;
@ApiOperation(value = "批量获取书籍信息(书名 与书刊序号 封面图)", httpMethod = "POST")
@RequestMapping(value = "/listBaseByIds", method = RequestMethod.POST)
public ResponseDto<Map<Long, BookDto>> listBaseByIds(@RequestBody(required = false) List<Long> bookIds)
throws BizException;
@ApiOperation("获取书刊标签")
@RequestMapping(value = "/getLabelMapByIds", method = RequestMethod.POST)
public ResponseDto<Map<Long, String>> getLabelMapByIds(
@RequestBody List<Long> labelIds
) throws BizException;
} }
...@@ -5,12 +5,17 @@ package com.pcloud.book.book.facade.impl; ...@@ -5,12 +5,17 @@ package com.pcloud.book.book.facade.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import com.pcloud.book.book.dto.BookResourceStatisticsDTO;
import com.pcloud.book.book.dto.MapResourceTotalCountDTO;
import com.pcloud.book.book.vo.QrCodeVO; import com.pcloud.book.book.vo.QrCodeVO;
import com.pcloud.channelcenter.qrcode.entity.QrcodeScene; import com.pcloud.channelcenter.qrcode.entity.QrcodeScene;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.JsonParseException;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -180,7 +185,6 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -180,7 +185,6 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
@RequestParam(value = "currentPage") Integer currentPage, @RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "numPerPage") Integer numPerPage) @RequestParam(value = "numPerPage") Integer numPerPage)
throws PermissionException, JsonParseException, BizException { throws PermissionException, JsonParseException, BizException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(bookAdviserBiz.listAdviserBook4Erp(isbn, uniqueNumber, adviserName, currentPage, numPerPage)); return new ResponseDto<>(bookAdviserBiz.listAdviserBook4Erp(isbn, uniqueNumber, adviserName, currentPage, numPerPage));
} }
...@@ -209,6 +213,9 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -209,6 +213,9 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
return new ResponseDto<>(qrCodeVOPageBeanNew); return new ResponseDto<>(qrCodeVOPageBeanNew);
} }
@Override
@PostMapping("mapResourceTotalCount")
public ResponseDto<Map<String, BookResourceStatisticsDTO>> mapResourceTotalCount(@RequestBody MapResourceTotalCountDTO mapResourceTotalCountDTO) {
return new ResponseDto<>(bookAdviserBiz.mapResourceTotalCount(mapResourceTotalCountDTO.getAdviserIds(), mapResourceTotalCountDTO.getBookIds(), mapResourceTotalCountDTO.getChannelIds()));
}
} }
...@@ -7,6 +7,7 @@ import com.google.common.collect.Lists; ...@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz; import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.biz.BookLabelBiz;
import com.pcloud.book.book.dto.AdviserBookInfoDTO; import com.pcloud.book.book.dto.AdviserBookInfoDTO;
import com.pcloud.book.book.dto.BookAssocCount; import com.pcloud.book.book.dto.BookAssocCount;
import com.pcloud.book.book.dto.BookDto; import com.pcloud.book.book.dto.BookDto;
...@@ -68,6 +69,9 @@ public class BookFacadeImpl implements BookFacade { ...@@ -68,6 +69,9 @@ public class BookFacadeImpl implements BookFacade {
@Autowired @Autowired
private BookBiz bookBiz; private BookBiz bookBiz;
@Autowired
private BookLabelBiz bookLabelBiz;
/** /**
* 创建书籍 * 创建书籍
*/ */
...@@ -1085,4 +1089,22 @@ public class BookFacadeImpl implements BookFacade { ...@@ -1085,4 +1089,22 @@ public class BookFacadeImpl implements BookFacade {
) throws BizException, PermissionException { ) throws BizException, PermissionException {
return new ResponseDto<>(bookBiz.getBookLabels4Erp()); return new ResponseDto<>(bookBiz.getBookLabels4Erp());
} }
@Override
@RequestMapping(value = "/listBaseByIds", method = RequestMethod.POST)
public ResponseDto<Map<Long, BookDto>> listBaseByIds(@RequestBody List<Long> bookIds) throws BizException {
if(ListUtils.isEmpty(bookIds)){
return new ResponseDto<>(new HashMap<>());
}
return new ResponseDto<>(bookBiz.listBaseByIds(bookIds));
}
@Override
@RequestMapping(value = "/getLabelMapByIds", method = RequestMethod.POST)
public ResponseDto<Map<Long, String>> getLabelMapByIds( @RequestBody List<Long> labelIds) throws BizException {
if(ListUtils.isEmpty(labelIds)){
return new ResponseDto<>(new HashMap<>());
}
return new ResponseDto<>(bookLabelBiz.getLabelMapByIds(labelIds));
}
} }
\ No newline at end of file
package com.pcloud.book.consumer.erp; package com.pcloud.book.consumer.erp;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil; import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.erp.project.service.ProjectService; import com.pcloud.readercenter.common.utils.HttpUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap; import java.util.HashMap;
...@@ -24,17 +28,25 @@ public class ErpConsr { ...@@ -24,17 +28,25 @@ public class ErpConsr {
*/ */
private static final Logger LOGGER = LoggerFactory.getLogger(ErpConsr.class); private static final Logger LOGGER = LoggerFactory.getLogger(ErpConsr.class);
@Autowired @Value("${erp.domain}")
private ProjectService projectService; private String domain;
@ParamLog("根据书名获取等级") @ParamLog("根据书名获取等级")
public Integer getBookServiceLevel(String bookName) throws BizException { public Integer getBookServiceLevel(String bookName) throws BizException {
try { Map<String, String> querys = new HashMap<>();
return ResponseHandleUtil.parseResponse(projectService.getBookServiceLevel(bookName), Integer.class); querys.put("bookName", bookName);
} catch (Exception e) { try {
LOGGER.error("获取资源基本信息[resourceService.mapByPass]:" + e.getMessage(), e); HttpResponse response = HttpUtils.doGet(domain, "/api/erp/project4Third/getBookServiceLevel", "GET", new HashMap<>(), querys);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "获取资源基本信息失败~!"); String entityString = EntityUtils.toString(response.getEntity());
} JSONObject jsonObject = JSONObject.parseObject(entityString);
if(jsonObject.getInteger("errCode") != 0){
throw new BizException(jsonObject.getString("message"));
}
return jsonObject.getInteger("data");
} catch (Exception e){
LOGGER.error("获取资源基本信息[resourceService.mapByPass]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "获取资源基本信息失败~!");
}
} }
@ParamLog("批量获取项目名称") @ParamLog("批量获取项目名称")
...@@ -42,9 +54,17 @@ public class ErpConsr { ...@@ -42,9 +54,17 @@ public class ErpConsr {
if(ListUtils.isEmpty(bookIds)){ if(ListUtils.isEmpty(bookIds)){
return new HashMap<>(); return new HashMap<>();
} }
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
try { try {
return ResponseHandleUtil.parseMap(projectService.getBookNames(bookIds), Long.class,String.class); HttpResponse response = HttpUtils.doPost(domain, "/api/erp/project4Third/getBookNames", "POST", headers, new HashMap<>(), JSONObject.toJSONString(bookIds));
} catch (Exception e) { String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString);
if(jsonObject.getInteger("errCode") != 0){
throw new BizException(jsonObject.getString("message"));
}
return JSONObject.parseObject(jsonObject.getString("data"), new TypeReference<Map<Long, String>>(){});
} catch (Exception e){
LOGGER.error("批量获取项目名称[projectService.getBookNames]:" + e.getMessage(), e); LOGGER.error("批量获取项目名称[projectService.getBookNames]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "批量获取项目名称~!"); throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "批量获取项目名称~!");
} }
...@@ -55,9 +75,17 @@ public class ErpConsr { ...@@ -55,9 +75,17 @@ public class ErpConsr {
if(StringUtil.isEmpty(bookName)){ if(StringUtil.isEmpty(bookName)){
return null; return null;
} }
Map<String, String> querys = new HashMap<>();
querys.put("bookName", bookName);
try { try {
return ResponseHandleUtil.parseListResponse(projectService.getIdByBookName(bookName), Long.class); HttpResponse response = HttpUtils.doGet(domain, "/api/erp/project4Third/getIdByBookName", "GET", new HashMap<>(), querys);
} catch (Exception e) { String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString);
if(jsonObject.getInteger("errCode") != 0){
throw new BizException(jsonObject.getString("message"));
}
return JSONArray.parseArray(jsonObject.getJSONArray("data").toJSONString(), Long.class);
} catch (Exception e){
LOGGER.error("通过书名获取ERP端的bookId[projectService.getIdByBookName]:" + e.getMessage(), e); LOGGER.error("通过书名获取ERP端的bookId[projectService.getIdByBookName]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过书名获取ERP端的bookId错误"); throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过书名获取ERP端的bookId错误");
} }
...@@ -68,9 +96,17 @@ public class ErpConsr { ...@@ -68,9 +96,17 @@ public class ErpConsr {
if(StringUtil.isEmpty(bookName)){ if(StringUtil.isEmpty(bookName)){
return null; return null;
} }
Map<String, String> querys = new HashMap<>();
querys.put("bookName", bookName);
try { try {
return ResponseHandleUtil.parseListResponse(projectService.getIdsByBookName(bookName), Long.class); HttpResponse response = HttpUtils.doGet(domain, "/api/erp/project4Third/getIdsByBookName", "GET", new HashMap<>(), querys);
} catch (Exception e) { String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString);
if(jsonObject.getInteger("errCode") != 0){
throw new BizException(jsonObject.getString("message"));
}
return JSONArray.parseArray(jsonObject.getJSONArray("data").toJSONString(), Long.class);
} catch (Exception e){
LOGGER.error("通过书名获取ERP端的bookId[projectService.getIdByBookName]:" + e.getMessage(), e); LOGGER.error("通过书名获取ERP端的bookId[projectService.getIdByBookName]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过书名获取ERP端的bookId错误"); throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过书名获取ERP端的bookId错误");
} }
...@@ -81,9 +117,24 @@ public class ErpConsr { ...@@ -81,9 +117,24 @@ public class ErpConsr {
if(!NumberUtil.isNumber(bookId)){ if(!NumberUtil.isNumber(bookId)){
return null; return null;
} }
Map<String, String> querys = new HashMap<>();
querys.put("bookId", bookId.toString());
if(NumberUtil.isNumber(adviserId)){
querys.put("adviserId", adviserId.toString());
}
if(NumberUtil.isNumber(channelId)){
querys.put("channelId", channelId.toString());
}
try { try {
return ResponseHandleUtil.parseResponse(projectService.getProjectIdByBookId(bookId, adviserId, channelId), Long.class); HttpResponse response = HttpUtils.doGet(domain, "/api/erp/project4Third/getProjectIdByBookId", "GET", new HashMap<>(), querys);
} catch (Exception e) { String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString);
if(jsonObject.getInteger("errCode") != 0){
throw new BizException(jsonObject.getString("message"));
}
return jsonObject.getLong("data");
} catch (Exception e){
LOGGER.error("通过项目id获取bookId[projectService.getBookIdByProjectId]:" + e.getMessage(), e); LOGGER.error("通过项目id获取bookId[projectService.getBookIdByProjectId]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过项目id获取bookId 错误"); throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过项目id获取bookId 错误");
} }
......
...@@ -599,38 +599,38 @@ ...@@ -599,38 +599,38 @@
</update> </update>
<select id="listAdviserBook4Erp" parameterType="map" resultType="erpAdviserBookVO"> <select id="listAdviserBook4Erp" parameterType="map" resultType="erpAdviserBookVO">
SELECT SELECT
ba.BOOK_ID bookId, ba.BOOK_ID bookId,
ba.ADVISER_ID adviserId, ba.ADVISER_ID adviserId,
ba.channel_id channelId, ba.channel_id channelId,
b.BOOK_NAME bookName, b.BOOK_NAME bookName,
b.COVER_IMG coverImg, b.COVER_IMG coverImg,
b.ISBN isbn, b.ISBN isbn,
CONCAT('BK', ba.BOOK_ID) uniqueNumber, CONCAT('BK', ba.BOOK_ID) uniqueNumber,
ba.BOOK_ADVISER_ID bookAdviserId, ba.BOOK_ADVISER_ID bookAdviserId,
b.SERIAL_NUMBER serialNumber b.SERIAL_NUMBER serialNumber
FROM FROM
`book_adviser` ba `book_adviser` ba
LEFT JOIN book b ON ba.BOOK_ID = b.BOOK_ID LEFT JOIN book b ON ba.BOOK_ID = b.BOOK_ID
WHERE WHERE
ba.IS_DELETE = 0 ba.IS_DELETE = 0
AND b.IS_DELETE = 0 AND b.IS_DELETE = 0
<if test="isbn != null"> <if test="isbn != null">
AND (b.ISBN =#{isbn} or b.BOOK_NAME LIKE CONCAT('%', #{isbn}, '%')) AND (b.ISBN =#{isbn} or b.BOOK_NAME LIKE CONCAT('%', #{isbn}, '%'))
</if> </if>
<if test="uniqueNumber != null"> <if test="uniqueNumber != null">
AND CONCAT('BK', ba.BOOK_ID) LIKE CONCAT('%', #{uniqueNumber}, '%') AND CONCAT('BK', ba.BOOK_ID) LIKE CONCAT('%', #{uniqueNumber}, '%')
</if> </if>
<if test="adviserIds != null and adviserIds.size() > 0"> <if test="adviserIds != null and adviserIds.size() > 0">
AND ba.ADVISER_ID IN AND ba.ADVISER_ID IN
<foreach collection="adviserIds" index="i" item="item" open="(" separator="," close=")"> <foreach collection="adviserIds" index="i" item="item" open="(" separator="," close=")">
${item} ${item}
</foreach> </foreach>
</if> </if>
GROUP BY GROUP BY
ba.BOOK_ADVISER_ID ba.BOOK_ADVISER_ID
ORDER BY ORDER BY
ba.CREATED_DATE DESC ba.CREATED_DATE DESC
</select> </select>
<!-- 设置书刊是否已下印状态 --> <!-- 设置书刊是否已下印状态 -->
......
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