24282 2 жил өмнө
parent
commit
8ff9b29571

+ 1 - 0
hx-account/src/main/java/com/fjhx/account/entity/account/vo/AccountRequestFundsVo.java

@@ -60,4 +60,5 @@ public class AccountRequestFundsVo extends AccountRequestFunds {
      * 流程ID
      */
     private Long flowInfoId;
+
 }

+ 46 - 56
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountRequestFundsServiceImpl.java

@@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.account.entity.account.dto.AccountRequestFundsDto;
 import com.fjhx.account.entity.account.dto.AccountRequestFundsSelectDto;
 import com.fjhx.account.entity.account.po.AccountRequestFunds;
-import com.fjhx.account.entity.account.vo.AccountRequestFundsDetailVo;
+import com.fjhx.account.entity.account.po.AccountRequestFundsDetail;
 import com.fjhx.account.entity.account.vo.AccountRequestFundsVo;
 import com.fjhx.account.mapper.account.AccountRequestFundsMapper;
 import com.fjhx.account.service.account.AccountRequestFundsDetailService;
@@ -19,11 +19,14 @@ import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.entity.corporation.po.Corporation;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.flow.entity.flow.po.FlowExample;
+import com.fjhx.flow.entity.flow.po.FlowInfo;
 import com.fjhx.flow.service.flow.FlowExampleService;
+import com.fjhx.flow.service.flow.FlowInfoService;
 import com.obs.services.internal.ServiceException;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -70,63 +73,54 @@ public class AccountRequestFundsServiceImpl extends ServiceImpl<AccountRequestFu
         wrapper.like(ObjectUtil.isNotEmpty(dto.getKeyword()), "arf.payment_remarks", dto.getKeyword());
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getWriteOffStatus()), "arf.write_off_status", dto.getWriteOffStatus());
         wrapper.orderByDesc("ap.status", "arf.payment_time", "arf.create_time");
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getType()), "arf.type", dto.getType());
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), "arf.status", dto.getStatus());
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getPaymentStatus()), "ap.status", dto.getPaymentStatus());
+        wrapper.like(ObjectUtil.isNotEmpty(dto.getKeyword()), "arf.payment_remarks", dto.getKeyword());
+        wrapper.orderByDesc("ap.status", "arf.payment_time", "arf.create_time");
         Page<AccountRequestFundsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
