feat(bpm): 添加 OA签呈申请功能
- 新增签呈申请相关的 VO、DO、Mapper 和 Service 接口及实现类 - 实现签呈申请的创建、更新和查询功能- 添加签呈申请的结果监听器 - 优化备用金报销逻辑 - 调整流程定义列表查询方式
This commit is contained in:
parent
cf9fc3a65e
commit
688d3be70d
@ -45,9 +45,9 @@ public class BpmProcessDefinitionController {
|
|||||||
return success(respVOS);
|
return success(respVOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping ("/list-simple")
|
@GetMapping ("/list-simple")
|
||||||
@Operation(summary = "获得流程定义列表-前端下拉框使用")
|
@Operation(summary = "获得流程定义列表-前端下拉框使用")
|
||||||
public CommonResult<List<BpmProcessDefinitionSimpleVO>> getProcessDefinitionSimpleList(@RequestBody BpmProcessDefinitionListReqVO reqVO) {
|
public CommonResult<List<BpmProcessDefinitionSimpleVO>> getProcessDefinitionSimpleList(BpmProcessDefinitionListReqVO reqVO) {
|
||||||
|
|
||||||
List<BpmProcessDefinitionSimpleVO> respVOS = bpmDefinitionService.getProcessDefinitionSimpleList(reqVO);
|
List<BpmProcessDefinitionSimpleVO> respVOS = bpmDefinitionService.getProcessDefinitionSimpleList(reqVO);
|
||||||
return success(respVOS);
|
return success(respVOS);
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition.BpmOAPetitionCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition.BpmOAPetitionRespVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPetitionDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAPetitionServiceImpl;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 签呈申请 Controller
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Tag(name = "管理后台 - OA 签呈申请")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bpm/oa/petition")
|
||||||
|
@Validated
|
||||||
|
public class BpmOAPetitionController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOAPetitionServiceImpl petitionService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建签呈申请")
|
||||||
|
public CommonResult<Long> createPetition(@Valid @RequestBody BpmOAPetitionCreateReqVO createReqVO) {
|
||||||
|
|
||||||
|
return success(petitionService.createPetition(getLoginUserId(), createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得签呈申请")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
public CommonResult<BpmOAPetitionRespVO> getPetition(@RequestParam("id") Long id) {
|
||||||
|
|
||||||
|
BpmOAPetitionDO petitionDO = petitionService.getPetition(id);
|
||||||
|
|
||||||
|
return success(BeanUtils.toBean(petitionDO, BpmOAPetitionRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getByProcessInstanceId")
|
||||||
|
@Operation(summary = "获得签呈申请")
|
||||||
|
@Parameter(name = "processInstanceId", description = "流程实例编号", required = true, example = "1024")
|
||||||
|
public CommonResult<BpmOAPetitionRespVO> getByProcessInstanceId(@RequestParam("processInstanceId") String processInstanceId) {
|
||||||
|
|
||||||
|
BpmOAPetitionDO petitionDO = petitionService.getByProcessInstanceId(processInstanceId);
|
||||||
|
|
||||||
|
return success(BeanUtils.toBean(petitionDO, BpmOAPetitionRespVO.class));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "关联流程 VO")
|
||||||
|
@Data
|
||||||
|
public class AssociationVO {
|
||||||
|
|
||||||
|
@Schema(description = "流程名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例编号")
|
||||||
|
private String processInstanceId;
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签呈申请 创建 Request VO
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 签呈申请创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode()
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BpmOAPetitionCreateReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "签呈标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "签呈标题不能为空")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "申请内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "申请内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "所关联的流程")
|
||||||
|
private List<AssociationVO> businessInstanceIds;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例编号")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "状态-参见 bpm_process_instance_result 枚举", example = "1")
|
||||||
|
private Integer result;
|
||||||
|
|
||||||
|
@Schema(description = "上传文件")
|
||||||
|
private List<UploadUserFile> fileItems;
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOABaseRespVO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 签呈申请 请求Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BpmOAPetitionRespVO extends BpmOABaseRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "签呈标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "签呈标题不能为空")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "申请内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "申请内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "所关联的流程")
|
||||||
|
private List<AssociationVO> businessInstanceIds;
|
||||||
|
|
||||||
|
@Schema(description = "上传文件")
|
||||||
|
private List<UploadUserFile> fileItems;
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition.AssociationVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
@TableName(value ="bpm_oa_petition", autoResultMap = true)
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BpmOAPetitionDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出差表单主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请人的用户编号
|
||||||
|
* 关联 AdminUserDO 的 id 属性
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签呈标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所关联的流程
|
||||||
|
*/
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<AssociationVO> businessInstanceIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请的结果
|
||||||
|
* 枚举 {@link BpmProcessInstanceResultEnum}
|
||||||
|
* 考虑到简单,所以直接复用了 BpmProcessInstanceResultEnum 枚举,也可以自己定义一个枚举哈
|
||||||
|
*/
|
||||||
|
private Integer result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应的流程编号
|
||||||
|
* 关联 ProcessInstance 的 id 属性
|
||||||
|
*/
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件基本信息
|
||||||
|
*/
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<UploadUserFile> fileItems ;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionSimpleVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionSimpleVO;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||||
@ -21,8 +22,8 @@ public interface BpmProcessDefinitionExtMapper extends BaseMapperX<BpmProcessDef
|
|||||||
return selectOne("process_definition_id", processDefinitionId);
|
return selectOne("process_definition_id", processDefinitionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BpmProcessDefinitionSimpleVO> selectSimpleList(@Param("definitionIds") List<String> definitionIds,
|
@DataPermission(enable = false)
|
||||||
@Param("deptIds") List<Long> deptIds,
|
List<BpmProcessDefinitionSimpleVO> selectSimpleList(@Param("deptIds") List<Long> deptIds,
|
||||||
@Param("createTime") LocalDateTime[] createTime,
|
@Param("createTime") LocalDateTime[] createTime,
|
||||||
@Param("userId") Long userId);
|
@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPetitionDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BpmOAPetitionMapper extends BaseMapperX<BpmOAPetitionDO> {
|
||||||
|
}
|
@ -146,12 +146,9 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||||||
deptIds = deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData();
|
deptIds = deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取流程定义编号集合
|
|
||||||
List<String> definitionIds = convertList(processDefinitions, ProcessDefinition::getId);
|
|
||||||
|
|
||||||
// 获取各流程待审核得数量
|
// 获取各流程待审核得数量
|
||||||
List<BpmProcessDefinitionSimpleVO> definitionCounts = processDefinitionMapper.selectSimpleList(definitionIds, deptIds, reqVO.getCreateTime(), getLoginUserId());
|
List<BpmProcessDefinitionSimpleVO> definitionCounts = processDefinitionMapper.selectSimpleList(deptIds, reqVO.getCreateTime(), getLoginUserId());
|
||||||
Map<String, BpmProcessDefinitionSimpleVO> mapCount = convertMap(definitionCounts, BpmProcessDefinitionSimpleVO::getProcessDefinitionId);
|
Map<String, BpmProcessDefinitionSimpleVO> mapCount = convertMap(definitionCounts, BpmProcessDefinitionSimpleVO::getName);
|
||||||
|
|
||||||
// 整合数据
|
// 整合数据
|
||||||
return processDefinitions.stream()
|
return processDefinitions.stream()
|
||||||
@ -159,7 +156,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||||||
.map(item -> new BpmProcessDefinitionSimpleVO()
|
.map(item -> new BpmProcessDefinitionSimpleVO()
|
||||||
.setName(item.getName())
|
.setName(item.getName())
|
||||||
.setProcessDefinitionId(item.getId())
|
.setProcessDefinitionId(item.getId())
|
||||||
.setTodoCount(Optional.ofNullable(mapCount.get(item.getId()).getTodoCount()).orElse(0)))
|
.setTodoCount(mapCount.get(item.getName()) == null ? 0 : mapCount.get(item.getName()).getTodoCount()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public class BpmOACashServiceImpl extends BpmOABaseService implements BpmOACashS
|
|||||||
}
|
}
|
||||||
|
|
||||||
//判断是否为备用金报销
|
//判断是否为备用金报销
|
||||||
boolean isImprest = false;
|
int isImprest = 0;
|
||||||
BigDecimal amount = null;
|
BigDecimal amount = null;
|
||||||
if (cash.getImprestId() != null) {
|
if (cash.getImprestId() != null) {
|
||||||
|
|
||||||
@ -214,15 +214,14 @@ public class BpmOACashServiceImpl extends BpmOABaseService implements BpmOACashS
|
|||||||
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.FLAG_TRUE));
|
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.FLAG_TRUE));
|
||||||
|
|
||||||
if (amount.compareTo(BigDecimal.ZERO) < 0) {
|
if (amount.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
isImprest = true;
|
isImprest = 1;
|
||||||
}else {
|
}else {
|
||||||
return;
|
isImprest = 2;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//将相应备用金申请状态改为 未报销完毕
|
//将相应备用金申请状态改为 未报销完毕
|
||||||
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.NOT_COMPLETED));
|
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.NOT_COMPLETED));
|
||||||
|
isImprest = 2;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +238,8 @@ public class BpmOACashServiceImpl extends BpmOABaseService implements BpmOACashS
|
|||||||
.setReason(reason)
|
.setReason(reason)
|
||||||
.setObjectId(id)
|
.setObjectId(id)
|
||||||
.setType(1)
|
.setType(1)
|
||||||
.setStatus(0)
|
.setStatus(isImprest == 2 ? 4 : 0)
|
||||||
.setAmountPayable(isImprest ? amount.abs() : cash.getTotalMoney())
|
.setAmountPayable(isImprest == 1 ? amount.abs() : cash.getTotalMoney())
|
||||||
.setBeginTime(processInstance.getCreateTime())
|
.setBeginTime(processInstance.getCreateTime())
|
||||||
.setEndTime(processInstance.getEndTime())
|
.setEndTime(processInstance.getEndTime())
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition.BpmOAPetitionCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPetitionDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签呈申请 Service 接口
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
public interface BpmOAPetitionService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建签呈申请
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 签呈申请编号
|
||||||
|
*/
|
||||||
|
Long createPetition(Long userId, BpmOAPetitionCreateReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新签呈申请审批结果
|
||||||
|
* @param id 编号
|
||||||
|
* @param result 审批结果
|
||||||
|
*/
|
||||||
|
void updatePetitionServiceResult(Long id, Integer result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得签呈申请
|
||||||
|
* @param id 编号
|
||||||
|
* @return 签呈详情
|
||||||
|
*/
|
||||||
|
BpmOAPetitionDO getPetition(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得签呈申请
|
||||||
|
* @param processInstanceId 流程实例编号
|
||||||
|
* @return 签呈详情
|
||||||
|
*/
|
||||||
|
BpmOAPetitionDO getByProcessInstanceId(String processInstanceId);
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.petition.BpmOAPetitionCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPetitionDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAPetitionMapper;
|
||||||
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_PETITION_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 签呈申请 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class BpmOAPetitionServiceImpl extends BpmOABaseService implements BpmOAPetitionService{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 签呈对应的流程定义 KEY
|
||||||
|
*/
|
||||||
|
public static final String PROCESS_KEY = "oa_petition_2";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOAPetitionMapper petitionMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createPetition(Long userId, BpmOAPetitionCreateReqVO createReqVO) {
|
||||||
|
|
||||||
|
//插入OA 签呈申请
|
||||||
|
BpmOAPetitionDO petitionDO = BeanUtils.toBean(createReqVO, BpmOAPetitionDO.class).setUserId(userId)
|
||||||
|
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||||
|
petitionMapper.insert(petitionDO);
|
||||||
|
|
||||||
|
// 发起 BPM 流程
|
||||||
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
|
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||||
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
|
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(petitionDO.getId())));
|
||||||
|
|
||||||
|
// 将工作流的编号,更新到 OA 加班单中
|
||||||
|
petitionMapper.updateById(new BpmOAPetitionDO().setId(petitionDO.getId()).setProcessInstanceId(processInstanceId));
|
||||||
|
|
||||||
|
// 判断是否为重新发起的流程
|
||||||
|
if (createReqVO.getProcessInstanceId() != null && createReqVO.getResult() == 3) {
|
||||||
|
|
||||||
|
historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
||||||
|
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||||
|
if (fileItems != null && !fileItems.isEmpty()) {
|
||||||
|
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
||||||
|
}
|
||||||
|
return petitionDO.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePetitionServiceResult(Long id, Integer result) {
|
||||||
|
|
||||||
|
validateLeaveExists(id);
|
||||||
|
petitionMapper.updateById(new BpmOAPetitionDO().setId(id).setResult(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmOAPetitionDO getPetition(Long id) {
|
||||||
|
|
||||||
|
return petitionMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmOAPetitionDO getByProcessInstanceId(String processInstanceId) {
|
||||||
|
|
||||||
|
return petitionMapper.selectOne(BpmOAPetitionDO::getProcessInstanceId, processInstanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLeaveExists(Long id) {
|
||||||
|
if (petitionMapper.selectById(id) == null) {
|
||||||
|
throw exception(OA_PETITION_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -193,7 +193,7 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
|||||||
}
|
}
|
||||||
|
|
||||||
//判断是否为备用金报销
|
//判断是否为备用金报销
|
||||||
boolean isImprest = false;
|
int isImprest = 0;
|
||||||
if (bpmOAReimbursementDO.getImprestId() != null) {
|
if (bpmOAReimbursementDO.getImprestId() != null) {
|
||||||
|
|
||||||
// 获取备用金详情
|
// 获取备用金详情
|
||||||
@ -208,15 +208,14 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
|||||||
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.FLAG_TRUE));
|
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.FLAG_TRUE));
|
||||||
|
|
||||||
if (bpmOAReimbursementDO.getDifference().compareTo(BigDecimal.ZERO) < 0) {
|
if (bpmOAReimbursementDO.getDifference().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
isImprest = true;
|
isImprest = 1;
|
||||||
}else {
|
}else {
|
||||||
return;
|
isImprest = 2;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//将相应备用金申请状态改为 未报销完毕
|
//将相应备用金申请状态改为 未报销完毕
|
||||||
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.NOT_COMPLETED));
|
bpmOAImprestMapper.updateById(updateVO.setStatus(BpmOAImprestDO.NOT_COMPLETED));
|
||||||
|
isImprest = 2;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,8 +233,8 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
|||||||
.setReason(reason)
|
.setReason(reason)
|
||||||
.setObjectId(id)
|
.setObjectId(id)
|
||||||
.setType(4)
|
.setType(4)
|
||||||
.setStatus(0)
|
.setStatus(isImprest == 2 ? 4 : 0)
|
||||||
.setAmountPayable(isImprest ? bpmOAReimbursementDO.getDifference().abs() : bpmOAReimbursementDO.getTotalMoney())
|
.setAmountPayable(isImprest == 1 ? bpmOAReimbursementDO.getDifference().abs() : bpmOAReimbursementDO.getTotalMoney())
|
||||||
.setProcessInstanceName(processInstance.getName())
|
.setProcessInstanceName(processInstance.getName())
|
||||||
.setBeginTime(processInstance.getCreateTime())
|
.setBeginTime(processInstance.getCreateTime())
|
||||||
.setEndTime(processInstance.getEndTime())
|
.setEndTime(processInstance.getEndTime())
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.oa.listener;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAPetitionService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAPetitionServiceImpl;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 签呈的结果的监听器实现类
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class BpmOAPetitionResultListener extends BpmProcessInstanceResultEventListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOAPetitionService petitionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getProcessDefinitionKey() {
|
||||||
|
return BpmOAPetitionServiceImpl.PROCESS_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||||
|
petitionService.updatePetitionServiceResult(Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||||
|
}
|
||||||
|
}
|
@ -93,6 +93,12 @@ spring:
|
|||||||
instance:
|
instance:
|
||||||
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
|
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
|
||||||
|
|
||||||
|
# 日志文件配置
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
# 配置自己写的 MyBatis Mapper 打印日志
|
||||||
|
cn.iocoder.yudao.module.bpm.dal.mysql: debug
|
||||||
|
|
||||||
--- #################### 芋道相关配置 ####################
|
--- #################### 芋道相关配置 ####################
|
||||||
|
|
||||||
# 芋道配置项,设置当前项目所有自定义的配置
|
# 芋道配置项,设置当前项目所有自定义的配置
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<select id="selectSimpleList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionSimpleVO">
|
<select id="selectSimpleList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionSimpleVO">
|
||||||
SELECT
|
SELECT
|
||||||
a.process_definition_id AS ProcessDefinitionId,
|
a.name AS name,
|
||||||
count(*) AS todoCount
|
count(*) AS todoCount
|
||||||
FROM
|
FROM
|
||||||
bpm_process_instance_ext a
|
bpm_process_instance_ext a
|
||||||
@ -27,18 +27,15 @@
|
|||||||
ON a.process_instance_id = b.process_instance_id
|
ON a.process_instance_id = b.process_instance_id
|
||||||
AND b.result = 1
|
AND b.result = 1
|
||||||
AND b.assignee_user_id = #{userId}
|
AND b.assignee_user_id = #{userId}
|
||||||
WHERE
|
<where>
|
||||||
a.process_definition_id IN
|
|
||||||
<foreach collection="definitionIds" item="id" index="index" open="(" close=")" separator=",">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
<if test="createTime != null and createTime.length > 0">
|
<if test="createTime != null and createTime.length > 0">
|
||||||
AND a.create_time
|
AND a.create_time
|
||||||
<foreach collection="createTime" item="time" index="index" open="BETWEEN" close="" separator="AND">
|
<foreach collection="createTime" item="time" index="index" open="BETWEEN" close="" separator="AND">
|
||||||
#{time}
|
#{time}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
</where>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
a.process_definition_id
|
a.name
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user