Merge remote-tracking branch 'origin/master'

new
fNumb 1 year ago
commit e1e9dd5192

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.controller.admin.expenseapply; 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.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@ -23,8 +24,11 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@ -67,8 +71,8 @@ public class ExpenseApplyController {
queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId()); queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId());
List<ExpenseApplyTripDO> list = expenseApplyTripService.list(queryWrapper); List<ExpenseApplyTripDO> list = expenseApplyTripService.list(queryWrapper);
expenseApply.setExpenseApplyTrips(list); expenseApply.setExpenseApplyTrips(list);
//cqptodo 需要设置用户名,部门返回前端 expenseApplyService.setNickNameField(CollUtil.toList(expenseApply));
// expenseApplyService.setRepField(expenseApply); expenseApplyService.setDeptNameField(CollUtil.toList(expenseApply));
} }
return success(expenseApply); return success(expenseApply);
} }
@ -85,9 +89,26 @@ public class ExpenseApplyController {
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得申请单分页") @Operation(summary = "获得申请单分页")
@PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')")
public CommonResult<PageResult<ExpenseApplyRespVO>> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) { public CommonResult<PageResult<ExpenseApplyDO>> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) {
PageResult<ExpenseApplyDO> pageResult = expenseApplyService.getExpenseApplyPage(pageVO); PageResult<ExpenseApplyDO> pageResult = expenseApplyService.getExpenseApplyPage(pageVO);
return success(ExpenseApplyConvert.INSTANCE.convertPage(pageResult)); List<ExpenseApplyDO> list = pageResult.getList();
if (CollUtil.isNotEmpty(list)) {
//cqptodo 待设置用户名称
expenseApplyService.setNickNameField(list);
List<Long> applids = list.stream().map(ExpenseApplyDO::getId).collect(Collectors.toList());
LambdaQueryWrapperX<ExpenseApplyTripDO> queryWrapper = new LambdaQueryWrapperX<>();
queryWrapper.in(ExpenseApplyTripDO::getApplyId, applids);
List<ExpenseApplyTripDO> tripList = expenseApplyTripService.list(queryWrapper);
Map<Long, ExpenseApplyDO> 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") @GetMapping("/export-excel")

@ -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.ExpenseApplyCreateReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; 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.ExpenseApplyPageReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -72,4 +72,7 @@ public interface ExpenseApplyService extends IService<ExpenseApplyDO> {
void processInstanceCallBack(long id, Integer result); void processInstanceCallBack(long id, Integer result);
void setNickNameField(List<ExpenseApplyDO> list);
void setDeptNameField(List<ExpenseApplyDO> toList);
} }

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.bpm.service.expenseapply; package cn.iocoder.yudao.module.bpm.service.expenseapply;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.exception.ErrorCode; 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.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; 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.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser; 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.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; 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.BillTypeEnum;
import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum;
import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; 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.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -34,10 +34,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Validator; import javax.validation.Validator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Collection; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
@ -61,6 +59,8 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
@Resource @Resource
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@Resource @Resource
private DeptApi deptApi;
@Resource
private ExpenseApplyTripService expenseApplyTripService; private ExpenseApplyTripService expenseApplyTripService;
@Resource @Resource
private BpmProcessInstanceApi processInstanceApi; private BpmProcessInstanceApi processInstanceApi;
@ -205,4 +205,22 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
updateById(apply); updateById(apply);
} }
} }
@Override
public void setNickNameField(List<ExpenseApplyDO> list) {
List<Long> userIds = list.stream().map(ExpenseApplyDO::getUserId).distinct().collect(Collectors.toList());
Map<Long, String> 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<ExpenseApplyDO> list) {
List<Long> deptIds = list.stream().map(ExpenseApplyDO::getDeptId).distinct().collect(Collectors.toList());
Map<Long, String> deptMap = deptApi.getDeptList(deptIds).stream().collect(Collectors.toMap(DeptRespDTO::getId, dept -> dept.getName()));
for (ExpenseApplyDO expenseApply : list) {
expenseApply.setDeptName(deptMap.get(expenseApply.getDeptId()));
}
}
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -10,6 +11,7 @@ import java.time.LocalDateTime;
import java.util.Set; 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.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/** /**
* Base VO VO 使 * Base VO VO 使
@ -31,11 +33,13 @@ public class ExpenseApplyTripBaseVO {
@Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开始日期不能为空") @NotNull(message = "开始日期不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @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; private LocalDateTime startTime;
@Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束日期不能为空") @NotNull(message = "结束日期不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @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; private LocalDateTime endTime;
@Schema(description = "出差天数") @Schema(description = "出差天数")

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply; package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply;
import cn.iocoder.yudao.framework.common.pojo.ImageVo; 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.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
@ -96,5 +95,5 @@ public class ExpenseApplyDO extends TenantBaseDO {
@TableField(exist = false) @TableField(exist = false)
private String nickname; private String nickname;
@TableField(exist = false) @TableField(exist = false)
private String detpName; private String deptName;
} }

@ -44,14 +44,7 @@ public class ExpenseApplyTripDO extends TenantBaseDO {
*/ */
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private List<ImageVo> files; private List<ImageVo> files;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
/** /**
* ID * ID
*/ */

Loading…
Cancel
Save