Commit 1d91481a authored by 郑建's avatar 郑建

6.6-2

parent f94cd055
package com.quantgroup.asset.distribution.service.approval;
import java.util.List;
import java.util.Map;
import com.quantgroup.asset.distribution.enums.funding.AuditTargetEnum;
......@@ -41,7 +42,9 @@ public interface IApprovalLogService {
*/
public Map<String, Object> getApprovalLogs(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget,
String applyStartTime, String applyEndTime, String user, Integer pageNum, Integer pageSize,Integer sortMode);
List<Long> getFundConfigIds(String channel);
/**
* 审批接口
* @param auditStatus
......
......@@ -116,6 +116,15 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
return result;
}
@Override
public List<Long> getFundConfigIds(String channel){
if (StringUtils.isEmpty(channel)){
return approvalLogRepository.findAuditConfigIds();
}else {
return approvalLogRepository.findAuditConfigIds(channel);
}
}
@Transactional(rollbackFor=Exception.class)
@Override
public void audit(ApprovalLog approvalLog, Integer auditStatus) {
......
......@@ -159,12 +159,32 @@ public class FundModuleChannelFundConfigNewServiceImpl implements IFundModuleCha
@Override
public Map<String, Object> getChannelFundConfigsByChannelOrFundIdOrdered(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
Map<String,Object> map = approvalLogService.getApprovalLogs(bizChannel,null,null,1,null,null,null,pageNum,pageSize,1);
List<ApprovalLog> logs = (List<ApprovalLog>) map.get("list");
List<Long> configIds = logs.stream().collect(ArrayList::new,(l,i)-> l.add(i.getAuditConfigId()),ArrayList::addAll);
List<FundModuleChannelFundConfigNew> channelFundConfigs = fundModuleChannelFundConfigNewRepository.getByIds(configIds);
map.replace("list",channelFundConfigs);
return map;
List<Long> ids = approvalLogService.getFundConfigIds(bizChannel);
// 分页条件
Pageable pageable = new PageRequest(pageNum < 0 ? 0 : pageNum, pageSize);
Specification<FundModuleChannelFundConfigNew> specification = new Specification<FundModuleChannelFundConfigNew>() {
@Override
public Predicate toPredicate(Root<FundModuleChannelFundConfigNew> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get("enable"), true));
if(StringUtils.isNotEmpty(bizChannel)){
predicates.add(cb.equal(root.get("bizChannel"), bizChannel));
}
if(fundId != null){
predicates.add(cb.like(root.get("fundIds"), "%" + fundId + "%"));
}
query.where(predicates.toArray(new Predicate[predicates.size()]));
return query.getRestriction();
}
};
Page<FundModuleChannelFundConfigNew> channelFundConfigs = fundModuleChannelFundConfigNewRepository.findAll(specification, pageable);
Map<String, Object> result = new HashMap<>();
result.put("total", channelFundConfigs.getTotalElements());
result.put("pages", channelFundConfigs.getTotalPages());
result.put("pageSize", channelFundConfigs.getSize());
result.put("pageNum", channelFundConfigs.getNumber());
result.put("list", channelFundConfigs.getContent());
return result;
}
@Override
......
......@@ -4,6 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.quantgroup.asset.distribution.service.jpa.entity.ApprovalLog;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface IApprovalLogRepository extends JpaRepository<ApprovalLog, Long>, JpaSpecificationExecutor<ApprovalLog>{
......@@ -13,4 +16,10 @@ public interface IApprovalLogRepository extends JpaRepository<ApprovalLog, Long
Integer auditTarget,
String targetName,
Integer auditStatus);
@Query(value = "select audit_config_id from approval_log where audit_type = 1 and target_name = ?1 and (audit_status = 0 or audit_status = 1) order by audit_status asc,updated_at desc", nativeQuery = true)
List<Long> findAuditConfigIds(String channel);
@Query(value = "select audit_config_id from approval_log where audit_type = 1 and (audit_status = 0 or audit_status = 1) order by audit_status asc,updated_at desc",nativeQuery = true)
List<Long> findAuditConfigIds();
}
......@@ -38,6 +38,11 @@ public interface IFundModuleChannelFundConfigNewRepository extends JpaRepository
@Query(value = "select biz_channel from fund_module_channel_fund_config_new where enable = 1", nativeQuery = true)
public List<String> getAllBizChannel();
@Query(value = "SELECT * FROM fund_module_channel_fund_config_new where id in ?1 order by field(?1)",nativeQuery = true)
List<FundModuleChannelFundConfigNew> getByIds(List<Long> ids);
@Query(value = "SELECT * FROM fund_module_channel_fund_config_new where id in ?1 and fund_ids like %?2% order by field(?1)",nativeQuery = true)
List<FundModuleChannelFundConfigNew> getByIds(List<Long> ids,Long fundId);
}
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