车辆管理
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
This commit is contained in:
parent
3cebec9d4a
commit
07c50255d4
@ -24,6 +24,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
@ -42,7 +43,7 @@ public class ClglController {
|
||||
@Operation(summary = "创建车辆管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:create')")
|
||||
public CommonResult<Long> createClgl(@Valid @RequestBody ClglSaveReqVO createReqVO) {
|
||||
return success(clglService.createClgl(createReqVO));
|
||||
return success(clglService.createClgl(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ -75,7 +76,7 @@ public class ClglController {
|
||||
@Operation(summary = "获得车辆管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:query')")
|
||||
public CommonResult<PageResult<ClglRespVO>> getClglPage(@Valid ClglPageReqVO pageReqVO) {
|
||||
PageResult<ClglDO> pageResult = clglService.getClglPage(pageReqVO);
|
||||
PageResult<ClglDO> pageResult = clglService.getClglPage(getLoginUserId(),pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ClglRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class ClglPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程状态", example = "1")
|
||||
private Integer flowStatus;
|
||||
|
||||
@Schema(description = "id", example = "26309")
|
||||
private Long id;
|
||||
|
||||
|
@ -14,6 +14,13 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ClglRespVO {
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "20058")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程状态", example = "1")
|
||||
private Integer flowStatus;
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26309")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
@ -11,6 +11,9 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class ClglSaveReqVO {
|
||||
|
||||
@Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
|
||||
private Map<String, List<Long>> startUserSelectAssignees;
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26309")
|
||||
private Long id;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.home.dal.dataobject.clgl;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
@ -24,6 +26,26 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
@AllArgsConstructor
|
||||
public class ClglDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 对应的流程编号
|
||||
*
|
||||
* 关联 ProcessInstance 的 id 属性
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 申请人的用户编号
|
||||
*
|
||||
* 关联 AdminUserDO 的 id 属性
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 审批结果
|
||||
*
|
||||
* 枚举 {@link BpmTaskStatusEnum}
|
||||
* 考虑到简单,所以直接复用了 BpmProcessInstanceStatusEnum 枚举,也可以自己定义一个枚举哈
|
||||
*/
|
||||
private Integer flowStatus;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
|
@ -17,6 +17,24 @@ import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
@Mapper
|
||||
public interface ClglMapper extends BaseMapperX<ClglDO> {
|
||||
|
||||
default PageResult<ClglDO> selectPage(Long userId,ClglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ClglDO>()
|
||||
.eqIfPresent(ClglDO::getId, reqVO.getId())
|
||||
.eqIfPresent(ClglDO::getCarUser, reqVO.getCarUser())
|
||||
.eqIfPresent(ClglDO::getDept, reqVO.getDept())
|
||||
.eqIfPresent(ClglDO::getCarType, reqVO.getCarType())
|
||||
.eqIfPresent(ClglDO::getCarDriver, reqVO.getCarDriver())
|
||||
.eqIfPresent(ClglDO::getCarStart, reqVO.getCarStart())
|
||||
.eqIfPresent(ClglDO::getCarEnd, reqVO.getCarEnd())
|
||||
.eqIfPresent(ClglDO::getCarAddress, reqVO.getCarAddress())
|
||||
.eqIfPresent(ClglDO::getCarStartMileage, reqVO.getCarStartMileage())
|
||||
.eqIfPresent(ClglDO::getCarEndMileage, reqVO.getCarEndMileage())
|
||||
.eqIfPresent(ClglDO::getCarStatus, reqVO.getCarStatus())
|
||||
.eqIfPresent(ClglDO::getUserId, userId)
|
||||
.eqIfPresent(ClglDO::getFlowStatus, reqVO.getFlowStatus())
|
||||
.betweenIfPresent(ClglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ClglDO::getId));
|
||||
}
|
||||
default PageResult<ClglDO> selectPage(ClglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ClglDO>()
|
||||
.eqIfPresent(ClglDO::getId, reqVO.getId())
|
||||
@ -30,6 +48,7 @@ public interface ClglMapper extends BaseMapperX<ClglDO> {
|
||||
.eqIfPresent(ClglDO::getCarStartMileage, reqVO.getCarStartMileage())
|
||||
.eqIfPresent(ClglDO::getCarEndMileage, reqVO.getCarEndMileage())
|
||||
.eqIfPresent(ClglDO::getCarStatus, reqVO.getCarStatus())
|
||||
.eqIfPresent(ClglDO::getFlowStatus, reqVO.getFlowStatus())
|
||||
.betweenIfPresent(ClglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ClglDO::getId));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public interface ClglService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createClgl(@Valid ClglSaveReqVO createReqVO);
|
||||
Long createClgl(Long userId, @Valid ClglSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新车辆管理
|
||||
@ -51,5 +51,14 @@ public interface ClglService {
|
||||
* @return 车辆管理分页
|
||||
*/
|
||||
PageResult<ClglDO> getClglPage(ClglPageReqVO pageReqVO);
|
||||
PageResult<ClglDO> getClglPage(Long userid, ClglPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 更新请假申请的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param status 结果
|
||||
*/
|
||||
void updateClglStatus(Long id, Integer status);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl;
|
||||
|
||||
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.BpmTaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -15,6 +18,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.clgl.ClglMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.KNOWLEDGE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -25,15 +29,28 @@ import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
@Service
|
||||
@Validated
|
||||
public class ClglServiceImpl implements ClglService {
|
||||
public static final String PROCESS_KEY = "test-001";
|
||||
|
||||
@Resource
|
||||
private ClglMapper clglMapper;
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Override
|
||||
public Long createClgl(ClglSaveReqVO createReqVO) {
|
||||
public Long createClgl(Long userId,ClglSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ClglDO clgl = BeanUtils.toBean(createReqVO, ClglDO.class);
|
||||
ClglDO clgl = BeanUtils.toBean(createReqVO, ClglDO.class)
|
||||
.setUserId(userId).setFlowStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
clglMapper.insert(clgl);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(clgl.getId()))
|
||||
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
clglMapper.updateById(new ClglDO().setId(clgl.getId()).setProcessInstanceId(processInstanceId));
|
||||
// 返回
|
||||
return clgl.getId();
|
||||
}
|
||||
@ -71,4 +88,20 @@ public class ClglServiceImpl implements ClglService {
|
||||
return clglMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClglDO> getClglPage(Long userId, ClglPageReqVO pageReqVO) {
|
||||
return clglMapper.selectPage(userId, pageReqVO);
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (clglMapper.selectById(id) == null) {
|
||||
throw exception(KNOWLEDGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateClglStatus(Long id, Integer status) {
|
||||
validateLeaveExists(id);
|
||||
clglMapper.updateById(new ClglDO().setId(id).setFlowStatus(status));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl.listener;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
|
||||
import cn.iocoder.yudao.module.home.service.clgl.ClglService;
|
||||
import cn.iocoder.yudao.module.home.service.clgl.ClglServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 车辆管理流程的结果的监听器实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmClglStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private ClglService clglService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return ClglServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
clglService.updateClglStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user