-        //赋值部门名称、归属公司名称
+
         List<AccountRequestFundsVo> records = page.getRecords();
         if (ObjectUtil.isEmpty(records)) {
+
+        if (ObjectUtil.isEmpty(records)) {
             return page;
         }
 
-        //切换数据源
-        DynamicDataSourceContextHolder.push(SourceConstant.COMMON);
-        //查询公司名称信息
-        List<Corporation> corporationList = corporationService.list();
-        Map<Long, List<Corporation>> corporationMap = corporationList.stream().collect(Collectors.groupingBy(Corporation::getId));
-        DynamicDataSourceContextHolder.poll();
+        // 赋值用户名称
+        UserUtil.assignmentNickName(records, BasePo::getCreateUser, AccountRequestFundsVo::setUserName);
 
+        // 赋值公司名称信息
+        corporationService.attributeAssign(records, AccountRequestFunds::getCorporationId, (item, corporation) -> {
+            item.setCorporationName(corporation.getName());
+        });
 
-        //切换数据源
+        // 切换数据源
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
-        //查询部门信息
-        List<SysDept> sysDeptList = sysDeptService.list();
-        Map<Long, List<SysDept>> sysDeptMap = sysDeptList.stream().collect(Collectors.groupingBy(SysDept::getDeptId));
-
-        //根据业务ID列表获取流程实例Id列表
-        List<Long> ids = records.stream().map(AccountRequestFundsVo::getId).collect(Collectors.toList());
-        List<FlowExample> flowExamples = flowExampleService.list(Wrappers.<FlowExample>lambdaQuery().in(FlowExample::getBusinessId, ids));
-        Map<Long, List<FlowExample>> flowInfoMap = flowExamples.stream().collect(Collectors.groupingBy(FlowExample::getBusinessId));
-
-
-        for (AccountRequestFundsVo record : records) {
-            //赋值部门信息
-            List<SysDept> sysDepts = sysDeptMap.get(record.getDepartmentId());
-            if (ObjectUtil.isNotEmpty(sysDepts)) {
-                record.setDeptName(sysDepts.get(0).getDeptName());
-            }
-
-            //赋值公司信息
-            List<Corporation> corporations = corporationMap.get(record.getCorporationId());
-            if (ObjectUtil.isNotEmpty(corporations)) {
-                record.setCorporationName(corporations.get(0).getName());
-            }
-
-            //赋值流程ID
-            List<FlowExample> flowInfoList = flowInfoMap.get(record.getId());
-            if (ObjectUtil.isEmpty(flowInfoList)) {
-                throw new ServiceException("数据有误:该请款没有找到流程详情信息信息");
-            }
-            record.setFlowInfoId(flowInfoList.get(0).getId());
-        }
 
-        // 赋值用户名称
-        UserUtil.assignmentNickName(records, BasePo::getCreateUser, AccountRequestFundsVo::setUserName);
+        // 赋值流程实例id
+        flowExampleService.attributeAssign(records, BaseIdPo::getId, (item, flowExample) -> {
+            item.setFlowInfoId(flowExample.getId());
+        });
+
+        // 查询部门id列表
+        List<Long> deptIdList = records.stream()
+                .map(AccountRequestFunds::getDepartmentId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+
+        List<SysDept> sysDeptList = sysDeptService.listByIds(deptIdList);
+        Map<Long, String> deptMap = sysDeptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
+        records.forEach(item -> item.setDeptName(deptMap.get(item.getDepartmentId())));
+
         DynamicDataSourceContextHolder.poll();
+
         return page;
     }
 
     /**
      * 查询请款详情
-     *
      * @param id
      * @return
      */
@@ -135,32 +129,28 @@ public class AccountRequestFundsServiceImpl extends ServiceImpl<AccountRequestFu
         AccountRequestFunds accountRequestFunds = this.getById(id);
         AccountRequestFundsVo accountRequestFundsVo = BeanUtil.toBean(accountRequestFunds, AccountRequestFundsVo.class);
 
-        //获取到请款明细信息
-//        List<AccountRequestFundsDetail> accountRequestFundsDetailList = accountRequestFundsDetailService
-//                .list(Wrappers.<AccountRequestFundsDetail>lambdaQuery()
-//                        .eq(AccountRequestFundsDetail::getAccountRequestFundsId, accountRequestFunds.getId()));
-        List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos =
-                accountRequestFundsDetailService.listByAccountRequestFundsId(accountRequestFunds.getId());
-        accountRequestFundsVo.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
-
-        //切换数据源
-        DynamicDataSourceContextHolder.push(SourceConstant.COMMON);
-        //查询归属公司的名称
+        // 获取到请款明细信息
+        List<AccountRequestFundsDetail> accountRequestFundsDetailList = accountRequestFundsDetailService.list(q -> q
+                .eq(AccountRequestFundsDetail::getAccountRequestFundsId, accountRequestFunds.getId()));
+
+        accountRequestFundsVo.setAccountRequestFundsDetailList(accountRequestFundsDetailList);
+
+        // 查询归属公司的名称
         Corporation corporation = corporationService.getById(accountRequestFundsVo.getCorporationId());
         if (ObjectUtil.isEmpty(corporation)) {
             throw new ServiceException("没有找到归属公司信息");
         }
         accountRequestFundsVo.setCorporationName(corporation.getName());
 
-        //切换数据源
+        // 切换数据源
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
-        //查询部门名称信息
+        // 查询部门名称信息
         SysDept sysDept = sysDeptService.getById(accountRequestFundsVo.getDepartmentId());
         if (ObjectUtil.isEmpty(sysDept)) {
             throw new ServiceException("没有找到归属部门信息");
         }
         accountRequestFundsVo.setDeptName(sysDept.getDeptName());
-        //赋值合同编号
+        DynamicDataSourceContextHolder.poll();
 
         return accountRequestFundsVo;
     }