|
@@ -1,14 +1,30 @@
|
|
package com.winhc.repal.service.impl;
|
|
package com.winhc.repal.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.winhc.common.enums.CodeMsg;
|
|
|
|
+import com.winhc.common.exception.CommonException;
|
|
import com.winhc.common.model.base.VOPage;
|
|
import com.winhc.common.model.base.VOPage;
|
|
import com.winhc.repal.entity.RepalBill;
|
|
import com.winhc.repal.entity.RepalBill;
|
|
import com.winhc.repal.model.dto.GetRepalBillPageDTO;
|
|
import com.winhc.repal.model.dto.GetRepalBillPageDTO;
|
|
import com.winhc.repal.model.vo.RepalBillPageVO;
|
|
import com.winhc.repal.model.vo.RepalBillPageVO;
|
|
import com.winhc.repal.repository.RepalBillMapper;
|
|
import com.winhc.repal.repository.RepalBillMapper;
|
|
import com.winhc.repal.service.RepalBillService;
|
|
import com.winhc.repal.service.RepalBillService;
|
|
|
|
+import com.winhc.repal.service.RepalResponsiblePersonService;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @description RepalBill 接口实现类
|
|
* @description RepalBill 接口实现类
|
|
* @author Generator
|
|
* @author Generator
|
|
@@ -17,12 +33,43 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class RepalBillServiceImpl extends ServiceImpl<RepalBillMapper, RepalBill> implements RepalBillService {
|
|
public class RepalBillServiceImpl extends ServiceImpl<RepalBillMapper, RepalBill> implements RepalBillService {
|
|
|
|
|
|
|
|
+ public static final Logger LOGGER = LoggerFactory.getLogger(RepalBillServiceImpl.class);
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RepalBillMapper repalBillMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RepalResponsiblePersonService repalResponsiblePersonService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public VOPage<RepalBillPageVO> getRepalBillPage(GetRepalBillPageDTO dto) {
|
|
public VOPage<RepalBillPageVO> getRepalBillPage(GetRepalBillPageDTO dto) {
|
|
|
|
+ if (ObjectUtil.hasEmpty(dto.getRepalGroupId(), dto.getRepalBookId())) {
|
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
|
+ }
|
|
|
|
+ VOPage<RepalBillPageVO> voPage = new VOPage<>();
|
|
|
|
+ voPage.setPageSize(dto.getPageSize());
|
|
|
|
+ voPage.setPageNum(dto.getPageNum());
|
|
|
|
+ // 管理员查看所有 todo
|
|
|
|
+ LOGGER.info("角色:[]");
|
|
|
|
+ Page<RepalBill> repalBillPage = new Page<>(dto.getPageNum(),dto.getPageSize());
|
|
|
|
+ repalBillPage = repalBillMapper.getRepalBillPage(repalBillPage, dto);
|
|
|
|
+ voPage.setTotalPage(Math.toIntExact(repalBillPage.getPages()));
|
|
|
|
+ voPage.setTotalNum(repalBillPage.getTotal());
|
|
|
|
+ if (CollUtil.isEmpty(repalBillPage.getRecords())) {
|
|
|
|
+ voPage.setDataList(new ArrayList<>());
|
|
|
|
+ return voPage;
|
|
|
|
+ }
|
|
|
|
+ List<Long> billIdList = repalBillPage.getRecords().stream().map(RepalBill::getId).collect(Collectors.toList());
|
|
|
|
+ Map<Long, List<String>> nameMap = repalResponsiblePersonService.getResponsiblePersonNameList(billIdList);
|
|
|
|
+ voPage.setDataList(repalBillPage.getRecords().stream().map(t -> {
|
|
|
|
+ RepalBillPageVO vo = new RepalBillPageVO();
|
|
|
|
+ BeanUtils.copyProperties(t, vo);
|
|
|
|
+ vo.setRepalBillId(t.getId());
|
|
|
|
+ vo.setResponsiblePersonNames(String.join("、", nameMap.get(t.getId())));
|
|
|
|
+ return vo;
|
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
|
+ return voPage;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|