代码提交 请假 出差完成

This commit is contained in:
123 2025-05-15 11:45:00 +08:00
parent 485f015c06
commit ec7100db91
7 changed files with 314 additions and 47 deletions

View File

@ -16,9 +16,9 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.dromara.workflow.common.ConditionalOnEnable; import org.dromara.workflow.common.ConditionalOnEnable;
import org.dromara.workflow.domain.bo.TestLeaveBo; import org.dromara.workflow.domain.bo.LxOaBusinessTripBo;
import org.dromara.workflow.domain.vo.TestLeaveVo; import org.dromara.workflow.domain.vo.LxOaBusinessTripVo;
import org.dromara.workflow.service.ITestLeaveService; import org.dromara.workflow.service.ILxOaBusinessTripService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -37,72 +37,72 @@ import java.util.List;
@RequestMapping("/workflow/businessTrip") @RequestMapping("/workflow/businessTrip")
public class OABusinessTripController extends BaseController { public class OABusinessTripController extends BaseController {
private final ITestLeaveService testLeaveService; private final ILxOaBusinessTripService lxOaBusinessTripService;
/** /**
* 查询出差列表 * 查询出差列表
*/ */
@SaCheckPermission("workflow:trip:list") @SaCheckPermission("workflow:trip:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo<TestLeaveVo> list(TestLeaveBo bo, PageQuery pageQuery) { public TableDataInfo<LxOaBusinessTripVo> list(LxOaBusinessTripBo bo, PageQuery pageQuery) {
return testLeaveService.queryPageList(bo, pageQuery); return lxOaBusinessTripService.queryPageList(bo, pageQuery);
} }
/** /**
* 导出请假列表 * 导出出差列表
*/ */
@SaCheckPermission("workflow:trip:export") @SaCheckPermission("workflow:trip:export")
@Log(title = "请假", businessType = BusinessType.EXPORT) @Log(title = "出差", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(TestLeaveBo bo, HttpServletResponse response) { public void export(LxOaBusinessTripBo bo, HttpServletResponse response) {
List<TestLeaveVo> list = testLeaveService.queryList(bo); List<LxOaBusinessTripVo> list = lxOaBusinessTripService.queryList(bo);
ExcelUtil.exportExcel(list, "请假", TestLeaveVo.class, response); ExcelUtil.exportExcel(list, "出差", LxOaBusinessTripVo.class, response);
} }
/** /**
* 获取请假详细信息 * 获取出差详细信息
* *
* @param id 主键 * @param id 主键
*/ */
@SaCheckPermission("workflow:trip:query") @SaCheckPermission("workflow:trip:query")
@GetMapping("/{id}") @GetMapping("/{id}")
public R<TestLeaveVo> getInfo(@NotNull(message = "主键不能为空") public R<LxOaBusinessTripVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) { @PathVariable Long id) {
return R.ok(testLeaveService.queryById(id)); return R.ok(lxOaBusinessTripService.queryById(id));
} }
/** /**
* 新增请假 * 新增出差
*/ */
@SaCheckPermission("workflow:trip:add") @SaCheckPermission("workflow:trip:add")
@Log(title = "请假", businessType = BusinessType.INSERT) @Log(title = "出差", businessType = BusinessType.INSERT)
@RepeatSubmit() @RepeatSubmit()
@PostMapping() @PostMapping()
public R<TestLeaveVo> add(@Validated(AddGroup.class) @RequestBody TestLeaveBo bo) { public R<LxOaBusinessTripVo> add(@Validated(AddGroup.class) @RequestBody LxOaBusinessTripBo bo) {
return R.ok(testLeaveService.insertByBo(bo)); return R.ok(lxOaBusinessTripService.insertByBo(bo));
} }
/** /**
* 修改请假 * 修改出差
*/ */
@SaCheckPermission("workflow:trip:edit") @SaCheckPermission("workflow:trip:edit")
@Log(title = "请假", businessType = BusinessType.UPDATE) @Log(title = "出差", businessType = BusinessType.UPDATE)
@RepeatSubmit() @RepeatSubmit()
@PutMapping() @PutMapping()
public R<TestLeaveVo> edit(@Validated(EditGroup.class) @RequestBody TestLeaveBo bo) { public R<LxOaBusinessTripVo> edit(@Validated(EditGroup.class) @RequestBody LxOaBusinessTripBo bo) {
return R.ok(testLeaveService.updateByBo(bo)); return R.ok(lxOaBusinessTripService.updateByBo(bo));
} }
/** /**
* 删除请假 * 删除出差
* *
* @param ids 主键串 * @param ids 主键串
*/ */
@SaCheckPermission("workflow:trip:remove") @SaCheckPermission("workflow:trip:remove")
@Log(title = "请假", businessType = BusinessType.DELETE) @Log(title = "出差", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) { @PathVariable Long[] ids) {
return toAjax(testLeaveService.deleteWithValidByIds(List.of(ids))); return toAjax(lxOaBusinessTripService.deleteWithValidByIds(List.of(ids)));
} }
} }

