feat: 申请单开发

new
chenqp 1 year ago
parent f0250d96d9
commit 286fc5b74a

@ -67,6 +67,8 @@ public class ExpenseApplyController {
queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId());
List<ExpenseApplyTripDO> list = expenseApplyTripService.list(queryWrapper);
expenseApply.setExpenseApplyTrips(list);
//cqptodo 需要设置用户名,部门返回前端
// expenseApplyService.setRepField(expenseApply);
}
return success(expenseApply);
}

@ -71,4 +71,5 @@ public interface ExpenseApplyService extends IService<ExpenseApplyDO> {
List<ExpenseApplyDO> getExpenseApplyList(ExpenseApplyExportReqVO exportReqVO);
void processInstanceCallBack(long id, Integer result);
}

@ -3,9 +3,12 @@ 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;
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;
@ -32,6 +35,7 @@ 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;
@ -58,7 +62,7 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
private AdminUserApi adminUserApi;
@Resource
private ExpenseApplyTripService expenseApplyTripService;
// @Resource
@Resource
private BpmProcessInstanceApi processInstanceApi;
@Override
public CommonResult createExpenseApply(ExpenseApplyCreateReqVO createReqVO) {
@ -75,15 +79,19 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
for (ExpenseApplyTripDO trip : trips) {
trip.setApplyId(expenseApply.getId());
}
expenseApplyTripService.saveOrUpdateBatch(trips);
//采用先删后增的方式来
//删除行程明细
expenseApplyTripService.remove(new LambdaQueryWrapperX<ExpenseApplyTripDO>().eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId()));
expenseApplyTripService.saveBatch(trips);
}
if (expenseApply.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) {
Map<String, Object> variables = BeanUtil.beanToMap(expenseApply);
//cqptodo 提交单据,创建工作流
Map<String, Object> variables = new HashMap<>();
variables.put("billType", expenseApply.getBillType());
variables.put("amount", expenseApply.getAmount());
variables.put("deptId", expenseApply.getDeptId());
String processInstanceId = processInstanceApi.createProcessInstance(expenseApply.getUserId(),
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(variables).setBusinessKey(String.valueOf(expenseApply.getId())));
//cqptodo 待测试是否会更新其它字段 将工作流的编号,更新到单据中
updateById(new ExpenseApplyDO().setId(expenseApply.getId()).setProcessInstanceId(processInstanceId));
}
// 返回
@ -120,7 +128,7 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
expenseApply.setApplyNo(RandomUtil.randomString(6));
}else {
ExpenseApplyDO dbApply = validateExpenseApplyExists(expenseApply.getId());
if (!dbApply.getStatus().equals(ExpenseApplyStatusEnum.NOSUBMIT)) {
if (!dbApply.getStatus().equals(ExpenseApplyStatusEnum.NOSUBMIT.getValue())) {
//只有未提交才能更新
return CommonResult.error("只有未提交单据才能更新");
}
@ -136,9 +144,15 @@ public class ExpenseApplyServiceImpl extends ServiceImpl<ExpenseApplyMapper, Exp
@Override
public void deleteExpenseApply(Long id) {
// 校验存在
validateExpenseApplyExists(id);
ExpenseApplyDO apply = validateExpenseApplyExists(id);
if (!apply.getStatus().equals(ExpenseApplyStatusEnum.NOSUBMIT.getValue())) {
//只有未提交才能更新
throw exception(new ErrorCode(500, "单据状态不可操作,请刷新后重试"));
}
// 删除
expenseApplyMapper.deleteById(id);
//删除行程明细
expenseApplyTripService.remove(new LambdaQueryWrapperX<ExpenseApplyTripDO>().eq(ExpenseApplyTripDO::getApplyId, apply.getId()));
}
private ExpenseApplyDO validateExpenseApplyExists(Long id) {

@ -33,32 +33,32 @@ public class BpmMessageServiceImpl implements BpmMessageService {
@Override
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) {
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
// Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
// BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
}
@Override
public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) {
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
templateParams.put("reason", reqDTO.getReason());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
// Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("reason", reqDTO.getReason());
// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
// BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
}
@Override
public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) {
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
templateParams.put("taskName", reqDTO.getTaskName());
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(),
BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
// Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("taskName", reqDTO.getTaskName());
// templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(),
// BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
}
private String getProcessInstanceDetailUrl(String taskId) {

@ -1,17 +1,14 @@
package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.math.BigDecimal;
import javax.validation.constraints.*;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
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;
/**

@ -91,4 +91,10 @@ public class ExpenseApplyDO extends TenantBaseDO {
@TableField(exist = false)
private List<ExpenseApplyTripDO> expenseApplyTrips;
@TableField(exist = false)
private Boolean deleted;
@TableField(exist = false)
private String nickname;
@TableField(exist = false)
private String detpName;
}

@ -3,17 +3,17 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip;
import cn.iocoder.yudao.framework.common.pojo.ImageVo;
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
/**
* DO
@ -91,5 +91,6 @@ public class ExpenseApplyTripDO extends TenantBaseDO {
*
*/
private BigDecimal amount;
@TableField(exist = false)
private Boolean deleted;
}

Loading…
Cancel
Save