报销明细查询修改,

针对以前的数据,判断没有部门编号的明细, 手动添加发起人部门编号
This commit is contained in:
furongxin 2024-04-28 15:34:19 +08:00
parent c254265a68
commit 92b27432f9
8 changed files with 87 additions and 33 deletions

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.oa;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAReimbursementConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
@ -34,7 +35,7 @@ public class BpmOAReimbursementController {
@PostMapping("/create")
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:create')")
@Operation(summary = "创建请求申请")
public CommonResult<Long> createLeave(@Valid @RequestBody BpmOAReimbursementCreateReqVO createReqVO) {
public CommonResult<Long> createReimbursement(@Valid @RequestBody BpmOAReimbursementCreateReqVO createReqVO) {
return success(service.createReimbursement(getLoginUserId(), createReqVO));
}
@ -42,9 +43,10 @@ public class BpmOAReimbursementController {
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:query')")
@Operation(summary = "获得报销申请")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<?> getLeave(@RequestParam("id") Long id) {
public CommonResult<BpmOAReimbursementRespVO> getReimbursement(@RequestParam("id") Long id) {
BpmOAReimbursementDO reimbursement = service.getReimbursement(id);
return success(BpmOAReimbursementConvert.INSTANCE.convert(reimbursement));
return success(service.convert(reimbursement));
}
// @GetMapping("/page")

View File

@ -29,7 +29,7 @@ public class BpmOAReimbursementRespVO extends BpmOABaseRespVO {
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "报销项目不能为空")
private List<Reimbursement> reimbursements;
private List<ReimbursementDTO> reimbursements;
@Schema(description = "报销总金额", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "报销总金额不能为空")

View File

@ -18,14 +18,11 @@ public class Reimbursement {
@Schema(description = "所属部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "128")
private Long deptId;
@Schema(description = "所属部门名称", example = "研发部")
private String deptName;
@Schema(description = "报销金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "23.45")
private BigDecimal money;
@Schema(description = "报销类别 字典值 参考 bpm_oa_reimbursement_type", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer type;
private String type;
@Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-09 12:31:12")
private Date happenTime;

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 功能描述 报销项目明细
* 前端返回值用
*/
@Data
public class ReimbursementDTO {
@Schema(description = "所属部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "128")
private Long deptId;
@Schema(description = "所属部门名称", example = "研发部")
private String deptName;
@Schema(description = "报销金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "23.45")
private BigDecimal money;
@Schema(description = "报销类别 字典值 参考 bpm_oa_reimbursement_type", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private String type;
@Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-09 12:31:12")
private Date happenTime;
@Schema(description = "发票张数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3")
private Integer quantity ;
@Schema(description = "费用明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "请吃饭")
private String detail ;
@Schema(description = "采购计划编号", example = "1")
private Long procureId;
}

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ReimbursementDTO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import org.mapstruct.Mapper;
@ -24,14 +25,12 @@ public interface BpmOAReimbursementConvert {
BpmOAReimbursementDO convert(BpmOAReimbursementCreateReqVO bean);
BpmOAReimbursementRespVO convert(BpmOAReimbursementDO bean);
default List<Reimbursement> convertList(List<Reimbursement> list, Map<Long, DeptRespDTO> deptMap) {
default List<ReimbursementDTO> convertList(List<ReimbursementDTO> list, Map<Long, DeptRespDTO> deptMap) {
return CollectionUtils.convertList(list, reimbursement -> convert(reimbursement, deptMap.get(reimbursement.getDeptId())));
}
default Reimbursement convert(Reimbursement reimbursement, DeptRespDTO dept) {
default ReimbursementDTO convert(ReimbursementDTO reimbursement, DeptRespDTO dept) {
if (dept != null) {
reimbursement.setDeptName(dept.getName());

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.service.oa;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
import javax.validation.Valid;
@ -40,13 +41,5 @@ public interface BpmOAReimbursementService {
*/
BpmOAReimbursementDO getReimbursement(Long id);
/**
* 获得请假申请分页
*
* @param userId 用户编号
* @param pageReqVO 分页查询
* @return 请假申请分页
*/
// PageResult<BpmOAReimbursementDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO);
BpmOAReimbursementRespVO convert(BpmOAReimbursementDO bpmOAReimbursementDO);
}

View File

@ -1,11 +1,14 @@
package cn.iocoder.yudao.module.bpm.service.oa;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
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.controller.admin.oa.vo.procure.BpmOAProcureListEditReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ReimbursementDTO;
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAReimbursementConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAImprestDO;
@ -17,6 +20,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
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 org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -24,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@ -71,6 +73,9 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
@Resource
private DeptApi deptApi;
@Resource
private AdminUserApi userApi;
@Override
public Long createReimbursement(Long userId, BpmOAReimbursementCreateReqVO createReqVO) {
BpmOAReimbursementDO reimbursement = BpmOAReimbursementConvert.INSTANCE.convert(createReqVO).setUserId(userId)
@ -97,7 +102,7 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
for (Reimbursement data : reimbursement.getReimbursements()) {
//报销类别为 采购费时
if (data.getType() == 4) {
if ("4".equals(data.getType())) {
BpmOAProcureDO procureDO = bpmOAProcureService.getOaProcure(data.getProcureId());
if (procureDO != null) {
@ -158,7 +163,7 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
for (Reimbursement reimbursement : reimbursements) {
//报销类别为 采购费时
if (reimbursement.getType() == 4) {
if ("4".equals(reimbursement.getType())) {
BpmOAProcureDO procureDO = bpmOAProcureService.getOaProcure(reimbursement.getProcureId());
if (procureDO != null) {
@ -208,7 +213,7 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
for (Reimbursement reimbursement : reimbursements) {
//报销类别为 采购费时
if (reimbursement.getType() == 4) {
if ("4".equals(reimbursement.getType())) {
BpmOAProcureDO procureDO = bpmOAProcureService.getOaProcure(reimbursement.getProcureId());
if (procureDO != null) {
@ -241,7 +246,12 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
@Override
public BpmOAReimbursementDO getReimbursement(Long id) {
BpmOAReimbursementDO reimbursementDO = reimbursementMapper.selectById(id);
return reimbursementMapper.selectById(id);
}
@Override
public BpmOAReimbursementRespVO convert(BpmOAReimbursementDO reimbursementDO) {
List<Reimbursement> reimbursement = reimbursementDO.getReimbursements();
//直接从数据库取出来的List<Reimbursement> 实际上是List<LinkedHashMap>类型 所以不能直接遍历
@ -249,11 +259,25 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
String json = JsonUtils.toJsonString(reimbursement);
reimbursement = JsonUtils.parseArray(json, Reimbursement.class);
//针对之前的数据 没有设置明细所属部门的 手动设置发起人的部门编号
AdminUserRespDTO userRespDTO = userApi.getUser(reimbursementDO.getUserId()).getCheckedData();
for (Reimbursement data : reimbursement) {
if (data.getDeptId() != null) {
break;
}
data.setDeptId(userRespDTO.getDeptId());
}
//获取部门信息map
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(reimbursement, Reimbursement::getDeptId));
//插入部门名称
reimbursementDO.setReimbursements(BpmOAReimbursementConvert.INSTANCE.convertList(reimbursement, deptMap));
List<ReimbursementDTO> reimbursementDTOS = BeanUtils.toBean(reimbursement, ReimbursementDTO.class);
return reimbursementDO;
BpmOAReimbursementRespVO bpmOAReimbursementRespVO = BeanUtils.toBean(reimbursementDO, BpmOAReimbursementRespVO.class);
bpmOAReimbursementRespVO.setReimbursements(BpmOAReimbursementConvert.INSTANCE.convertList(reimbursementDTOS, deptMap)); //拼接数据
return bpmOAReimbursementRespVO;
}
}