View File

@ -1,6 +1,5 @@
package org.dromara.workflow.domain.bo; package org.dromara.workflow.domain.bo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
@ -12,6 +11,7 @@ import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.domain.BaseEntity; import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.workflow.domain.LxOaBusinessTrip; import org.dromara.workflow.domain.LxOaBusinessTrip;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
@ -32,10 +32,10 @@ public class LxOaBusinessTripBo extends BaseEntity {
private Long id; private Long id;
/** /**
* 请假类型 * 业务类别
*/ */
@NotBlank(message = "请假类型不能为空", groups = {AddGroup.class, EditGroup.class}) @NotBlank(message = "业务类别不能为空", groups = {AddGroup.class, EditGroup.class})
private String leaveType; private String tripType;
/** /**
* 开始时间 * 开始时间
@ -52,48 +52,43 @@ public class LxOaBusinessTripBo extends BaseEntity {
private Date endDate; private Date endDate;
/** /**
* 请假天数 * 出差天数
*/ */
private Integer leaveDays; private Integer tripDays;
/** /**
* 开始时间 * 开始时间
*/ */
private Integer startLeaveDays; private Integer startTripDays;
/** /**
* 结束时间 * 结束时间
*/ */
private Integer endLeaveDays; private Integer endTripDays;
/** /**
* 请假原因 * 出差原因
*/ */
@ExcelProperty(value = "出差原因")
private String reason; private String reason;
/** /**
* 备注 * 备注
*/ */
@ExcelProperty(value = "备注")
private String remark; private String remark;
/** /**
* 在办项目 * 在办项目
*/ */
@ExcelProperty(value = "在办项目")
private String currentProjects; private String currentProjects;
/** /**
* 附件 * 附件
*/ */
@ExcelProperty(value = "附件")
private String attachment; private String attachment;
/** /**
* 预算事项 * 预算事项
*/ */
@ExcelProperty(value = "预算事项")
private String budgetType; private String budgetType;
/** /**
@ -107,4 +102,10 @@ public class LxOaBusinessTripBo extends BaseEntity {
private String dept; private String dept;
/**
* 差旅金额
*/
private BigDecimal tripMoney;
} }

View File

