feat(bpm): 添加付款申请功能并优化采购单查询
- 新增付款申请相关表单、接口和服务实现 - 添加付款申请结果监听器 - 优化采购单查询接口,支持按类型筛选
This commit is contained in:
parent
16e541462c
commit
d9fbd61195
@ -60,6 +60,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode OA_REFUND_NOT_EXISTS = new ErrorCode(1_009_001_123, "退款申请不存在");
|
||||
ErrorCode OA_PROJECT_NOT_EXISTS = new ErrorCode(1_009_001_124, "项目申请不存在");
|
||||
ErrorCode OA_CONTRACT_INVOICE_AMOUNT_LACK = new ErrorCode(1_009_001_125, "该合同的开票余额不足!");
|
||||
ErrorCode OA_PAYMENT_NOT_EXISTS = new ErrorCode(1_009_001_126, "付款申请不存在");
|
||||
|
||||
// ========== 流程模型 1-009-002-000 ==========
|
||||
ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1_009_002_000, "已经存在流程标识为【{}】的流程");
|
||||
|
@ -0,0 +1,143 @@
|
||||
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.payment.BpmOAPaymentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAPaymentService;
|
||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||
import cn.iocoder.yudao.module.system.api.bank.dto.BankRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
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 java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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/payment")
|
||||
@Validated
|
||||
public class BpmOAPaymentController {
|
||||
|
||||
@Resource
|
||||
private BpmOAPaymentService paymentService;
|
||||
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建付款申请")
|
||||
public CommonResult<Long> createPayment(@Valid @RequestBody BpmOAPaymentCreateReqVO createReqVO) {
|
||||
|
||||
return success(paymentService.createPayment(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得付款申请")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<BpmOAPaymentRespVO> getPayment(@RequestParam("id") Long id) {
|
||||
|
||||
BpmOAPaymentDO payment = paymentService.getPayment(id);
|
||||
BpmOAPaymentRespVO respVO = BeanUtils.toBean(payment, BpmOAPaymentRespVO.class);
|
||||
if (respVO != null) {
|
||||
// 获取部门信息Map
|
||||
List<Long> deptIds = Arrays.asList(payment.getDeptId(), payment.getPaymentCompany());
|
||||
Map<Long, DeptRespDTO> dtoMap = deptApi.getDeptMap(new HashSet<>(deptIds));
|
||||
|
||||
// 设置部门名称
|
||||
respVO.setDeptName(dtoMap.get(payment.getDeptId()).getName());
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(dtoMap.get(payment.getPaymentCompany()).getName());
|
||||
|
||||
if (payment.getProjectNo() != null) {
|
||||
// 获取项目信息
|
||||
ProjectDTO project = projectApi.getProject(payment.getProjectNo()).getCheckedData();
|
||||
// 设置项目名称
|
||||
respVO.setProjectName(project.getName());
|
||||
}
|
||||
|
||||
if (payment.getBankId() != null) {
|
||||
// 获取银行卡信息
|
||||
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
|
||||
// 设置银行卡信息
|
||||
respVO.setBankName(bankResp.getBankName());
|
||||
respVO.setBankNo(bankResp.getBankNo());
|
||||
respVO.setNickname(bankResp.getNickname());
|
||||
}
|
||||
}
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/getByProcessInstanceId")
|
||||
@Operation(summary = "获得付款申请")
|
||||
@Parameter(name = "BpmOAPaymentRespVO", description = "流程实例编号", required = true, example = "1024")
|
||||
public CommonResult<BpmOAPaymentRespVO> getByProcessInstanceId(@RequestParam("processInstanceId") String processInstanceId) {
|
||||
|
||||
BpmOAPaymentDO payment = paymentService.getByProcessInstanceId(processInstanceId);
|
||||
BpmOAPaymentRespVO respVO = BeanUtils.toBean(payment, BpmOAPaymentRespVO.class);
|
||||
if (respVO != null) {
|
||||
// 获取部门信息Map
|
||||
List<Long> deptIds = Arrays.asList(payment.getDeptId(), payment.getPaymentCompany());
|
||||
Map<Long, DeptRespDTO> dtoMap = deptApi.getDeptMap(new HashSet<>(deptIds));
|
||||
|
||||
// 设置部门名称
|
||||
respVO.setDeptName(dtoMap.get(payment.getDeptId()).getName());
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(dtoMap.get(payment.getPaymentCompany()).getName());
|
||||
|
||||
if (payment.getProjectNo() != null) {
|
||||
// 获取项目信息
|
||||
ProjectDTO project = projectApi.getProject(payment.getProjectNo()).getCheckedData();
|
||||
// 设置项目名称
|
||||
respVO.setProjectName(project.getName());
|
||||
}
|
||||
|
||||
if (payment.getBankId() != null) {
|
||||
// 获取银行卡信息
|
||||
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
|
||||
// 设置银行卡信息
|
||||
respVO.setBankName(bankResp.getBankName());
|
||||
respVO.setBankNo(bankResp.getBankNo());
|
||||
respVO.setNickname(bankResp.getNickname());
|
||||
}
|
||||
}
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/get-list")
|
||||
@Operation(summary = "获得指定条件的付款申请")
|
||||
@Parameter(name = "type", description = "付款类型", required = true, example = "1")
|
||||
public CommonResult<List<BpmOAPaymentRespVO>> getPayment(@RequestParam("type") Integer type) {
|
||||
|
||||
return success(paymentService.getPaymentList(type));
|
||||
}
|
||||
}
|
@ -78,8 +78,8 @@ public class BpmOAProcurePayController {
|
||||
|
||||
@GetMapping("/getAvailablePurchaseOrders")
|
||||
@Operation(summary = "获取可用采购单列表")
|
||||
public CommonResult<List<BpmOAProcureRespVO>> getAvailablePurchaseOrders() {
|
||||
List<BpmOAProcureDO> list = oAProcurePayService.getAvailablePurchaseOrders();
|
||||
public CommonResult<List<BpmOAProcureRespVO>> getAvailablePurchaseOrders(@RequestParam(name = "type", required = false) Integer type) {
|
||||
List<BpmOAProcureDO> list = oAProcurePayService.getAvailablePurchaseOrders(type);
|
||||
return success(BeanUtils.toBean(list, BpmOAProcureRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款申请 创建 Request VO
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Schema(description = "管理后台 - 付款申请创建 Request VO")
|
||||
@Data
|
||||
public class BpmOAPaymentCreateReqVO {
|
||||
|
||||
@Schema(description = "申请事由", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "申请事由不能为空")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "付款类型 | 字典值参考 bpm_oa_payment_type", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "付款类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "费用产生部门编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private String projectNo;
|
||||
|
||||
@Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Long procureId;
|
||||
|
||||
@Schema(description = "银行编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Long bankId;
|
||||
|
||||
@Schema(description = "付款方式 | 1预付款 2分期付款 3全额付款", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Integer paymentMethod;
|
||||
|
||||
@Schema(description = "付款总额 | 针对预付款、分期付款情况", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description = "付款比例 | 针对分期付款情况", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Integer paymentRatio;
|
||||
|
||||
@Schema(description = "付款金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "付款金额不能为空")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "付款公司编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "付款公司编号不能为空")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "父级审批编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "流程实例编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "状态-参见 bpm_process_instance_result 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "上传文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<UploadUserFile> fileItems;
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment;
|
||||
|
||||
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 java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Schema(description = "管理后台 - 付款申请 请求Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOAPaymentRespVO extends BpmOABaseRespVO {
|
||||
|
||||
@Schema(description = "申请事由")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "付款类型 | 字典值参考 bpm_oa_payment_type")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "费用产生部门编号")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "费用产生部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "项目编号")
|
||||
private String projectNo;
|
||||
|
||||
@Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Long procureId;
|
||||
|
||||
@Schema(description = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@Schema(description = "银行编号")
|
||||
private Long bankId;
|
||||
|
||||
@Schema(description = "付款人昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "银行名称")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "银行账号")
|
||||
private String bankNo;
|
||||
|
||||
@Schema(description = "付款方式 | 1预付款 2分期付款 3全额付款")
|
||||
private Integer paymentMethod;
|
||||
|
||||
@Schema(description = "付款总额 | 针对预付款、分期付款情况")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description = "付款比例 | 针对分期付款情况")
|
||||
private Integer paymentRatio;
|
||||
|
||||
@Schema(description = "付款金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "付款公司编号")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "付款公司名称")
|
||||
private String paymentCompanyName;
|
||||
|
||||
@Schema(description = "父级审批编号")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "累计付款比列")
|
||||
private Integer ratio;
|
||||
|
||||
@Schema(description = "上传文件")
|
||||
private List<UploadUserFile> fileItems;
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
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.enums.task.BpmProcessInstanceResultEnum;
|
||||
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.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款申请 DO
|
||||
*
|
||||
* @author 艾楷
|
||||
*/
|
||||
@TableName("bpm_oa_payment")
|
||||
@KeySequence("bpm_oa_payment") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BpmOAPaymentDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 付款申请表单主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请人的用户编号
|
||||
* 关联 AdminUserDO 的 id 属性
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 申请事由
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 付款类型 | 字典值参考 bpm_oa_payment_type
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 费用产生部门编号
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String projectNo;
|
||||
|
||||
/**
|
||||
* 采购计划编号
|
||||
*/
|
||||
private Long procureId;
|
||||
|
||||
/**
|
||||
* 银行编号
|
||||
*/
|
||||
private Long bankId;
|
||||
|
||||
/**
|
||||
* 付款方式 | 1预付款 2分期付款 3全额付款
|
||||
*/
|
||||
private Integer paymentMethod;
|
||||
|
||||
/**
|
||||
* 付款总额 | 针对预付款、分期付款情况
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 付款比例 | 百分比数字
|
||||
*/
|
||||
private Integer paymentRatio;
|
||||
|
||||
/**
|
||||
* 付款金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 付款公司
|
||||
*/
|
||||
private Long paymentCompany;
|
||||
|
||||
/**
|
||||
* 父级审批
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 出差的结果
|
||||
* 枚举 {@link BpmProcessInstanceResultEnum}
|
||||
* 考虑到简单,所以直接复用了 BpmProcessInstanceResultEnum 枚举,也可以自己定义一个枚举哈
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 对应的流程编号
|
||||
* 关联 ProcessInstance 的 id 属性
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
/**
|
||||
* 附件基本信息
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<UploadUserFile> fileItems ;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPaymentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BpmOAPaymentMapper extends BaseMapperX<BpmOAPaymentDO> {
|
||||
|
||||
List<BpmOAPaymentRespVO> selectPaymentList(@Param("type") Integer type);
|
||||
}
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcurePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -34,5 +33,6 @@ public interface BpmOAProcureMapper extends BaseMapperX<BpmOAProcureDO> {
|
||||
.orderByDesc(BpmOAProcureDO::getId));
|
||||
}
|
||||
|
||||
List<BpmOAProcureDO> selectListByDeptId(@Param("companyDeptId") Long companyDeptId);
|
||||
List<BpmOAProcureDO> selectListByDeptId(@Param("companyDeptId") Long companyDeptId,
|
||||
@Param("type") Integer type);
|
||||
}
|
||||
|
@ -17,9 +17,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@ -91,7 +89,9 @@ public class BpmOAEvectionServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
// 发起出差申请后,判断是否是当天的出差
|
||||
if (evection.getStartTime().toLocalDate().isEqual(LocalDate.now())) {
|
||||
// 设置外勤打卡权限
|
||||
userApi.updateFieldworkType(getLoginUserId(), 1);
|
||||
Set<Long> userIds = evection.getTogetherUserIds();
|
||||
userIds.add(userId);
|
||||
userApi.updateFieldworkType(userIds, 1);
|
||||
}
|
||||
|
||||
return evection.getId();
|
||||
@ -100,7 +100,7 @@ public class BpmOAEvectionServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
@Override
|
||||
public void updateEvectionResult(Long id, Integer result) {
|
||||
|
||||
validateLeaveExists(id);
|
||||
BpmOAEvectionDO evectionDO = validateLeaveExists(id);
|
||||
evectionMapper.updateById(new BpmOAEvectionDO().setId(id).setResult(result));
|
||||
|
||||
// -- 自己取消
|
||||
@ -109,15 +109,19 @@ public class BpmOAEvectionServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
|| BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)
|
||||
|| BpmProcessInstanceResultEnum.BACK.getResult().equals(result)) {
|
||||
|
||||
// 发起外出申请后,设置关闭外勤打卡权限
|
||||
userApi.updateFieldworkType(getLoginUserId(), 0);
|
||||
// 设置关闭外勤打卡权限
|
||||
Set<Long> userIds = evectionDO.getTogetherUserIds();
|
||||
userIds.add(evectionDO.getUserId());
|
||||
userApi.updateFieldworkType(userIds, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (evectionMapper.selectById(id) == null) {
|
||||
private BpmOAEvectionDO validateLeaveExists(Long id) {
|
||||
BpmOAEvectionDO evectionDO = evectionMapper.selectById(id);
|
||||
if (evectionDO == null) {
|
||||
throw exception(OA_EVECTION_NOT_EXISTS);
|
||||
}
|
||||
return evectionDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,9 +17,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@ -84,7 +82,7 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
|
||||
// 发起外出申请后,判断是否是当天的外出
|
||||
if (goOut.getStartTime().toLocalDate().isEqual(LocalDate.now())) {
|
||||
// 设置外勤打卡权限
|
||||
userApi.updateFieldworkType(getLoginUserId(), 1);
|
||||
userApi.updateFieldworkType(Collections.singletonList(userId), 1);
|
||||
}
|
||||
|
||||
return goOut.getId();
|
||||
@ -102,7 +100,7 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
|
||||
|| BpmProcessInstanceResultEnum.BACK.getResult().equals(result)) {
|
||||
|
||||
// 发起外出申请后,设置关闭外勤打卡权限
|
||||
userApi.updateFieldworkType(getLoginUserId(), 0);
|
||||
userApi.updateFieldworkType(Collections.singletonList(getLoginUserId()), 0);
|
||||
}
|
||||
|
||||
goOutMapper.updateById(new BpmOAGoOutDO().setId(id).setResult(result));
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPaymentDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
public interface BpmOAPaymentService {
|
||||
|
||||
/**
|
||||
* 创建付款申请
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPayment(Long userId, @Valid BpmOAPaymentCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新付款申请的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param result 结果
|
||||
*/
|
||||
void updatePaymentResult(String processInstanceId, Long id, Integer result);
|
||||
|
||||
/**
|
||||
* 获得付款申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 退款申请
|
||||
*/
|
||||
BpmOAPaymentDO getPayment(Long id);
|
||||
|
||||
/**
|
||||
* 获得指定的付款申请
|
||||
* @param processInstanceId 流程实例编号
|
||||
* @return 退款申请
|
||||
*/
|
||||
BpmOAPaymentDO getByProcessInstanceId(String processInstanceId);
|
||||
|
||||
/**
|
||||
* 获得付款申请列表
|
||||
* @return 付款申请列表
|
||||
*/
|
||||
List<BpmOAPaymentRespVO> getPaymentList(Integer type);
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
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.payment.BpmOAPaymentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAPaymentMapper;
|
||||
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_PAYMENT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* OA 付款申请 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPaymentService{
|
||||
|
||||
/**
|
||||
* OA 付款对应的流程定义 KEY
|
||||
*/
|
||||
public static final String PROCESS_KEY = "oa_payment_2";
|
||||
|
||||
@Resource
|
||||
private BpmOAPaymentMapper paymentMapper;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||
|
||||
@Override
|
||||
public Long createPayment(Long userId, BpmOAPaymentCreateReqVO createReqVO) {
|
||||
|
||||
//插入OA 付款申请
|
||||
BpmOAPaymentDO paymentDO = BeanUtils.toBean(createReqVO, BpmOAPaymentDO.class).setUserId(userId)
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
paymentMapper.insert(paymentDO);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(paymentDO.getId())));
|
||||
|
||||
// 将工作流的编号,更新到 OA 付款申请单中
|
||||
paymentMapper.updateById(new BpmOAPaymentDO().setId(paymentDO.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 paymentDO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePaymentResult(String processInstanceId, Long id, Integer result) {
|
||||
|
||||
validateLeaveExists(id);
|
||||
paymentMapper.updateById(new BpmOAPaymentDO().setId(id).setResult(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOAPaymentDO getPayment(Long id) {
|
||||
|
||||
return paymentMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOAPaymentDO getByProcessInstanceId(String processInstanceId) {
|
||||
|
||||
return paymentMapper.selectOne(BpmOAPaymentDO::getProcessInstanceId, processInstanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmOAPaymentRespVO> getPaymentList(Integer type) {
|
||||
|
||||
return paymentMapper.selectPaymentList(type);
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (paymentMapper.selectById(id) == null) {
|
||||
throw exception(OA_PAYMENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ public interface BpmOAProcurePayService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<BpmOAProcureDO> getAvailablePurchaseOrders();
|
||||
List<BpmOAProcureDO> getAvailablePurchaseOrders(Integer type);
|
||||
|
||||
void updateEvectionResult(String processInstanceExtId, Long id, Integer result);
|
||||
|
||||
|
@ -41,7 +41,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -158,7 +157,7 @@ public class BpmOAProcurePayServiceImpl extends BpmOABaseService implements BpmO
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmOAProcureDO> getAvailablePurchaseOrders() {
|
||||
public List<BpmOAProcureDO> getAvailablePurchaseOrders(Integer type) {
|
||||
//获取当前登录用户id
|
||||
Long userId = WebFrameworkUtils.getLoginUserId();
|
||||
// 获取当前登录用的部门信息
|
||||
@ -171,7 +170,7 @@ public class BpmOAProcurePayServiceImpl extends BpmOABaseService implements BpmO
|
||||
DeptRespDTO company = deptApi.getUserCompanyDept(userId).getCheckedData();
|
||||
|
||||
// 查询当前用户所在公司下,所有部门可用的采购单
|
||||
return oaProcureMapper.selectListByDeptId(company.getId());
|
||||
return oaProcureMapper.selectListByDeptId(company.getId(), type);
|
||||
|
||||
}else {
|
||||
|
||||
@ -184,6 +183,7 @@ public class BpmOAProcurePayServiceImpl extends BpmOABaseService implements BpmO
|
||||
.in(BpmOAProcureDO::getUserId, userIds)
|
||||
.eq(BpmOAProcureDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult())
|
||||
.eq(BpmOAProcureDO::getPayFlag, BpmOAProcureDO.FLAG_FALSE)
|
||||
.eqIfPresent(BpmOAProcureDO::getProcureType, type)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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.BpmOAPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAPaymentServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* OA 签呈的结果的监听器实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Component
|
||||
public class BpmOAPaymentResultListener extends BpmProcessInstanceResultEventListener {
|
||||
|
||||
@Resource
|
||||
private BpmOAPaymentService paymentService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return BpmOAPaymentServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||
paymentService.updatePaymentResult(event.getId() ,Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAPaymentMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
|
||||
<select id="selectPaymentList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO">
|
||||
SELECT
|
||||
a.*,
|
||||
COALESCE(SUM( b.payment_ratio ), 0) + COALESCE(a.payment_ratio,0) AS ratio
|
||||
FROM
|
||||
bpm_oa_payment a
|
||||
LEFT JOIN bpm_oa_payment b ON b.parent_id = a.id AND b.result = 2
|
||||
WHERE
|
||||
ISNULL( a.parent_id )
|
||||
AND a.result = 2
|
||||
AND a.payment_method = #{type}
|
||||
GROUP BY
|
||||
a.id
|
||||
HAVING
|
||||
ratio < 100
|
||||
</select>
|
||||
</mapper>
|
@ -29,5 +29,8 @@
|
||||
a.result = 2
|
||||
AND a.pay_flag = 0
|
||||
AND a.deleted = 0
|
||||
<if test="type != null">
|
||||
AND a.procure_type = #{type}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user