|
|
@@ -1,11 +1,15 @@
|
|
|
package cn.iocoder.yudao.module.expense.controller.admin.expenseitem;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseitem.vo.ExpenseItemPageReqVO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseitem.vo.ExpenseItemRespVO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseitem.vo.ExpenseItemSaveReqVO;
|
|
|
@@ -23,6 +27,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
@@ -36,6 +43,9 @@ public class ExpenseItemController {
|
|
|
@Resource
|
|
|
private ExpenseItemService itemService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建报销费用项目信息")
|
|
|
// @PreAuthorize("@ss.hasPermission('expense:item:create')")
|
|
|
@@ -74,7 +84,20 @@ public class ExpenseItemController {
|
|
|
// @PreAuthorize("@ss.hasPermission('expense:item:query')")
|
|
|
public CommonResult<PageResult<ExpenseItemRespVO>> getItemPage(@Valid @ParameterObject ExpenseItemPageReqVO pageReqVO) {
|
|
|
PageResult<ExpenseItemDO> pageResult = itemService.getItemPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, ExpenseItemRespVO.class));
|
|
|
+ PageResult<ExpenseItemRespVO> voPageResult = BeanUtils.toBean(pageResult, ExpenseItemRespVO.class);
|
|
|
+ List<ExpenseItemRespVO> list = voPageResult.getList();
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ List<Long> userIdList = list.stream().map(ExpenseItemRespVO::getCreator).collect(Collectors.toList());
|
|
|
+ List<EmployeeRespDTO> employeeRespDTOList = employeeApi.getEmployeeListByUserIds(userIdList);
|
|
|
+ Map<Long, EmployeeRespDTO> longEmployeeRespDTOMap = CollectionUtils.convertMap(employeeRespDTOList, EmployeeRespDTO::getUserId);
|
|
|
+ for (ExpenseItemRespVO expenseItemRespVO : list) {
|
|
|
+ EmployeeRespDTO employeeRespDTO = longEmployeeRespDTOMap.get(expenseItemRespVO.getCreator());
|
|
|
+ if (Objects.nonNull(employeeRespDTO)) {
|
|
|
+ expenseItemRespVO.setCreateEmployeeName(employeeRespDTO.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return success(voPageResult);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|