diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseclaim/ExpenseClaimController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseclaim/ExpenseClaimController.java index 356b3361..699df137 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseclaim/ExpenseClaimController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseclaim/ExpenseClaimController.java @@ -130,8 +130,6 @@ public class ExpenseClaimController { PageResult pageResult = expenseClaimService.getExpenseClaimPage(pageVO); List list = pageResult.getList(); if (CollUtil.isNotEmpty(list)) { - - expenseClaimService.setNickNameField(list); taskService.handleApprovalAuthority(list); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimService.java index be8cd564..f093814b 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimService.java @@ -73,4 +73,6 @@ public interface ExpenseClaimService extends MPJBaseService { void setNickNameField(List toList); void setDeptNameField(List toList); + + void processInstanceCallBack(long id, Integer result); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimServiceImpl.java index 80817220..834cc558 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseclaim/ExpenseClaimServiceImpl.java @@ -4,16 +4,22 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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; +import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.module.bpm.service.expenseclaimdetail.ExpenseClaimDetailService; import cn.iocoder.yudao.module.bpm.service.expenseclaimtrip.ExpenseClaimTripService; import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.*; import cn.iocoder.yudao.module.bs.convert.expenseclaim.ExpenseClaimConvert; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseclaim.ExpenseClaimDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseclaimdetail.ExpenseClaimDetailDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseclaimtrip.ExpenseClaimTripDO; import cn.iocoder.yudao.module.bs.dal.mysql.expenseclaim.ExpenseClaimMapper; import cn.iocoder.yudao.module.bs.enums.BillTypeEnum; import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; +import cn.iocoder.yudao.module.bs.enums.ExpenseClaimSettleStatusEnum; 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; @@ -26,9 +32,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Collection; -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; @@ -44,7 +48,7 @@ import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_CLAIM_ @Validated @Transactional(rollbackFor = Exception.class) public class ExpenseClaimServiceImpl extends MPJBaseServiceImpl implements ExpenseClaimService { - + public static final String PROCESS_KEY = "expense_claim"; @Resource private ExpenseClaimMapper expenseClaimMapper; @Resource @@ -57,6 +61,8 @@ public class ExpenseClaimServiceImpl extends MPJBaseServiceImpl trips = ExpenseClaimConvert.INSTANCE.convert(createReqVO.getExpenseClaimTrips()); + for (ExpenseClaimTripDO trip : trips) { + trip.setClaimId(expenseClaim.getId()); + } + expenseClaimTripService.remove(new LambdaQueryWrapperX().eq(ExpenseClaimTripDO::getClaimId, expenseClaim.getId())); + expenseClaimTripService.saveBatch(trips); + expenseClaimDetailService.remove(new LambdaQueryWrapperX().eq(ExpenseClaimDetailDO::getClaimId, expenseClaim.getId())); + List allDetais = new ArrayList<>(); + for (ExpenseClaimTripDO trip : trips) { + List details = trip.getExpenseClaimDetails(); + for (ExpenseClaimDetailDO detail : details) { + detail.setClaimId(expenseClaim.getId()); + detail.setTripId(trip.getId()); + } + allDetais.addAll(details); + } + expenseClaimDetailService.saveBatch(allDetais); + } else { + expenseClaimDetailService.remove(new LambdaQueryWrapperX().eq(ExpenseClaimDetailDO::getClaimId, expenseClaim.getId())); + List details = expenseClaim.getExpenseClaimDetails(); + for (ExpenseClaimDetailDO detail : details) { + detail.setClaimId(expenseClaim.getId()); + detail.setTripId(null); + } + expenseClaimDetailService.saveBatch(details); + } + if (expenseClaim.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) { + Map variables = new HashMap<>(); + variables.put("billType", expenseClaim.getBillType()); + variables.put("amount", expenseClaim.getAmount()); + variables.put("deptId", expenseClaim.getDeptId()); + String processInstanceId = processInstanceApi.createProcessInstance(expenseClaim.getUserId(), + new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) + .setVariables(variables).setBusinessKey(String.valueOf(expenseClaim.getId()))); + updateById(new ExpenseClaimDO().setId(expenseClaim.getId()).setProcessInstanceId(processInstanceId)); + } // 返回 return CommonResult.success(); } @@ -181,4 +224,29 @@ public class ExpenseClaimServiceImpl extends MPJBaseServiceImpl files; @Schema(description = "行程明细,仅为差旅报销单的时候需要传", example = "") + @Valid private List expenseClaimTrips; @Schema(description = "费用明细,仅为日常报销单的时候需要传", example = "") + @Valid private List expenseClaimDetails; @AssertTrue(message = "差旅报销单的行程明细及其报销明细不能为空") diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseclaim/vo/ExpenseClaimTripCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseclaim/vo/ExpenseClaimTripCreateReqVO.java index a9be9710..c4260264 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseclaim/vo/ExpenseClaimTripCreateReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseclaim/vo/ExpenseClaimTripCreateReqVO.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.math.BigDecimal; @@ -57,5 +58,7 @@ public class ExpenseClaimTripCreateReqVO { private BigDecimal amount; @Schema(description = "费用明细", example = "") + @Valid + @NotEmpty(message = "费用明细expenseClaimDetails不能为空") private List expenseClaimDetails; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseclaim/ExpenseClaimConvert.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseclaim/ExpenseClaimConvert.java index 5034aa9e..41f09f20 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseclaim/ExpenseClaimConvert.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseclaim/ExpenseClaimConvert.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.module.bs.convert.expenseclaim; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.ExpenseClaimCreateReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.ExpenseClaimExcelVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.ExpenseClaimRespVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.ExpenseClaimUpdateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.ExpenseApplyTripCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseclaim.vo.*; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseclaim.ExpenseClaimDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseclaimtrip.ExpenseClaimTripDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -32,5 +32,6 @@ public interface ExpenseClaimConvert { PageResult convertPage(PageResult page); List convertList02(List list); - + ExpenseClaimTripDO convert(ExpenseClaimTripCreateReqVO bean); + List convert(List bean); }