diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java index 0801a9a3..4f063ec6 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bpm.controller.admin.expenseapply; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -23,8 +24,11 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -67,8 +71,8 @@ public class ExpenseApplyController { queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId()); List list = expenseApplyTripService.list(queryWrapper); expenseApply.setExpenseApplyTrips(list); - //cqptodo 需要设置用户名,部门返回前端 -// expenseApplyService.setRepField(expenseApply); + expenseApplyService.setNickNameField(CollUtil.toList(expenseApply)); + expenseApplyService.setDeptNameField(CollUtil.toList(expenseApply)); } return success(expenseApply); } @@ -85,9 +89,26 @@ public class ExpenseApplyController { @GetMapping("/page") @Operation(summary = "获得申请单分页") @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") - public CommonResult> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) { + public CommonResult> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) { PageResult pageResult = expenseApplyService.getExpenseApplyPage(pageVO); - return success(ExpenseApplyConvert.INSTANCE.convertPage(pageResult)); + List list = pageResult.getList(); + if (CollUtil.isNotEmpty(list)) { + //cqptodo 待设置用户名称 + expenseApplyService.setNickNameField(list); + List applids = list.stream().map(ExpenseApplyDO::getId).collect(Collectors.toList()); + LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); + queryWrapper.in(ExpenseApplyTripDO::getApplyId, applids); + List tripList = expenseApplyTripService.list(queryWrapper); + Map applyDOMap = list.stream().collect(Collectors.toMap(ExpenseApplyDO::getId, eat -> eat)); + for (ExpenseApplyTripDO tripDO : tripList) { + ExpenseApplyDO apply = applyDOMap.get(tripDO.getApplyId()); + if (apply.getExpenseApplyTrips() == null) { + apply.setExpenseApplyTrips(new ArrayList<>()); + } + apply.getExpenseApplyTrips().add(tripDO); + } + } + return success(pageResult); } @GetMapping("/export-excel") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java index f252e6e5..b759dcb0 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java @@ -5,11 +5,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; import com.baomidou.mybatisplus.extension.service.IService; import javax.validation.Valid; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -72,4 +72,7 @@ public interface ExpenseApplyService extends IService { void processInstanceCallBack(long id, Integer result); + void setNickNameField(List list); + + void setDeptNameField(List toList); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java index 15f47cb2..186e795d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.bpm.service.expenseapply; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.exception.ErrorCode; @@ -8,7 +7,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; @@ -24,6 +22,8 @@ import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; import cn.iocoder.yudao.module.bs.enums.BillTypeEnum; import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -34,10 +34,8 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import javax.validation.Validator; import java.math.BigDecimal; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; @@ -61,6 +59,8 @@ public class ExpenseApplyServiceImpl extends ServiceImpl list) { + List userIds = list.stream().map(ExpenseApplyDO::getUserId).distinct().collect(Collectors.toList()); + Map userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(AdminUserRespDTO::getId, user -> user.getNickname())); + for (ExpenseApplyDO expenseApply : list) { + expenseApply.setNickname(userMap.get(expenseApply.getUserId())); + } + } + + @Override + public void setDeptNameField(List list) { + List deptIds = list.stream().map(ExpenseApplyDO::getDeptId).distinct().collect(Collectors.toList()); + Map deptMap = deptApi.getDeptList(deptIds).stream().collect(Collectors.toMap(DeptRespDTO::getId, dept -> dept.getName())); + for (ExpenseApplyDO expenseApply : list) { + expenseApply.setDeptName(deptMap.get(expenseApply.getDeptId())); + } + } } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java index 2eb69273..fc0c0402 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -10,6 +11,7 @@ import java.time.LocalDateTime; import java.util.Set; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; /** * 申请单行程明细 Base VO,提供给添加、修改、详细的子 VO 使用 @@ -31,11 +33,13 @@ public class ExpenseApplyTripBaseVO { @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "开始日期不能为空") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) private LocalDateTime startTime; @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "结束日期不能为空") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) private LocalDateTime endTime; @Schema(description = "出差天数") diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java index a43bcfa3..98522028 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply; import cn.iocoder.yudao.framework.common.pojo.ImageVo; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import com.baomidou.mybatisplus.annotation.KeySequence; @@ -96,5 +95,5 @@ public class ExpenseApplyDO extends TenantBaseDO { @TableField(exist = false) private String nickname; @TableField(exist = false) - private String detpName; + private String deptName; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java index bed5db48..523e1ce7 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java @@ -44,14 +44,7 @@ public class ExpenseApplyTripDO extends TenantBaseDO { */ @TableField(typeHandler = JacksonTypeHandler.class) private List files; - /** - * 创建者 - */ - private String createBy; - /** - * 更新者 - */ - private String updateBy; + /** * 申请单ID */