Commit 963b9d30 by 田超

Merge branch 'feature/1004406' into 'master'

feat: [1004406]六个月数据改版

See merge request rays/pcloud-book!1234
parents e044f5b4 07404931
...@@ -373,8 +373,9 @@ public interface BookAdviserBiz { ...@@ -373,8 +373,9 @@ public interface BookAdviserBiz {
* @param agentId * @param agentId
*/ */
void getBookIdsByAgentId(Long agentId); void getBookIdsByAgentId(Long agentId);
void getBookIdsByAgentIdAndMonth(Long agentId,int month);
List<Long> getBooksByAgentToken(Long agentId, int index); List<Long> getBooksByAgentToken(Long agentId, int index,int month);
BookServeInfo listBookServes4Book(String cursor, Integer limit); BookServeInfo listBookServes4Book(String cursor, Integer limit);
......
...@@ -747,5 +747,5 @@ public interface BookBiz { ...@@ -747,5 +747,5 @@ public interface BookBiz {
List<BookInfo4ScanCount> fetchBookListByScanCount(List<BookInfo4ScanCountRequestVO> requestVOS); List<BookInfo4ScanCount> fetchBookListByScanCount(List<BookInfo4ScanCountRequestVO> requestVOS);
BookCountsVO getPublishCounts(Long agentId); BookCountsVO getPublishCounts(Long agentId,int month);
} }
...@@ -2486,16 +2486,38 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -2486,16 +2486,38 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
} }
} }
public void getBookIdsByAgentIdAndMonth(Long agentId,int month) {
if (null == agentId) {
return;
}
List<Long> adviserIds = adviserConsr.getByAgentId(agentId);
if (ListUtils.isEmpty(adviserIds)) {
return;
}
String key = CacheConstant.BOOK + "BOOKIDS4AGENT:" + agentId+"_"+month;
//为空的话从数据库查询并缓存5分钟
if (StringUtil.isEmpty(JedisClusterUtils.get(key))) {
List<ERPPublishNumDTO> erpPublishNumQueryParams = bookAdviserDao.getErpPublishNumQueryParamsByMonth(adviserIds,month);
if (ListUtils.isEmpty(erpPublishNumQueryParams)) {
return;
}
Integer expireTime = 60 * 5;
JedisClusterUtils.setJsonList(key, erpPublishNumQueryParams, expireTime);
}
}
@Override @Override
public List<Long> getBooksByAgentToken(Long agentId, int index) { public List<Long> getBooksByAgentToken(Long agentId, int index,int month) {
if (null == agentId) { if (null == agentId) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<Long> result = new ArrayList<>(); List<Long> result = new ArrayList<>();
String key = CacheConstant.BOOK + "BOOKIDS4AGENT:" + agentId; String key = CacheConstant.BOOK + "BOOKIDS4AGENT:" + agentId+"_"+month;
if (StringUtil.isEmpty(JedisClusterUtils.get(key))) { if (StringUtil.isEmpty(JedisClusterUtils.get(key))) {
List<Long> adviserIds = adviserConsr.getByAgentId(agentId); List<Long> adviserIds = adviserConsr.getByAgentId(agentId);
List<ERPPublishNumDTO> erpPublishNumQueryParams = bookAdviserDao.getErpPublishNumQueryParams(adviserIds); List<ERPPublishNumDTO> erpPublishNumQueryParams = bookAdviserDao.getErpPublishNumQueryParamsByMonth(adviserIds,month);
if (ListUtils.isEmpty(erpPublishNumQueryParams)) { if (ListUtils.isEmpty(erpPublishNumQueryParams)) {
return new ArrayList<>(); return new ArrayList<>();
} }
......
...@@ -105,7 +105,6 @@ import com.pcloud.resourcecenter.product.dto.ProductDto; ...@@ -105,7 +105,6 @@ import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.SpecificationDto; import com.pcloud.resourcecenter.product.dto.SpecificationDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto; import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import com.pcloud.usercenter.party.agent.dto.SaleAgentDTO; import com.pcloud.usercenter.party.agent.dto.SaleAgentDTO;
import io.swagger.models.auth.In;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -3995,14 +3994,14 @@ public class BookBizImpl implements BookBiz { ...@@ -3995,14 +3994,14 @@ public class BookBizImpl implements BookBiz {
} }
@Override @Override
public BookCountsVO getPublishCounts(Long agentId) { public BookCountsVO getPublishCounts(Long agentId, int month) {
String keyOne = CacheConstant.BOOK + "getPublishCounts:" + agentId; String keyOne = CacheConstant.BOOK + "getPublishCounts:" + agentId+"_"+month;
if (JedisClusterUtils.exists(keyOne)) { if (JedisClusterUtils.exists(keyOne)) {
return JedisClusterUtils.getJson(keyOne, BookCountsVO.class); return JedisClusterUtils.getJson(keyOne, BookCountsVO.class);
} else { } else {
BookCountsVO bookCountsVO = new BookCountsVO(); BookCountsVO bookCountsVO = new BookCountsVO();
bookAdviserBiz.getBookIdsByAgentId(agentId); bookAdviserBiz.getBookIdsByAgentIdAndMonth(agentId,month);
String key = CacheConstant.BOOK + "BOOKIDS4AGENT:" + agentId; String key = CacheConstant.BOOK + "BOOKIDS4AGENT:" + agentId+"_"+month;
List<ERPPublishNumDTO> bookList = JedisClusterUtils.getJsonList(key, ERPPublishNumDTO.class); List<ERPPublishNumDTO> bookList = JedisClusterUtils.getJsonList(key, ERPPublishNumDTO.class);
if (bookList == null || bookList.size() == 0) { if (bookList == null || bookList.size() == 0) {
return new BookCountsVO(); return new BookCountsVO();
...@@ -4017,8 +4016,13 @@ public class BookBizImpl implements BookBiz { ...@@ -4017,8 +4016,13 @@ public class BookBizImpl implements BookBiz {
} }
if (books.size() > 0) { if (books.size() > 0) {
List<Long> advisers = adviserConsr.getByAgentId(agentId); List<Long> advisers = adviserConsr.getByAgentId(agentId);
int fundBookCounts = bookDao.getFundBookCounts(advisers); if(advisers.size()>0) {
bookCountsVO.setFundBookCounts(fundBookCounts); Integer fundBookCounts = bookDao.getFundBookCounts(advisers, month);
if (fundBookCounts == null) {
fundBookCounts = 0;
}
bookCountsVO.setFundBookCounts(fundBookCounts);
}
} else { } else {
bookCountsVO.setFundBookCounts(0); bookCountsVO.setFundBookCounts(0);
} }
...@@ -4027,11 +4031,23 @@ public class BookBizImpl implements BookBiz { ...@@ -4027,11 +4031,23 @@ public class BookBizImpl implements BookBiz {
bookGroupScanStatisticsRequestDTO.setBookIds(new ArrayList<>(books)); bookGroupScanStatisticsRequestDTO.setBookIds(new ArrayList<>(books));
bookGroupScanStatisticsRequestDTO.setAdviserIds(adviserIds); bookGroupScanStatisticsRequestDTO.setAdviserIds(adviserIds);
bookGroupScanStatisticsRequestDTO.setChannelIds(channelIds); bookGroupScanStatisticsRequestDTO.setChannelIds(channelIds);
bookGroupScanStatisticsRequestDTO.setStart(200001); if(month>0) {
Date now = new Date(); Calendar c = Calendar.getInstance();
String strDateFormat = "yyyyMM"; String strDateFormat = "yyyyMM";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
bookGroupScanStatisticsRequestDTO.setEnd(Integer.valueOf(sdf.format(now))); int startTime = Integer.parseInt(sdf.format(c.getTime()));
bookGroupScanStatisticsRequestDTO.setEnd(startTime);
c.add(Calendar.MONTH, -month);
int endTime = Integer.parseInt(sdf.format(c.getTime()));
bookGroupScanStatisticsRequestDTO.setStart(endTime);
}else {
bookGroupScanStatisticsRequestDTO.setStart(202001);
Calendar c = Calendar.getInstance();
String strDateFormat = "yyyyMM";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
bookGroupScanStatisticsRequestDTO.setEnd(Integer.parseInt(sdf.format(c.getTime())));
}
List<BookGroupScanStatisticsRespDTO> bookGroupScanStatistics = bookGroupBiz.getBookGroupScanStatistics(bookGroupScanStatisticsRequestDTO); List<BookGroupScanStatisticsRespDTO> bookGroupScanStatistics = bookGroupBiz.getBookGroupScanStatistics(bookGroupScanStatisticsRequestDTO);
Map<Long, Integer> booksScanCounts = new HashMap<>(); Map<Long, Integer> booksScanCounts = new HashMap<>();
for (BookGroupScanStatisticsRespDTO bookGroupScanStatistic : bookGroupScanStatistics) { for (BookGroupScanStatisticsRespDTO bookGroupScanStatistic : bookGroupScanStatistics) {
...@@ -4049,8 +4065,16 @@ public class BookBizImpl implements BookBiz { ...@@ -4049,8 +4065,16 @@ public class BookBizImpl implements BookBiz {
bookScanStatistics4OfficialAccountsReqDTO.setBookIds(new ArrayList<>(books)); bookScanStatistics4OfficialAccountsReqDTO.setBookIds(new ArrayList<>(books));
bookScanStatistics4OfficialAccountsReqDTO.setAdviserIds(adviserIds); bookScanStatistics4OfficialAccountsReqDTO.setAdviserIds(adviserIds);
bookScanStatistics4OfficialAccountsReqDTO.setChannelIds(channelIds); bookScanStatistics4OfficialAccountsReqDTO.setChannelIds(channelIds);
bookScanStatistics4OfficialAccountsReqDTO.setStart(new Date("2001/01/01 00:00:00"));
bookScanStatistics4OfficialAccountsReqDTO.setEnd(now); if(month>0) {
Calendar c2 = Calendar.getInstance();
bookScanStatistics4OfficialAccountsReqDTO.setEnd(c2.getTime());
c2.add(Calendar.MONTH, -month);
bookScanStatistics4OfficialAccountsReqDTO.setStart(c2.getTime());
}else{
bookScanStatistics4OfficialAccountsReqDTO.setStart(new Date("2018/01/01 00:00:00"));
bookScanStatistics4OfficialAccountsReqDTO.setEnd(new Date());
}
List<BookScanStatistics4OfficialAccountsDTO> bookScanStatistics4OfficialAccountsDTOS = ResponseHandleUtil.parseList(sceneRecordService.listBookScanStatistics4OfficialAccounts(bookScanStatistics4OfficialAccountsReqDTO), BookScanStatistics4OfficialAccountsDTO.class); List<BookScanStatistics4OfficialAccountsDTO> bookScanStatistics4OfficialAccountsDTOS = ResponseHandleUtil.parseList(sceneRecordService.listBookScanStatistics4OfficialAccounts(bookScanStatistics4OfficialAccountsReqDTO), BookScanStatistics4OfficialAccountsDTO.class);
for (BookScanStatistics4OfficialAccountsDTO bookGroupScanStatistic : bookScanStatistics4OfficialAccountsDTOS) { for (BookScanStatistics4OfficialAccountsDTO bookGroupScanStatistic : bookScanStatistics4OfficialAccountsDTOS) {
Long bookId = bookGroupScanStatistic.getBookId(); Long bookId = bookGroupScanStatistic.getBookId();
......
...@@ -320,4 +320,6 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> { ...@@ -320,4 +320,6 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> {
BookDto getLatestAdviserBookByIsbn(String isbn); BookDto getLatestAdviserBookByIsbn(String isbn);
List<BookServesListDTO> listBookServes4Book(Long cursor, Integer limit); List<BookServesListDTO> listBookServes4Book(Long cursor, Integer limit);
List<ERPPublishNumDTO> getErpPublishNumQueryParamsByMonth(List<Long> adviserIds, int month);
} }
...@@ -379,5 +379,5 @@ public interface BookDao extends BaseDao<Book> { ...@@ -379,5 +379,5 @@ public interface BookDao extends BaseDao<Book> {
Integer getBookMinimunSupportCount4Platform(Map<String, Object> paramMap); Integer getBookMinimunSupportCount4Platform(Map<String, Object> paramMap);
int getFundBookCounts(List<Long> advisers); Integer getFundBookCounts(List<Long> advisers,int month);
} }
...@@ -350,6 +350,15 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book ...@@ -350,6 +350,15 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book
} }
@Override @Override
public List<ERPPublishNumDTO> getErpPublishNumQueryParamsByMonth(List<Long> adviserIds,int month) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("adviserIds",adviserIds);
paramMap.put("month", month);
return super.getSqlSession().selectList(getStatement("getErpPublishNumQueryParamsByMonth"),paramMap);
}
@Override
public List<AgentBookStatsDetailVO> getAgentBookStatsDetail(List<ErpBookInfoDTO> raysBookIds, Integer isRay, String name, List<Long> advisers) { public List<AgentBookStatsDetailVO> getAgentBookStatsDetail(List<ErpBookInfoDTO> raysBookIds, Integer isRay, String name, List<Long> advisers) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (StrUtil.isNotBlank(name) && name.startsWith("BK")){ if (StrUtil.isNotBlank(name) && name.startsWith("BK")){
......
...@@ -15,10 +15,10 @@ import com.pcloud.book.book.vo.BookSaleVO; ...@@ -15,10 +15,10 @@ import com.pcloud.book.book.vo.BookSaleVO;
import com.pcloud.book.book.vo.SearchBookVO; import com.pcloud.book.book.vo.SearchBookVO;
import com.pcloud.book.book.dto.BookUniqueNumberDTO; import com.pcloud.book.book.dto.BookUniqueNumberDTO;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.book.group.vo.BookGroupServeCountVO;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import com.pcloud.common.utils.ListForInSQL; import com.pcloud.common.utils.ListForInSQL;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap; import java.util.HashMap;
...@@ -449,9 +449,10 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao { ...@@ -449,9 +449,10 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {
} }
@Override @Override
public int getFundBookCounts(List<Long> advisers) { public Integer getFundBookCounts(List<Long> advisers, int month) {
Map<String, Object> paramMap = Maps.newHashMap(); Map<String, Object> paramMap = Maps.newHashMap();
paramMap.put("list", advisers); paramMap.put("list", advisers);
return getSessionTemplate().selectOne(getStatement("getFundBookCounts"), advisers); paramMap.put("month", month);
return getSessionTemplate().selectOne(getStatement("getFundBookCounts"), paramMap);
} }
} }
...@@ -383,9 +383,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -383,9 +383,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
} }
@PostMapping("getBooksByAgentToken") @PostMapping("getBooksByAgentToken")
public ResponseDto<List<Long>>getBooksByAgentToken(@RequestParam(value = "token") String token,@RequestParam(value = "index") int index){ public ResponseDto<List<Long>>getBooksByAgentToken(@RequestParam(value = "token") String token,@RequestParam(value = "index") int index,@RequestParam(value = "month" ,required = false) Integer month){
Long agentId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); Long agentId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
List<Long>bookIds = bookAdviserBiz.getBooksByAgentToken(agentId,index); if(month==null){
month=0;
}
List<Long>bookIds = bookAdviserBiz.getBooksByAgentToken(agentId,index,month);
return new ResponseDto<>(bookIds); return new ResponseDto<>(bookIds);
} }
......
...@@ -1319,9 +1319,12 @@ public class BookFacadeImpl implements BookFacade { ...@@ -1319,9 +1319,12 @@ public class BookFacadeImpl implements BookFacade {
} }
@GetMapping("getPublishCounts") @GetMapping("getPublishCounts")
public ResponseDto<BookCountsVO>getPublishCounts( @RequestHeader("token") String token){ public ResponseDto<BookCountsVO>getPublishCounts( @RequestHeader("token") String token,@RequestParam(name = "month",required = false)Integer month){
if(month==null){
month=0;
}
Long agentId = (Long) SessionUtil.getVlaue(token,SessionUtil.PARTY_ID); Long agentId = (Long) SessionUtil.getVlaue(token,SessionUtil.PARTY_ID);
BookCountsVO bookCountsVO = bookBiz.getPublishCounts(agentId); BookCountsVO bookCountsVO = bookBiz.getPublishCounts(agentId,month);
return new ResponseDto<>(bookCountsVO); return new ResponseDto<>(bookCountsVO);
} }
} }
...@@ -2888,7 +2888,7 @@ ...@@ -2888,7 +2888,7 @@
) a ) a
</select> </select>
<select id="getFundBookCounts" resultType="int"> <select id="getFundBookCounts" resultType="Integer">
select count(1) from ( select count(1) from (
SELECT SELECT
A.BOOK_ID, A.CHANNEL_ID A.BOOK_ID, A.CHANNEL_ID
...@@ -2916,7 +2916,11 @@ ...@@ -2916,7 +2916,11 @@
BF.BOOK_ID = A.BOOK_ID AND BF.END_TIME> NOW() AND NOW()> BF.START_TIME BF.BOOK_ID = A.BOOK_ID AND BF.END_TIME> NOW() AND NOW()> BF.START_TIME
WHERE WHERE
1=1 and 1=1
<if test="month>0">
and BF.CREATED_DATE>= SUBDATE(now(),INTERVAL #{month} month)
</if>
and
BF.BOOK_FUND_ID>0 BF.BOOK_FUND_ID>0
GROUP BY A.BOOK_ID, A.CHANNEL_ID GROUP BY A.BOOK_ID, A.CHANNEL_ID
......
...@@ -919,6 +919,29 @@ ...@@ -919,6 +919,29 @@
</select> </select>
<select id="getErpPublishNumQueryParamsByMonth" parameterType="map" resultType="com.pcloud.book.book.dto.ERPPublishNumDTO">
SELECT
ADVISER_ID AS adviserId,
CHANNEL_ID AS channelId,
BOOK_ID AS bookId,
CREATED_DATE AS createDate
FROM
book_adviser
WHERE
ADVISER_ID IN
<foreach collection="adviserIds" item="item" close=")" open="(" separator=",">
#{item}
</foreach>
<if test="month>0">
and CREATED_DATE>= SUBDATE(now(),INTERVAL #{month} month)
</if>
GROUP BY
ADVISER_ID,
CHANNEL_ID,
BOOK_ID
</select>
<select id="getAgentBookStatsDetail" parameterType="map" resultType="com.pcloud.book.book.vo.AgentBookStatsDetailVO"> <select id="getAgentBookStatsDetail" parameterType="map" resultType="com.pcloud.book.book.vo.AgentBookStatsDetailVO">
SELECT SELECT
tb.bookAdviserId, tb.bookAdviserId,
......
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