feat: 申请代码bug修复

new
chenqp 1 year ago
parent 286fc5b74a
commit f897e341b3

@ -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<ExpenseApplyTripDO> 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<PageResult<ExpenseApplyRespVO>> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) {
public CommonResult<PageResult<ExpenseApplyDO>> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO 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")

@ -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<ExpenseApplyDO> {
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;
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<ExpenseApplyMapper, Exp
@Resource
private AdminUserApi adminUserApi;
@Resource
private DeptApi deptApi;
@Resource
private ExpenseApplyTripService expenseApplyTripService;
@Resource
private BpmProcessInstanceApi processInstanceApi;
@ -205,4 +205,22 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
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;
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 = "出差天数")

@ -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;
}

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

Loading…
Cancel
Save