123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.smppw.analysis.domain.dao;
- import com.smppw.analysis.domain.dataobject.NavDo;
- import com.smppw.analysis.infrastructure.consts.NavConst;
- import com.smppw.analysis.domain.persistence.NavDoMapper;
- import com.smppw.common.pojo.dto.NavDto;
- import com.smppw.common.pojo.enums.NavType;
- import com.smppw.constants.DateConst;
- import com.smppw.utils.DateUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Repository;
- import java.util.*;
- @Repository
- public class PrivatelyOfferedFundNavDao {
- @Autowired
- private NavDoMapper navDoMapper;
- public Map<String, List<NavDto>> getNav(List<String> fundIdList, String startDate, String endDate, NavType navType, boolean needUpdateAndCreateTime) {
- String navFieldSql = "";
- List<NavDo> navDoList = null;
- if (NavType.CumulativeNav == navType) {
- navFieldSql = NavConst.CUMULATIVE_NAV_SQL_FIELD;
- } else if (NavType.OriginalNav == navType) {
- navFieldSql = NavConst.NAV_SQL_FIELD;
- } else if (NavType.WithdrawalNav == navType) {
- navFieldSql = NavConst.CUMULATIVE_NAV_WITHDRAWAL_SQL_FIELD;
- } else if (NavType.All == navType) {
- navFieldSql = NavConst.CUMULATIVE_NAV_SQL_FIELD + "," + NavConst.NAV_SQL_FIELD + "," + NavConst.CUMULATIVE_NAV_WITHDRAWAL_SQL_FIELD;
- }
- navDoList = navDoMapper.listNavByTimeInterval(fundIdList, startDate, endDate, navFieldSql, needUpdateAndCreateTime);
- Map<String, List<NavDto>> fundIdNavDtoListMap = navDoListToNavDtoMap(navDoList);
- return fundIdNavDtoListMap;
- }
- /**
- * 领域对象集合转为数据传输对象集合
- *
- * @param navDoList 领域对象集合
- * @return 数据传输对象集合 key-基金ID value-数据传输对象集合
- */
- private Map<String, List<NavDto>> navDoListToNavDtoMap(List<NavDo> navDoList) {
- Map<String, List<NavDto>> fundIdNavDtoListMap = new HashMap<>();
- if (navDoList == null) {
- return fundIdNavDtoListMap;
- }
- for (NavDo navDo : navDoList) {
- NavDto navDto = new NavDto();
- navDto.setFundId(navDo.getFundId());
- if (navDo.getPriceDate() == null) {
- continue;
- }
- navDto.setPriceDate(DateUtil.DateToString(navDo.getPriceDate(), DateConst.YYYY_MM_DD));
- navDto.setOriginalNav(navDo.getNav());
- navDto.setCumulativeNav(navDo.getCumulativeNav());
- navDto.setCumulativeNavWithdrawal(navDo.getCumulativeNavWithdrawal());
- if (navDo.getUpdatetime() != null) {
- navDto.setUpdatetime(DateUtil.DateToString(navDo.getUpdatetime(), DateConst.YYYY_MM_DD_HH_MM_SS));
- }
- if (navDo.getCreatetime() != null) {
- navDto.setCreatetime(DateUtil.DateToString(navDo.getCreatetime(), DateConst.YYYY_MM_DD));
- }
- if (fundIdNavDtoListMap.containsKey(navDo.getFundId())) {
- List<NavDto> navDtoList = fundIdNavDtoListMap.get(navDo.getFundId());
- navDtoList.add(navDto);
- } else {
- List<NavDto> navDtoList = new ArrayList<>();
- navDtoList.add(navDto);
- fundIdNavDtoListMap.put(navDo.getFundId(), navDtoList);
- }
- }
- return fundIdNavDtoListMap;
- }
- /**
- * 获取基金净值更新时间 大于 传入的开始时间的基金id
- *
- * @param startTime 开始时间
- * @return 基金id列表
- */
- public List<NavDo> selectFundIdByStartTime(Date startTime) {
- return navDoMapper.selectFundIdByStartTime(startTime);
- }
- }
|