@ -1,6 +1,5 @@
package org.dromara.workflow.domain.bo; package org.dromara.workflow.domain.bo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
@ -69,25 +68,21 @@ public class LxOaLeaveBo extends BaseEntity {
/** /**
* 请假原因 * 请假原因
*/ */
@ExcelProperty(value = "请假原因")
private String reason; private String reason;
/** /**
* 备注 * 备注
*/ */
@ExcelProperty(value = "备注")
private String remark; private String remark;
/** /**
* 在办项目 * 在办项目
*/ */
@ExcelProperty(value = "在办项目")
private String currentProjects; private String currentProjects;
/** /**
* 附件 * 附件
*/ */
@ExcelProperty(value = "附件")
private String attachment; private String attachment;
/** /**

View File

@ -0,0 +1,15 @@
package org.dromara.workflow.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.workflow.domain.LxOaBusinessTrip;
import org.dromara.workflow.domain.vo.LxOaBusinessTripVo;
/**
* 出差Mapper接口
*
* @author may
* @date 2023-07-21
*/
public interface LxOaBusinessTripMapper extends BaseMapperPlus<LxOaBusinessTrip, LxOaBusinessTripVo> {
}

View File

@ -0,0 +1,47 @@
package org.dromara.workflow.service;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.workflow.domain.bo.LxOaBusinessTripBo;
import org.dromara.workflow.domain.vo.LxOaBusinessTripVo;
import java.util.List;
/**
* 出差Service接口
*
* @author may
* @date 2023-07-21
*/
public interface ILxOaBusinessTripService {
/**
* 查询出差
*/
LxOaBusinessTripVo queryById(Long id);
/**
* 查询出差列表
*/
TableDataInfo<LxOaBusinessTripVo> queryPageList(LxOaBusinessTripBo bo, PageQuery pageQuery);
/**
* 查询出差列表
*/
List<LxOaBusinessTripVo> queryList(LxOaBusinessTripBo bo);
/**
* 新增出差
*/
LxOaBusinessTripVo insertByBo(LxOaBusinessTripBo bo);
/**
* 修改出差
*/
LxOaBusinessTripVo updateByBo(LxOaBusinessTripBo bo);
/**
* 校验并批量删除出差信息
*/
Boolean deleteWithValidByIds(List<Long> ids);
}

View File

@ -0,0 +1,209 @@
package org.dromara.workflow.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.event.ProcessCreateTaskEvent;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.service.WorkflowService;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.workflow.common.ConditionalOnEnable;
import org.dromara.workflow.domain.LxOaBusinessTrip;
import org.dromara.workflow.domain.bo.LxOaBusinessTripBo;
import org.dromara.workflow.domain.vo.LxOaBusinessTripVo;
import org.dromara.workflow.mapper.LxOaBusinessTripMapper;
import org.dromara.workflow.service.ILxOaBusinessTripService;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 出差Service业务层处理
*
* @author may
* @date 2023-07-21
*/
@ConditionalOnEnable
@RequiredArgsConstructor
@Service
@Slf4j
public class LxOaBusinessTripServiceImpl implements ILxOaBusinessTripService {
private final LxOaBusinessTripMapper baseMapper;
private final WorkflowService workflowService;
/**
* spel条件表达判断小于2
*
* @param leaveDays 待判断的变量可不传自行返回true或false
* @return boolean
*/
public boolean eval(Integer leaveDays) {
if (leaveDays <= 2) {
return true;
}
return false;
}
/**
* 查询出差
*/
@Override
public LxOaBusinessTripVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
/**
* 查询出差列表
*/
@Override
public TableDataInfo<LxOaBusinessTripVo> queryPageList(LxOaBusinessTripBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<LxOaBusinessTrip> lqw = buildQueryWrapper(bo);
Page<LxOaBusinessTripVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询出差列表
*/
@Override
public List<LxOaBusinessTripVo> queryList(LxOaBusinessTripBo bo) {
LambdaQueryWrapper<LxOaBusinessTrip> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<LxOaBusinessTrip> buildQueryWrapper(LxOaBusinessTripBo bo) {
LambdaQueryWrapper<LxOaBusinessTrip> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getTripType()), LxOaBusinessTrip::getTripType, bo.getTripType());
lqw.ge(bo.getStartTripDays() != null, LxOaBusinessTrip::getTripDays, bo.getStartTripDays());
lqw.le(bo.getEndTripDays() != null, LxOaBusinessTrip::getTripDays, bo.getEndTripDays());
lqw.orderByDesc(BaseEntity::getCreateTime);
return lqw;
}
/**
* 新增出差
*/
@Override
public LxOaBusinessTripVo insertByBo(LxOaBusinessTripBo bo) {
long day = DateUtil.between(bo.getStartDate(), bo.getEndDate(), DateUnit.DAY);
// 截止日期也算一天
bo.setTripDays((int) day + 1);
LxOaBusinessTrip add = MapstructUtils.convert(bo, LxOaBusinessTrip.class);
if (StringUtils.isBlank(add.getStatus())) {
add.setStatus(BusinessStatusEnum.DRAFT.getStatus());
}
boolean flag = baseMapper.insert(add) > 0;
// 流程变量
Map<String, Object> variable = new HashMap<>();
// variable.put("testLeave", testLeave);
// variable.put("flag", String.valueOf(testLeave.getDay()));
// flowParams.variable(variable);
// Instance instance = insService.start(id, flowParams);
if (flag) {
bo.setId(add.getId());
}
return MapstructUtils.convert(add, LxOaBusinessTripVo.class);
}
/**
* 修改出差
*/
@Override
public LxOaBusinessTripVo updateByBo(LxOaBusinessTripBo bo) {
LxOaBusinessTrip update = MapstructUtils.convert(bo, LxOaBusinessTrip.class);
baseMapper.updateById(update);
return MapstructUtils.convert(update, LxOaBusinessTripVo.class);
}
/**
* 批量删除出差
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteWithValidByIds(List<Long> ids) {
workflowService.deleteInstance(ids);
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 总体流程监听(例如: 草稿撤销退回作废终止已完成单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'
* 示例为了方便则使用startsWith匹配了全部示例key
*
* @param processEvent 参数
*/
@EventListener(condition = "#processEvent.flowCode=='trip1'")
public void processHandler(ProcessEvent processEvent) {
log.info("当前任务执行了{}", processEvent.toString());
LxOaBusinessTrip lxOaBusinessTrip = baseMapper.selectById(Long.valueOf(processEvent.getBusinessId()));
lxOaBusinessTrip.setStatus(processEvent.getStatus());
// 用于例如审批附件 审批意见等 存储到业务表内 自行根据业务实现存储流程
Map<String, Object> params = processEvent.getParams();
if (MapUtil.isNotEmpty(params)) {
// 历史任务扩展(通常为附件)
String hisTaskExt = Convert.toStr(params.get("hisTaskExt"));
// 办理人
String handler = Convert.toStr(params.get("handler"));
// 办理意见
String message = Convert.toStr(params.get("message"));
}
if (processEvent.isSubmit()) {
lxOaBusinessTrip.setStatus(BusinessStatusEnum.WAITING.getStatus());
}
baseMapper.updateById(lxOaBusinessTrip);
}
/**
* 执行任务创建监听
* 示例也可通过 @EventListener(condition = "#processCreateTaskEvent.flowCode=='leave1'")进行判断
* 在方法中判断流程节点key
* if ("xxx".equals(processCreateTaskEvent.getNodeCode())) {
* //执行业务逻辑
* }
*
* @param processCreateTaskEvent 参数
*/
@EventListener(condition = "#processCreateTaskEvent.flowCode=='trip1'")
public void processCreateTaskHandler(ProcessCreateTaskEvent processCreateTaskEvent) {
log.info("当前任务创建了{}", processCreateTaskEvent.toString());
LxOaBusinessTrip businessTrip = baseMapper.selectById(Long.valueOf(processCreateTaskEvent.getBusinessId()));
businessTrip.setStatus(BusinessStatusEnum.WAITING.getStatus());
baseMapper.updateById(businessTrip);
}
/**
* 监听删除流程事件
* 正常使用只需#processDeleteEvent.flowCode=='leave1'
* 示例为了方便则使用startsWith匹配了全部示例key
*
* @param processDeleteEvent 参数
*/
@EventListener(condition = "#processDeleteEvent.flowCode=='trip1'")
public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) {
log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString());
LxOaBusinessTrip businessTrip = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId()));
if (ObjectUtil.isNull(businessTrip)) {
return;
}
baseMapper.deleteById(businessTrip.getId());
}
}

