BPM:抄送任务的 code review
This commit is contained in:
parent
a5dc4e7876
commit
ee1870802f
|
@ -2,20 +2,18 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
||||||
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
|
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
@ -62,19 +60,21 @@ public class BpmProcessInstanceController {
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @kyle:抄送要不单独 controller?
|
||||||
|
|
||||||
@PostMapping("/cc/create")
|
@PostMapping("/cc/create")
|
||||||
@Operation(summary = "抄送流程")
|
@Operation(summary = "抄送流程")
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')")
|
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')")
|
||||||
public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) {
|
public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) {
|
||||||
return success(processInstanceCopyService.ccProcessInstance(SecurityFrameworkUtils.getLoginUserId(), createReqVO));
|
return success(processInstanceCopyService.ccProcessInstance(getLoginUserId(), createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/cc/my-page")
|
@GetMapping("/cc/my-page")
|
||||||
@Operation(summary = "获得抄送流程分页列表")
|
@Operation(summary = "获得抄送流程分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
|
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
|
||||||
public CommonResult<PageResult<BpmProcessInstanceCCPageItemRespVO>> getProcessInstanceCCPage(@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
public CommonResult<PageResult<BpmProcessInstanceCCPageItemRespVO>> getProcessInstanceCCPage(
|
||||||
return success(processInstanceCopyService.getMyProcessInstanceCCPage(SecurityFrameworkUtils.getLoginUserId(), pageReqVO));
|
@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
||||||
|
return success(processInstanceCopyService.getMyProcessInstanceCCPage(getLoginUserId(), pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO")
|
// TODO @kyle:建议改成 BpmProcessInstanceCopyMyPageReqVO;cc 缩写不容易理解,所以改成 copy,虽然会长一点,但是可读性更重要;
|
||||||
|
@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.time.LocalDateTime;
|
||||||
@Data
|
@Data
|
||||||
public class BpmProcessInstanceCCPageItemRespVO {
|
public class BpmProcessInstanceCCPageItemRespVO {
|
||||||
|
|
||||||
|
// TODO @kyle:如果已经写了 swagger 注解,可以不用写 java 注释哈;
|
||||||
/**
|
/**
|
||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
|
@ -52,4 +53,5 @@ public class BpmProcessInstanceCCPageItemRespVO {
|
||||||
|
|
||||||
@Schema(description = "抄送时间")
|
@Schema(description = "抄送时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Set;
|
// TODO @kyle:这个 VO 可以改成 BpmProcessInstanceCopyCreateReqVO
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程实例的抄送 Request VO")
|
@Schema(description = "管理后台 - 流程实例的抄送 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ -33,7 +32,6 @@ public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO {
|
||||||
@NotNull(message = "发起流程的用户的编号不能为空")
|
@NotNull(message = "发起流程的用户的编号不能为空")
|
||||||
private Long startUserId;
|
private Long startUserId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
@NotEmpty(message = "任务实例名称不能为空")
|
@NotEmpty(message = "任务实例名称不能为空")
|
||||||
private String processInstanceName;
|
private String processInstanceName;
|
||||||
|
@ -41,4 +39,9 @@ public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO {
|
||||||
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
|
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
|
||||||
@NotBlank(message = "抄送原因不能为空")
|
@NotBlank(message = "抄送原因不能为空")
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
// TODO @kyle:看了下字段有点多,尽量不传递可推导的字段;
|
||||||
|
// 需要传递:taskId(任务编号)、reason、userIds(被抄送的人)
|
||||||
|
// 不需要传递:taskKey、taskName、processInstanceKey、startUserId、processInstanceName 因为这些可以后端查询到
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.mapstruct.factory.Mappers;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
// TODO kyle:类注释不太对
|
||||||
/**
|
/**
|
||||||
* 动态表单 Convert
|
* 动态表单 Convert
|
||||||
*
|
*
|
||||||
|
@ -21,14 +22,14 @@ public interface BpmProcessInstanceCopyConvert {
|
||||||
|
|
||||||
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
|
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
|
||||||
|
|
||||||
|
// TODO @kyle:可以使用 BeanUtils copy 替代这些简单的哈;
|
||||||
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
|
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
|
||||||
|
|
||||||
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
|
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
|
||||||
|
|
||||||
List<BpmProcessInstanceCopyVO> convertList2(List<BpmProcessInstanceCopyDO> list);
|
|
||||||
|
|
||||||
List<BpmProcessInstanceCCPageItemRespVO> convertList(List<BpmProcessInstanceCopyDO> list);
|
List<BpmProcessInstanceCCPageItemRespVO> convertList(List<BpmProcessInstanceCopyDO> list);
|
||||||
|
|
||||||
|
// TODO @kyle:/* taskId */ 这种注释一般不用写,可以一眼看明白的;避免变量看着略微不清晰哈
|
||||||
default PageResult<BpmProcessInstanceCCPageItemRespVO> convertPage(PageResult<BpmProcessInstanceCopyDO> page
|
default PageResult<BpmProcessInstanceCCPageItemRespVO> convertPage(PageResult<BpmProcessInstanceCopyDO> page
|
||||||
, Map<String/* taskId */, String/* taskName */> taskMap
|
, Map<String/* taskId */, String/* taskName */> taskMap
|
||||||
, Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap
|
, Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap
|
||||||
|
@ -45,6 +46,15 @@ public interface BpmProcessInstanceCopyConvert {
|
||||||
MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(),
|
MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(),
|
||||||
vo::setProcessInstanceName);
|
vo::setProcessInstanceName);
|
||||||
}
|
}
|
||||||
|
// TODO @kyle:可以精简成下面的哈;
|
||||||
|
// List<BpmProcessInstanceCCPageItemRespVO> list2 = BeanUtils.toBean(page.getList(),
|
||||||
|
// BpmProcessInstanceCCPageItemRespVO.class,
|
||||||
|
// copy -> {
|
||||||
|
// MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), copy::setCreatorNickname);
|
||||||
|
// MapUtils.findAndThen(userMap, copy.getStartUserId(), copy::setStartUserNickname);
|
||||||
|
// MapUtils.findAndThen(taskMap, copy.getTaskId(), copy::setTaskName);
|
||||||
|
// MapUtils.findAndThen(processInstaneMap, copy.getProcessInstanceId(), copy::setProcessInstanceName);
|
||||||
|
// });
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程抄送对象
|
* 流程抄送 DO
|
||||||
*
|
*
|
||||||
* @author kyle
|
* @author kyle
|
||||||
* @date 2022-05-19
|
* @date 2022-05-19 TODO @kyle:@date 不是标准 java doc,可以使用 @since 替代,然后日期是不是不对
|
||||||
*/
|
*/
|
||||||
@TableName(value = "bpm_process_instance_copy", autoResultMap = true)
|
@TableName(value = "bpm_process_instance_copy", autoResultMap = true)
|
||||||
@Data
|
@Data
|
||||||
|
@ -26,6 +26,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
// TODO @kyle:字段如果是关联或者冗余,要写下注释。以 processInstanceId 举例子。
|
||||||
/**
|
/**
|
||||||
* 发起人 Id
|
* 发起人 Id
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +36,9 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private String processInstanceName;
|
private String processInstanceName;
|
||||||
/**
|
/**
|
||||||
* 流程主键
|
* 流程实例的编号
|
||||||
|
*
|
||||||
|
* 关联 ProcessInstance 的 id 属性
|
||||||
*/
|
*/
|
||||||
private String processInstanceId;
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||||
private String taskName;
|
private String taskName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户主键
|
* 用户编号
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
// TODO @kyle:这个字段,可以用 category 简化点
|
||||||
/**
|
/**
|
||||||
* 流程分类
|
* 流程分类
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,7 +8,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> {
|
public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> { // TODO @kyle:方法和类之间要空行下;
|
||||||
default PageResult<BpmProcessInstanceCopyDO> selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){
|
default PageResult<BpmProcessInstanceCopyDO> selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessInstanceCopyDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessInstanceCopyDO>()
|
||||||
.eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId)
|
.eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId)
|
||||||
|
|
|
@ -6,8 +6,7 @@ import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.util.List;
|
// TODO @芋艿:Candidate 相关还在完善中,用户可以暂时忽略,仅 yudao 开发的同学需要关注~计划是把 Candidate 和 Assign 融合成一套
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable
|
* BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable
|
||||||
* @author kyle
|
* @author kyle
|
||||||
|
|
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessI
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
|
||||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||||
|
|
||||||
|
// TODO @kyle:这个 Service 要不挪到 task 包下;保持统一,task 下有流程、任务、抄送等;
|
||||||
|
// TODO @kyle:中文和英文之间,有个空格,会更清晰点;例如说;流程抄送 Service 接口;中文写作习惯~
|
||||||
/**
|
/**
|
||||||
* 流程抄送Service接口
|
* 流程抄送Service接口
|
||||||
*
|
*
|
||||||
|
@ -13,6 +15,7 @@ import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||||
*/
|
*/
|
||||||
public interface BpmProcessInstanceCopyService {
|
public interface BpmProcessInstanceCopyService {
|
||||||
|
|
||||||
|
// TODO @kyle:无用的方法,可以去掉哈;另外,考虑到避免过多的 VO,这里就可以返回 BpmProcessInstanceCopyDO
|
||||||
/**
|
/**
|
||||||
* 查询流程抄送
|
* 查询流程抄送
|
||||||
*
|
*
|
||||||
|
@ -21,6 +24,7 @@ public interface BpmProcessInstanceCopyService {
|
||||||
*/
|
*/
|
||||||
BpmProcessInstanceCopyVO queryById(Long copyId);
|
BpmProcessInstanceCopyVO queryById(Long copyId);
|
||||||
|
|
||||||
|
// TODO 芋艿:这块要 review 下;思考下~~
|
||||||
/**
|
/**
|
||||||
* 抄送
|
* 抄送
|
||||||
* @param sourceInfo 抄送源信息,方便抄送处理
|
* @param sourceInfo 抄送源信息,方便抄送处理
|
||||||
|
@ -28,13 +32,15 @@ public interface BpmProcessInstanceCopyService {
|
||||||
*/
|
*/
|
||||||
boolean makeCopy(BpmCandidateSourceInfo sourceInfo);
|
boolean makeCopy(BpmCandidateSourceInfo sourceInfo);
|
||||||
|
|
||||||
|
// TODO @kyle:可以方法名改成 createProcessInstanceCopy;现在项目一般新增都用 create 为主;
|
||||||
/**
|
/**
|
||||||
* 流程实例的抄送
|
* 流程实例的抄送
|
||||||
* @param loginUserId 当前登录用户
|
*
|
||||||
|
* @param userId 当前登录用户
|
||||||
* @param createReqVO 创建的抄送请求
|
* @param createReqVO 创建的抄送请求
|
||||||
* @return 是否抄送成功,抄送成功则返回true
|
* @return 是否抄送成功,抄送成功则返回true TODO @kyle:这里可以不用返回哈;目前一般是失败,就抛出业务异常;
|
||||||
*/
|
*/
|
||||||
boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO createReqVO);
|
boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 抄送的流程
|
* 抄送的流程
|
||||||
|
@ -42,5 +48,6 @@ public interface BpmProcessInstanceCopyService {
|
||||||
* @param pageReqVO 分页请求
|
* @param pageReqVO 分页请求
|
||||||
* @return 抄送的分页结果
|
* @return 抄送的分页结果
|
||||||
*/
|
*/
|
||||||
PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO);
|
PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId,
|
||||||
|
BpmProcessInstanceCCMyPageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,12 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper;
|
||||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain;
|
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain;
|
||||||
import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO;
|
import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||||
import cn.iocoder.yudao.module.bpm.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.util.FlowableUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.RuntimeService;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
|
@ -24,33 +26,37 @@ import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
// TODO @kyle:类注释要写下
|
||||||
|
@Slf4j // TODO @kyle:按照 @Service、@Validated、@Slf4j,从重要到不重要的顺序;
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService {
|
public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService {
|
||||||
@Resource
|
@Resource // TODO @kyle:第一个变量,和类之间要有空行;
|
||||||
private BpmProcessInstanceCopyMapper processInstanceCopyMapper;
|
private BpmProcessInstanceCopyMapper processInstanceCopyMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和flowable有关的,查询流程名用的
|
* 和flowable有关的,查询流程名用的 TODO @kyle:可以不写哈注释;
|
||||||
*/
|
*/
|
||||||
@Resource
|
@Resource
|
||||||
private RuntimeService runtimeService;
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 找抄送人用的
|
* 找抄送人用的 TODO @kyle:可以不写哈注释;
|
||||||
*/
|
*/
|
||||||
@Resource
|
@Resource
|
||||||
private BpmCandidateSourceInfoProcessorChain processorChain;
|
private BpmCandidateSourceInfoProcessorChain processorChain;
|
||||||
|
|
||||||
|
// TODO @kyle:多余的变量,可以去掉哈
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy // 解决循环依赖
|
@Lazy // 解决循环依赖
|
||||||
private BpmTaskService taskService;
|
private BpmTaskService bpmTaskService;
|
||||||
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
|
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@ -60,6 +66,10 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||||
return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO);
|
return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @kyle:makeCopy 和 ccProcessInstance 的调用关系,感受上反了;
|
||||||
|
// makeCopy 有点像基于规则,查找抄送人,然后创建;
|
||||||
|
// ccProcessInstance 是已经有了抄送人,然后创建;
|
||||||
|
// 建议的改造:独立基于 processInstanceCopyMapper 做 insert
|
||||||
@Override
|
@Override
|
||||||
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
|
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
|
||||||
if (null == sourceInfo) {
|
if (null == sourceInfo) {
|
||||||
|
@ -103,13 +113,13 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ccProcessInstance(Long loginUserId, BpmProcessInstanceCCReqVO reqVO) {
|
public boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO reqVO) {
|
||||||
// 在能正常审批的情况下抄送流程
|
// 在能正常审批的情况下抄送流程
|
||||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||||
sourceInfo.setTaskId(reqVO.getTaskKey());
|
sourceInfo.setTaskId(reqVO.getTaskKey());
|
||||||
sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey());
|
sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey());
|
||||||
sourceInfo.addRule(reqVO);
|
sourceInfo.addRule(reqVO);
|
||||||
sourceInfo.setCreator(String.valueOf(loginUserId));
|
sourceInfo.setCreator(String.valueOf(userId));
|
||||||
sourceInfo.setReason(reqVO.getReason());
|
sourceInfo.setReason(reqVO.getReason());
|
||||||
if (!makeCopy(sourceInfo)) {
|
if (!makeCopy(sourceInfo)) {
|
||||||
throw new RuntimeException("抄送任务失败");
|
throw new RuntimeException("抄送任务失败");
|
||||||
|
@ -117,15 +127,20 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取流程抄送分页
|
//获取流程抄送分页 TODO @kyle:接口已经注释,这里不用注释了哈;
|
||||||
@Override
|
@Override
|
||||||
public PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
public PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
||||||
// 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页
|
// 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页
|
||||||
|
// TODO @kyle:一般读逻辑,Service 返回 PageResult<BpmProcessInstanceCopyDO> 即可。关联数据的查询和拼接,交给 Controller;目的是:保证 Service 聚焦写逻辑,清晰简洁;
|
||||||
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
|
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
|
||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
return new PageResult<>(pageResult.getTotal());
|
return new PageResult<>(pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @kyle:这种可以简洁点;参考如下
|
||||||
|
// Map<String, ProcessInstance> processInstanceMap = bpmProcessInstanceService.getProcessInstanceMap(
|
||||||
|
// convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
|
||||||
|
|
||||||
Set<String/* taskId */> taskIds = new HashSet<>();
|
Set<String/* taskId */> taskIds = new HashSet<>();
|
||||||
Set<String/* processInstaneId */> processInstaneIds = new HashSet<>();
|
Set<String/* processInstaneId */> processInstaneIds = new HashSet<>();
|
||||||
Set<Long/* userId */> userIds = new HashSet<>();
|
Set<Long/* userId */> userIds = new HashSet<>();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO @kyle:看看是不是要删除
|
||||||
/**
|
/**
|
||||||
* 流程抄送视图对象 wf_copy
|
* 流程抄送视图对象 wf_copy
|
||||||
*
|
*
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class FlowableUtils {
|
||||||
return task.getName();
|
return task.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里
|
||||||
public static Map<String/* taskId */, String/* taskName */> getTaskNameByTaskIds(Collection<String> taskIds) {
|
public static Map<String/* taskId */, String/* taskName */> getTaskNameByTaskIds(Collection<String> taskIds) {
|
||||||
TaskService taskService = SpringUtil.getBean(TaskService.class);
|
TaskService taskService = SpringUtil.getBean(TaskService.class);
|
||||||
List<Task> tasks = taskService.createTaskQuery().taskIds(taskIds).list();
|
List<Task> tasks = taskService.createTaskQuery().taskIds(taskIds).list();
|
||||||
|
@ -109,6 +110,7 @@ public class FlowableUtils {
|
||||||
return processInstance.getName();
|
return processInstance.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里
|
||||||
public static Map<String/* processInstaneId */, String/* processInstaneName */> getProcessInstanceNameByTaskIds(Set<String> taskIds) {
|
public static Map<String/* processInstaneId */, String/* processInstaneName */> getProcessInstanceNameByTaskIds(Set<String> taskIds) {
|
||||||
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
|
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
|
||||||
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list();
|
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list();
|
||||||
|
|
|
@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.system.controller.admin.ip;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.IPUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.IPUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.ip.AreaConvert;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -31,7 +31,7 @@ public class AreaController {
|
||||||
public CommonResult<List<AreaNodeRespVO>> getAreaTree() {
|
public CommonResult<List<AreaNodeRespVO>> getAreaTree() {
|
||||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
||||||
Assert.notNull(area, "获取不到中国");
|
Assert.notNull(area, "获取不到中国");
|
||||||
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
|
return success(BeanUtils.toBean(area.getChildren(), AreaNodeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-by-ip")
|
@GetMapping("/get-by-ip")
|
||||||
|
|
|
@ -31,7 +31,4 @@ public class SocialUserBindReqVO {
|
||||||
@NotEmpty(message = "state 不能为空")
|
@NotEmpty(message = "state 不能为空")
|
||||||
private String state;
|
private String state;
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.system.controller.app.ip;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO;
|
import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.ip.AreaConvert;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -28,7 +28,7 @@ public class AppAreaController {
|
||||||
public CommonResult<List<AppAreaNodeRespVO>> getAreaTree() {
|
public CommonResult<List<AppAreaNodeRespVO>> getAreaTree() {
|
||||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
||||||
Assert.notNull(area, "获取不到中国");
|
Assert.notNull(area, "获取不到中国");
|
||||||
return success(AreaConvert.INSTANCE.convertList3(area.getChildren()));
|
return success(BeanUtils.toBean(area.getChildren(), AppAreaNodeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.system.convert.ip;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface AreaConvert {
|
|
||||||
|
|
||||||
AreaConvert INSTANCE = Mappers.getMapper(AreaConvert.class);
|
|
||||||
|
|
||||||
List<AreaNodeRespVO> convertList(List<Area> list);
|
|
||||||
|
|
||||||
List<AppAreaNodeRespVO> convertList3(List<Area> list);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 缺少单个转换
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
AreaNodeRespVO map(Area value);
|
|
||||||
|
|
||||||
AppAreaNodeRespVO map3(Area value);
|
|
||||||
}
|
|
Loading…
Reference in New Issue