Commit 1f97af23 by 田超

Merge branch 'fixbug/10001234' into 'master'

bug : [none] rays和erp显示扫码量不一致

See merge request rays/pcloud-book!1511
parents 99c6be73 78820ab5
...@@ -1028,25 +1028,36 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -1028,25 +1028,36 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return new PageBeanNew<>(currentPage, numPerPage,null==pageBeanNew ? 0 : pageBeanNew.getTotalCount(), new ArrayList<>()); return new PageBeanNew<>(currentPage, numPerPage,null==pageBeanNew ? 0 : pageBeanNew.getTotalCount(), new ArrayList<>());
} }
List<ErpAdviserBookVO> bookVOS=pageBeanNew.getRecordList(); List<ErpAdviserBookVO> bookVOS=pageBeanNew.getRecordList();
List<BookScanCountParamDTO> param=new ArrayList<>();
BookScanCountParamDTO bookScanCountParamDTO=null;
if(!CollectionUtils.isEmpty(bookVOS)) { if(!CollectionUtils.isEmpty(bookVOS)) {
Set<Long> setAdviserIds=new HashSet<>(); Set<Long> setAdviserIds=new HashSet<>();
Set<Long> setChannelIds=new HashSet<>(); Set<Long> setChannelIds=new HashSet<>();
Set<Long> setBookIds=new HashSet<>(); Set<Long> setBookIds=new HashSet<>();
for (ErpAdviserBookVO bookVO : bookVOS) { for (ErpAdviserBookVO bookVO : bookVOS) {
bookScanCountParamDTO=new BookScanCountParamDTO();
addIfNonNull(setAdviserIds,bookVO.getAdviserId()); addIfNonNull(setAdviserIds,bookVO.getAdviserId());
addIfNonNull(setChannelIds,bookVO.getChannelId()); addIfNonNull(setChannelIds,bookVO.getChannelId());
addIfNonNull(setBookIds,bookVO.getBookId()); addIfNonNull(setBookIds,bookVO.getBookId());
bookScanCountParamDTO.setBookId(bookVO.getBookId());
bookScanCountParamDTO.setAdviserId(bookVO.getAdviserId());
bookScanCountParamDTO.setChannelId(bookVO.getChannelId());
param.add(bookScanCountParamDTO);
} }
List<Long> adviserIds = Lists.newArrayList(setAdviserIds); List<Long> adviserIds = Lists.newArrayList(setAdviserIds);
List<Long> channelIds = Lists.newArrayList(setChannelIds); List<Long> channelIds = Lists.newArrayList(setChannelIds);
List<Long> bookIds = Lists.newArrayList(setBookIds); List<Long> bookIds = Lists.newArrayList(setBookIds);
Map<String, BookDataStatisticsDTO> stringBookDataStatisticsDTOMap = mapBookDataStatistics(adviserIds, bookIds, channelIds); // Map<String, BookDataStatisticsDTO> stringBookDataStatisticsDTOMap = mapBookDataStatistics(adviserIds, bookIds, channelIds);
List<Long> xiaoRuiEducation = channelConsr.isXiaoRuiEducation(bookIds); List<Long> xiaoRuiEducation = channelConsr.isXiaoRuiEducation(bookIds);
List<BookScanCountDto> bookScanCounts = bookMapper.getBookScanCounts(bookIds); // List<BookScanCountDto> bookScanCounts = bookMapper.getBookScanCounts(bookIds);
Map<Long,Integer> chMap = new HashMap<>(); //小睿书的扫码量
Map<Long, Long> xiaoRuiScanMap = erpConsr.mapScan4Erp(xiaoRuiEducation);
//从data服务拿书刊扫码量(bookId,adviserId,channelId)
Map<String, BookScanCountVO> bookScanCountVOMap = dataConsr.multiGetBookScanCount(param);
/* Map<Long,Integer> chMap = new HashMap<>();
for (BookScanCountDto bookScanCount : bookScanCounts) { for (BookScanCountDto bookScanCount : bookScanCounts) {
chMap.put(bookScanCount.getBookId(),bookScanCount.getScanCount().intValue()); chMap.put(bookScanCount.getBookId(),bookScanCount.getScanCount().intValue());
} }*/
Map<Long, UserLogin> userLoginInfoMap= new HashMap<>(); Map<Long, UserLogin> userLoginInfoMap= new HashMap<>();
...@@ -1074,20 +1085,33 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -1074,20 +1085,33 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if(bookVO.getAdviserId()!=null &&bookVO.getChannelId()!=null &&bookVO.getBookId()!=null ) { if(bookVO.getAdviserId()!=null &&bookVO.getChannelId()!=null &&bookVO.getBookId()!=null ) {
String key = bookVO.getBookId() + "_" + bookVO.getChannelId() + "_" + bookVO.getAdviserId(); String key = bookVO.getBookId() + "_" + bookVO.getChannelId() + "_" + bookVO.getAdviserId();
if(stringBookDataStatisticsDTOMap.containsKey(key)){ String scanKey = bookVO.getBookId() + "_" + bookVO.getAdviserId() + "_" + bookVO.getChannelId();
/*if(stringBookDataStatisticsDTOMap.containsKey(key)){
BookDataStatisticsDTO bookDataStatisticsDTO = stringBookDataStatisticsDTOMap.get(key); BookDataStatisticsDTO bookDataStatisticsDTO = stringBookDataStatisticsDTOMap.get(key);
bookVO.setScanCount(bookDataStatisticsDTO.getScanCount().intValue()); bookVO.setScanCount(bookDataStatisticsDTO.getScanCount().intValue());
bookVO.setUserCount(bookDataStatisticsDTO.getUserCount().intValue()); bookVO.setUserCount(bookDataStatisticsDTO.getUserCount().intValue());
}*/
if(CollUtil.isNotEmpty(bookScanCountVOMap) && bookScanCountVOMap.containsKey(scanKey)){
BookScanCountVO bookScanCountVO = bookScanCountVOMap.get(scanKey);
if(null!=bookScanCountVO){
bookVO.setScanCount(Optional.ofNullable(bookScanCountVO.getScanCnt()).map(Long::intValue).orElse(0));
bookVO.setUserCount(Optional.ofNullable(bookScanCountVO.getScanUserCnt()).map(Long::intValue).orElse(0));
bookVO.setChScanCount(Optional.ofNullable(bookScanCountVO.getScanCnt()).map(Long::intValue).orElse(0));
}
} }
} }
if(bookVO.getBookId()!=null){ if(bookVO.getBookId()!=null){
if(xiaoRuiEducation.contains(bookVO.getBookId())){ if(xiaoRuiEducation.contains(bookVO.getBookId())){
bookVO.setXiaoRuiEducation(1); bookVO.setXiaoRuiEducation(1);
if(CollUtil.isNotEmpty(xiaoRuiScanMap) && xiaoRuiScanMap.containsKey(bookVO.getBookId())){
Long scanCount = xiaoRuiScanMap.get(bookVO.getBookId());
bookVO.setChScanCount(Optional.ofNullable(scanCount).map(Long::intValue).orElse(0));
} }
Integer chScan = chMap.get(bookVO.getBookId()); }
/*Integer chScan = chMap.get(bookVO.getBookId());
if(chScan!=null) { if(chScan!=null) {
bookVO.setChScanCount(chScan); bookVO.setChScanCount(chScan);
} }*/
} }
Long adviserId = bookVO.getAdviserId(); Long adviserId = bookVO.getAdviserId();
if(adviserId != null && MapUtils.isNotEmpty(userLoginInfoMap) && userLoginInfoMap.containsKey(adviserId)) { if(adviserId != null && MapUtils.isNotEmpty(userLoginInfoMap) && userLoginInfoMap.containsKey(adviserId)) {
......
...@@ -209,7 +209,7 @@ public class ErpConsr { ...@@ -209,7 +209,7 @@ public class ErpConsr {
params.put("startTime", startTime); params.put("startTime", startTime);
params.put("endTime", endTime); params.put("endTime", endTime);
try { try {
HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/searchBookInfo", "GET", headers, new HashMap<>(), JSONObject.toJSONString(params)); HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/searchBookInfo", "POST", headers, new HashMap<>(), JSONObject.toJSONString(params));
String entityString = EntityUtils.toString(response.getEntity()); String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString); JSONObject jsonObject = JSONObject.parseObject(entityString);
if (jsonObject.getInteger("errCode") != 0) { if (jsonObject.getInteger("errCode") != 0) {
...@@ -231,7 +231,7 @@ public class ErpConsr { ...@@ -231,7 +231,7 @@ public class ErpConsr {
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
try { try {
HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/searchRaysBookId", "GET", headers, new HashMap<>(), JSONObject.toJSONString(erpBookInfoDTOS)); HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/searchRaysBookId", "POST", headers, new HashMap<>(), JSONObject.toJSONString(erpBookInfoDTOS));
String entityString = EntityUtils.toString(response.getEntity()); String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString); JSONObject jsonObject = JSONObject.parseObject(entityString);
if (jsonObject.getInteger("errCode") != 0) { if (jsonObject.getInteger("errCode") != 0) {
...@@ -402,4 +402,29 @@ public class ErpConsr { ...@@ -402,4 +402,29 @@ public class ErpConsr {
return null; return null;
} }
/**
* 批量获取小睿书的扫码量
* @param
* @return
*/
public Map<Long,Long> mapScan4Erp(List<Long> bookIds) {
if (CollUtil.isEmpty(bookIds)) {
return new HashMap<>();
}
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
try {
HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/mapScan4Erp", "POST", headers, new HashMap<>(), JSONObject.toJSONString(bookIds));
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,Long>>(){});
} catch (Exception e) {
LOGGER.error("批量获取小睿书的扫码量 [projectService.mapScan4Erp]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "批量获取小睿书的扫码量失败!");
}
}
} }
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