View File

@ -182,7 +182,7 @@ public class LxOaLeaveServiceImpl implements ILxOaLeaveService {
* *
* @param processCreateTaskEvent 参数 * @param processCreateTaskEvent 参数
*/ */
@EventListener(condition = "#processCreateTaskEvent.flowCode.startsWith('leave')") @EventListener(condition = "#processCreateTaskEvent.flowCode=='leave1'")
public void processCreateTaskHandler(ProcessCreateTaskEvent processCreateTaskEvent) { public void processCreateTaskHandler(ProcessCreateTaskEvent processCreateTaskEvent) {
log.info("当前任务创建了{}", processCreateTaskEvent.toString()); log.info("当前任务创建了{}", processCreateTaskEvent.toString());
LxOaLeave lxOaLeave = baseMapper.selectById(Long.valueOf(processCreateTaskEvent.getBusinessId())); LxOaLeave lxOaLeave = baseMapper.selectById(Long.valueOf(processCreateTaskEvent.getBusinessId()));
@ -197,7 +197,7 @@ public class LxOaLeaveServiceImpl implements ILxOaLeaveService {
* *
* @param processDeleteEvent 参数 * @param processDeleteEvent 参数
*/ */
@EventListener(condition = "#processDeleteEvent.flowCode.startsWith('leave')") @EventListener(condition = "#processDeleteEvent.flowCode=='leave1'")
public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) { public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) {
log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString()); log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString());
LxOaLeave lxOaLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId())); LxOaLeave lxOaLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId()));