feat(bpm): 增加借支还款功能并优化相关流程
- 新增借支还款列表接口和相关页面 - 实现借支申请和还款的分页查询功能 - 优化生产开支流程,增加支付管理和状态更新逻辑 - 修复备用金流程中的公司名称显示问题 - 重构借支申请接口,提高代码复用性
This commit is contained in:
parent
7b681b114b
commit
f2d3f9c9cf
@ -12,4 +12,7 @@ public class ReceiptSettlementDTO {
|
||||
|
||||
@Schema(description = "回款总金额")
|
||||
private BigDecimal money;
|
||||
|
||||
@Schema(description = "渠道商回款总金额")
|
||||
private BigDecimal channelAmount;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode OA_PAYMENT_FILES_NOT_NULL = new ErrorCode(1_009_001_128, "后补发票不能为空!");
|
||||
ErrorCode OA_EXPENSES_NOT_EXISTS = new ErrorCode(1_009_001_129, "开支日报申请不存在");
|
||||
ErrorCode OA_LOAN_NOT_EXISTS = new ErrorCode(1_009_001_130, "借支申请不存在");
|
||||
ErrorCode OA_LOAN_NOT_CREATE = new ErrorCode(1_009_001_131, "厂区员工信息不存在");
|
||||
|
||||
// ========== 流程模型 1-009-002-000 ==========
|
||||
ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1_009_002_000, "已经存在流程标识为【{}】的流程");
|
||||
|
@ -62,4 +62,16 @@ public class FinancialPaymentRespVO {
|
||||
|
||||
@Schema(description = "流程实例名称")
|
||||
private String processInstanceName;
|
||||
|
||||
@Schema(description = "收款人名称")
|
||||
private String recipientName;
|
||||
|
||||
@Schema(description = "付款公司编号")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "付款公司工厂编号")
|
||||
private Long companyFactoryId;
|
||||
|
||||
@Schema(description = "付款公司名称")
|
||||
private String companyName;
|
||||
}
|
||||
|
@ -74,4 +74,24 @@ public class BpmOAExpensesController {
|
||||
|
||||
return success(expensesService.getExpensesTotal(pageReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/payment")
|
||||
@Operation(summary = "提前付款")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> getPayment(Long id) {
|
||||
|
||||
expensesService.getPayment(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/refused")
|
||||
@Operation(summary = "拒绝付款")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@Parameter(name = "processInstanceId", description = "流程实例编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> refused(@RequestParam("id") Long id,
|
||||
@RequestParam("processInstanceId") String processInstanceId) {
|
||||
|
||||
expensesService.refused(id, processInstanceId);
|
||||
return success(true);
|
||||
}
|
||||
}
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.bpm.controller.admin.oa;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALoanDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
@ -143,30 +146,29 @@ public class BpmOALoanController {
|
||||
|
||||
@GetMapping("/get-list")
|
||||
@Operation(summary = "获得指定用户的借支申请列表")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<List<BpmOALoanRespVO>> getLoanList(@RequestParam("staffId") Long staffId) {
|
||||
public CommonResult<PageResult<BpmOALoanRespVO>> getLoanList(BpmOALoanPageReqVO pageReqVO) {
|
||||
|
||||
List<BpmOALoanDO> loanList = loanService.getListByStaffId(staffId);
|
||||
List<BpmOALoanRespVO> respVOS = BeanUtils.toBean(loanList, BpmOALoanRespVO.class);
|
||||
if (CollUtil.isNotEmpty(respVOS)) {
|
||||
PageResult<BpmOALoanDO> loanList = loanService.getListByStaffId(pageReqVO);
|
||||
PageResult<BpmOALoanRespVO> respVOS = BeanUtils.toBean(loanList, BpmOALoanRespVO.class);
|
||||
if (CollUtil.isNotEmpty(respVOS.getList())) {
|
||||
|
||||
// 获取支付信息
|
||||
List<String> processInstanceIds = convertList(loanList, BpmOALoanDO::getProcessInstanceId);
|
||||
List<String> processInstanceIds = convertList(loanList.getList(), BpmOALoanDO::getProcessInstanceId);
|
||||
Map<String, FinancialPaymentDO> financialPayments = convertMap(financialPaymentService.getFinancialPaymentList(processInstanceIds), FinancialPaymentDO::getProcessInstanceId);
|
||||
|
||||
// 获取申请人信息
|
||||
Set<Long> userIds = convertSet(loanList, BpmOALoanDO::getUserId);
|
||||
Set<Long> userIds = convertSet(loanList.getList(), BpmOALoanDO::getUserId);
|
||||
Map<Long, AdminUserRespDTO> userMap = userApi.getUserMap(userIds);
|
||||
|
||||
// 获取借支人信息
|
||||
Set<Long> loanUserIds = convertSet(loanList, BpmOALoanDO::getSfUserId);
|
||||
Set<Long> loanUserIds = convertSet(loanList.getList(), BpmOALoanDO::getSfUserId);
|
||||
Map<Long, StaffDTO> loanUserMap = convertMap(staffApi.getStaffList(loanUserIds).getCheckedData(), StaffDTO::getId);
|
||||
|
||||
// 获取工厂信息
|
||||
Set<Long> deptIds = convertSet(loanList, BpmOALoanDO::getFactoryId);
|
||||
Set<Long> deptIds = convertSet(loanList.getList(), BpmOALoanDO::getFactoryId);
|
||||
Map<Long, FactoryInfoDTO> factoryMap = factoryInfoApi.getFactoryMap(deptIds);
|
||||
|
||||
respVOS.forEach(item -> {
|
||||
respVOS.getList().forEach(item -> {
|
||||
// 设置申请人名称
|
||||
item.setUserName(userMap.get(item.getUserId()).getNickname());
|
||||
// 设置借支用户名称
|
||||
@ -180,4 +182,13 @@ public class BpmOALoanController {
|
||||
|
||||
return success(respVOS);
|
||||
}
|
||||
|
||||
@GetMapping("/get-return-list")
|
||||
@Operation(summary = "获得指定用户的还款列表")
|
||||
public CommonResult<PageResult<BpmOAReturnVO>> getReturnList(BpmOALoanPageReqVO pageReqVO) {
|
||||
|
||||
PageResult<BpmOAReturnVO> respVOS = loanService.getReturnList(pageReqVO);
|
||||
|
||||
return success(respVOS);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class BpmOAExpensesCreateReqVO {
|
||||
@Schema(description = "开支明细")
|
||||
private List<Expenses> expensesItem;
|
||||
|
||||
@Schema(description = "工厂类型 | 1公司 工厂")
|
||||
@Schema(description = "工厂类型 |1工厂 2公司 ")
|
||||
private Integer factoryType;
|
||||
|
||||
@Schema(description = "报销总金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
@ -14,4 +14,7 @@ public class BpmOAExpensesTotal {
|
||||
|
||||
@Schema(description = "应付款金额")
|
||||
private BigDecimal payableAmount;
|
||||
|
||||
@Schema(description = "剩余付款金额")
|
||||
private BigDecimal remainingPayable;
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 借支申请分页 Request VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BpmOALoanPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "员工ID")
|
||||
private Long staffId;
|
||||
|
||||
@Schema(description = "借支类型")
|
||||
private Integer loanType;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 借支申请还款 Response VO")
|
||||
@Data
|
||||
public class BpmOAReturnVO {
|
||||
|
||||
@Schema(description = "员工ID")
|
||||
private Long staffId;
|
||||
|
||||
@Schema(description = "员工名称")
|
||||
private String staffName;
|
||||
|
||||
@Schema(description = "工厂ID")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "工厂名称")
|
||||
private String factoryName;
|
||||
|
||||
@Schema(description = "还款月份")
|
||||
private String month;
|
||||
|
||||
@Schema(description = "还款金额")
|
||||
private BigDecimal repaymentAmount;
|
||||
|
||||
@Schema(description = "还款类型 | 1开支抵扣 2工资还款")
|
||||
private Integer type;
|
||||
}
|
@ -55,7 +55,7 @@ public class FinancialPaymentDO extends BaseDO {
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 流程类型 1现金支出 2备用金 3采购付款 4报销 5付款申请 6薪资付款 7借支申请 8供应商采购付款
|
||||
* 流程类型 1现金支出 2备用金 3采购付款 4报销 5付款申请 6薪资付款 7借支申请 8供应商采购付款 9开支日报
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
@ -83,6 +83,19 @@ public class FinancialPaymentDO extends BaseDO {
|
||||
* 流程结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 收款人名称
|
||||
*/
|
||||
private String recipientName;
|
||||
/**
|
||||
* 付款公司编号
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 公司工厂编号
|
||||
*/
|
||||
private Long companyFactoryId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
@ -99,4 +112,9 @@ public class FinancialPaymentDO extends BaseDO {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String receiveUserNickName;
|
||||
/**
|
||||
* 付款公司名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String companyName;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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 liquibase.pro.packaged.I;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -54,6 +55,16 @@ public class BpmOAExpensesDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
/**
|
||||
* 支付金额
|
||||
*/
|
||||
private BigDecimal amountPaid;
|
||||
|
||||
/**
|
||||
* 支付状态 | 0未支付 1已支付 2已抵扣 3未抵扣完
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 申请结果
|
||||
* 枚举 {@link BpmProcessInstanceResultEnum}
|
||||
|
@ -69,6 +69,11 @@ public class BpmOALoanDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
/**
|
||||
* 还款金额
|
||||
*/
|
||||
private BigDecimal returnAmount;
|
||||
|
||||
/**
|
||||
* 借支原因
|
||||
*/
|
||||
|
@ -1,8 +1,12 @@
|
||||
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.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALoanDO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -14,4 +18,7 @@ public interface BpmOALoanMapper extends BaseMapperX<BpmOALoanDO> {
|
||||
|
||||
List<BpmOALoanSumDTO> selectSumByStaffId(@Param("staffId") Collection<Long> staffId,
|
||||
@Param("month") String month);
|
||||
|
||||
IPage<BpmOAReturnVO> selectReturnList(@Param("pageReqVO") BpmOALoanPageReqVO pageReqVO,
|
||||
@Param("page") IPage<BpmOAReturnVO> page);
|
||||
}
|
||||
|
@ -89,6 +89,13 @@ public interface FinancialPaymentService {
|
||||
*/
|
||||
List<FinancialPaymentDO> getFinancialPaymentList(List<String> processInstanceIds);
|
||||
|
||||
/**
|
||||
* 根据流程实例编号获取支付信息
|
||||
* @param processInstanceId 流程实例编号
|
||||
* @return 支付信息
|
||||
*/
|
||||
FinancialPaymentDO getFinancialPaymentByProcessInstanceId(String processInstanceId);
|
||||
|
||||
/**
|
||||
* 获取支付信息 统计
|
||||
* @param pageReqVO 查询条件
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.financialpayment;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
@ -24,6 +25,7 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.oa.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAExpensesService;
|
||||
import cn.iocoder.yudao.module.system.api.auth.AdminOauthUserOtherInfoApi;
|
||||
import cn.iocoder.yudao.module.system.api.auth.dto.AdminOauthUserOtherInfoApiDTO;
|
||||
import cn.iocoder.yudao.module.system.api.auth.vo.AdminOauthUserOtherInfoApiVO;
|
||||
@ -89,6 +91,9 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
@Resource
|
||||
private BpmOASalaryMapper salaryMapper;
|
||||
|
||||
@Resource
|
||||
private BpmOAExpensesMapper expensesMapper;
|
||||
|
||||
@Override
|
||||
public Long createFinancialPayment(FinancialPaymentSaveVO vo) {
|
||||
FinancialPaymentItemSaveReqVO createReqVO = vo.getFinancialPaymentItemSaveReqVO();
|
||||
@ -139,6 +144,8 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
case 8:
|
||||
supplierPurchasePaymentMapper.updateById(new BpmOASupplierPurchasePaymentDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult()));
|
||||
break;
|
||||
case 9:
|
||||
expensesMapper.updateById(new BpmOAExpensesDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult()));
|
||||
}
|
||||
BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(financialPayment.getProcessInstanceId())
|
||||
.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus())
|
||||
@ -147,19 +154,31 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
}
|
||||
this.updateById(financialPayment);
|
||||
|
||||
// 判断是借支申请时
|
||||
if (financialPayment.getType() == 7 && financialPayment.getStatus() == 2) {
|
||||
// 支付完成时
|
||||
if (financialPayment.getStatus() == 2) {
|
||||
|
||||
// 获取借支信息
|
||||
BpmOALoanDO loanDO = loanMapper.selectById(financialPayment.getObjectId());
|
||||
switch (financialPayment.getType()) {
|
||||
case 7: // 借支申请时
|
||||
// 获取借支信息
|
||||
BpmOALoanDO loanDO = loanMapper.selectById(financialPayment.getObjectId());
|
||||
|
||||
// 同步插入借支表中
|
||||
LoanDTO createDO = new LoanDTO()
|
||||
.setUserId(loanDO.getSfUserId())
|
||||
.setDeptId(loanDO.getFactoryId())
|
||||
.setAmount(loanDO.getTotalMoney())
|
||||
.setReturnAmount(BigDecimal.ZERO);
|
||||
loanApi.createLoan(createDO);
|
||||
// 同步插入借支表中
|
||||
LoanDTO createDO = new LoanDTO()
|
||||
.setUserId(loanDO.getSfUserId())
|
||||
.setDeptId(loanDO.getFactoryId())
|
||||
.setLoanType(loanDO.getLoanType())
|
||||
.setAmount(loanDO.getTotalMoney())
|
||||
.setReturnAmount(BigDecimal.ZERO);
|
||||
loanApi.createLoan(createDO);
|
||||
break;
|
||||
case 9: // 开支日报时
|
||||
// 更新开支日报支付状态、支付金额
|
||||
expensesMapper.updateById(new BpmOAExpensesDO()
|
||||
.setId(financialPayment.getObjectId())
|
||||
.setStatus(1)
|
||||
.setAmountPaid(financialPayment.getActualPayment()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// -- 获取发起人的openId
|
||||
@ -253,6 +272,15 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FinancialPaymentDO getFinancialPaymentByProcessInstanceId(String processInstanceId) {
|
||||
List<FinancialPaymentDO> financialPaymentDO = financialPaymentMapper.selectList(FinancialPaymentDO::getProcessInstanceId, processInstanceId);
|
||||
if (CollUtil.isNotEmpty(financialPaymentDO)) {
|
||||
return financialPaymentDO.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FinancialPaymentDO getPaymentTotal(FinancialPaymentPageReqVO pageReqVO) {
|
||||
pageReqVO.setReceiveUserId(getLoginUserId());
|
||||
|
@ -229,6 +229,16 @@ public class BpmOACashServiceImpl extends BpmOABaseService implements BpmOACashS
|
||||
|
||||
BpmProcessInstanceExtDO processInstance = bpmProcessInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(cash.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getCompanyByDept(cashItemDOs.get(0).getDeptId()).getCheckedData();
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = new BankRespDTO();
|
||||
if (cash.getBankId() != null) {
|
||||
bankRespDTO = bankApi.getBank(cash.getBankId()).getCheckedData();
|
||||
}
|
||||
|
||||
// -- 插入到财务支付表中
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(cash.getUserId())
|
||||
@ -242,6 +252,8 @@ public class BpmOACashServiceImpl extends BpmOABaseService implements BpmOACashS
|
||||
.setAmountPayable(isImprest == 1 ? amount.abs() : cash.getTotalMoney())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
.setCompanyId(deptRespDTO != null ? deptRespDTO.getId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAExpensesDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAExpensesItemDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public interface BpmOAExpensesService {
|
||||
@ -70,4 +71,24 @@ public interface BpmOAExpensesService {
|
||||
* @return 统计信息
|
||||
*/
|
||||
BpmOAExpensesTotal getExpensesTotal(BpmOAExpensesPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 提前付款 | 手动插入至支付管理
|
||||
* @param id 生产开支id
|
||||
*/
|
||||
void getPayment(Long id);
|
||||
|
||||
/**
|
||||
* 更新生产开支 支付状态
|
||||
* @param status 支付状态
|
||||
* @param amountPaid 支付金额
|
||||
*/
|
||||
void updateExpenses(Long id ,Integer status, BigDecimal amountPaid);
|
||||
|
||||
/**
|
||||
* 拒绝付款
|
||||
* @param id 生产开支id
|
||||
* @param processInstanceId 流程实例编号
|
||||
*/
|
||||
void refused(Long id, String processInstanceId);
|
||||
}
|
||||
|
@ -1,40 +1,50 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
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.controller.admin.oa.vo.expenses.*;
|
||||
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAExpensesConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAExpensesDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAExpensesItemDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAExpensesItemMapper;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAExpensesMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.dto.FactoryInfoDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
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.loan.LoanApi;
|
||||
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_EXPENSES_NOT_EXISTS;
|
||||
|
||||
@ -59,7 +69,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
private BpmOAExpensesItemMapper expensesItemMapper;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoApi factoryInfoApi;
|
||||
@ -67,10 +77,22 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@Resource
|
||||
private FinancialPaymentService financialPaymentService;
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private LoanApi loanApi;
|
||||
|
||||
@Resource
|
||||
private StaffApi staffApi;
|
||||
|
||||
@Override
|
||||
public Long createExpenses(Long userId, BpmOAExpensesCreateReqVO createReqVO) {
|
||||
|
||||
@ -90,9 +112,9 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
String type = bpmOAExpensesItemDOS.stream().map(item -> item.getType().toString()).collect(Collectors.joining(","));
|
||||
processInstanceVariables.put("type", type);
|
||||
processInstanceVariables.put("factoryType", expenses.getFactoryType());
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(expenses.getId()))).getCheckedData();
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(expenses.getId())));
|
||||
|
||||
// 将工作流的编号,更新到 OA 生产开支单中
|
||||
expensesMapper.updateById(new BpmOAExpensesDO().setId(expenses.getId()).setProcessInstanceId(processInstanceId));
|
||||
@ -118,7 +140,48 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
// 获得现金支出业务数据
|
||||
BpmOAExpensesDO expenses = validateLeaveExists(id);
|
||||
|
||||
expensesMapper.updateById(new BpmOAExpensesDO().setId(id).setResult(result));
|
||||
//审核通过 (最后节点)
|
||||
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
|
||||
|
||||
ProcessInstance instance = processInstanceService.getProcessInstance(processInstanceId);
|
||||
if (instance.isEnded()) {
|
||||
|
||||
// 获取申请人对应的厂区员工编号
|
||||
StaffDTO staffDTO = staffApi.getStaffByUserId(expenses.getUserId()).getCheckedData();
|
||||
if (staffDTO != null) {
|
||||
|
||||
// 判断申请人是否存在 费用借支
|
||||
LoanDTO loanDTO = loanApi.getByUserId(staffDTO.getId(), 2).getCheckedData();
|
||||
if (loanDTO != null) {
|
||||
|
||||
if (loanDTO.getRemainingAmount().compareTo(expenses.getTotalMoney()) >= 0) {
|
||||
|
||||
// 设置开支日报支付状态为 已抵扣
|
||||
expenses.setStatus(2).setAmountPaid(expenses.getTotalMoney());
|
||||
|
||||
}else {
|
||||
|
||||
// 设置开支日报支付状态为 未抵扣完毕
|
||||
expenses.setStatus(3).setAmountPaid(loanDTO.getRemainingAmount());
|
||||
}
|
||||
|
||||
// 更新借支表中 归还金额
|
||||
loanApi.createLoan(new LoanDTO()
|
||||
.setUserId(staffDTO.getId())
|
||||
.setLoanType(2)
|
||||
.setAmount(BigDecimal.ZERO)
|
||||
.setReturnAmount(expenses.getAmountPaid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新开支日报 审批结果、支付状态以及支付金额
|
||||
expensesMapper.updateById(new BpmOAExpensesDO()
|
||||
.setId(id)
|
||||
.setResult(result)
|
||||
.setStatus(expenses.getStatus())
|
||||
.setAmountPaid(expenses.getAmountPaid()));
|
||||
}
|
||||
|
||||
private BpmOAExpensesDO validateLeaveExists(Long id) {
|
||||
@ -181,4 +244,70 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
public BpmOAExpensesTotal getExpensesTotal(BpmOAExpensesPageReqVO pageReqVO) {
|
||||
return expensesMapper.selectTotal(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPayment(Long id) {
|
||||
|
||||
// 获取开支详情
|
||||
BpmOAExpensesDO expenses = this.getExpenses(id);
|
||||
List<BpmOAExpensesItemDO> expensesItems = this.getExpensesItem(id);
|
||||
|
||||
// 校验是否已添加至支付管理
|
||||
if (financialPaymentService.getFinancialPaymentByProcessInstanceId(expenses.getProcessInstanceId()) == null) {
|
||||
|
||||
String reason = expensesItems.stream().map(BpmOAExpensesItemDO::getDetail)
|
||||
.filter(StrUtil::isNotEmpty)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
BpmProcessInstanceExtDO processInstance = processInstanceService.getProcessInstanceDO(expenses.getProcessInstanceId());
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(expenses.getUserId());
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = bankApi.getBank(expenses.getBankId()).getCheckedData();
|
||||
|
||||
// 获取付款公司信息
|
||||
FactoryInfoDTO dto = new FactoryInfoDTO();
|
||||
if (expenses.getFactoryType() == 1) {
|
||||
dto = factoryInfoApi.getFactoryInfo(expensesItems.get(0).getDeptId()).getCheckedData();
|
||||
}
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(expenses.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
.setProcessInstanceId(expenses.getProcessInstanceId())
|
||||
.setReason(reason)
|
||||
.setObjectId(id)
|
||||
.setType(9)
|
||||
.setStatus(0)
|
||||
.setAmountPayable(expenses.getTotalMoney())
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
.setCompanyFactoryId(dto.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExpenses(Long id ,Integer status, BigDecimal amountPaid) {
|
||||
|
||||
expensesMapper.updateById(new BpmOAExpensesDO()
|
||||
.setId(id)
|
||||
.setStatus(status)
|
||||
.setAmountPaid(amountPaid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refused(Long id, String processInstanceId) {
|
||||
|
||||
// 设置状态为 驳回
|
||||
expensesMapper.updateById(new BpmOAExpensesDO()
|
||||
.setId(id)
|
||||
.setResult(BpmProcessInstanceResultEnum.BACK.getResult()));
|
||||
|
||||
// 同步更新流程实例表
|
||||
processInstanceService.updateProcessInstanceResult(processInstanceId, BpmProcessInstanceResultEnum.BACK.getResult());
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
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.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -40,7 +44,7 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_IMPREST_NO
|
||||
public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAImprestService {
|
||||
|
||||
/**
|
||||
* OA 出差对应的流程定义 KEY
|
||||
* OA 备用金对应的流程定义 KEY
|
||||
*/
|
||||
public static final String PROCESS_KEY = "oa_imprest";
|
||||
|
||||
@ -49,14 +53,23 @@ public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAIm
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
|
||||
@Resource
|
||||
private FinancialPaymentService financialPaymentService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@Resource
|
||||
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||
|
||||
@ -95,7 +108,7 @@ public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAIm
|
||||
@Override
|
||||
public void updateImprestResult(String processInstanceId, Long id, Integer result) {
|
||||
|
||||
validateLeaveExists(id);
|
||||
BpmOAImprestDO imprestDO = validateLeaveExists(id);
|
||||
imprestMapper.updateById(new BpmOAImprestDO().setId(id).setResult(result));
|
||||
|
||||
//审核通过 (最后节点)
|
||||
@ -105,31 +118,44 @@ public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAIm
|
||||
|
||||
if (instance.isEnded()) {
|
||||
//判断是否有采购报销
|
||||
BpmOAImprestDO cash = getImprest(id);
|
||||
BpmProcessInstanceExtDO processInstance = bpmProcessInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(cash.getUserId());
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(imprestDO.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(imprestDO.getCompanyId()).getCheckedData();
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = new BankRespDTO();
|
||||
if (imprestDO.getBankId() != null) {
|
||||
bankRespDTO = bankApi.getBank(imprestDO.getBankId()).getCheckedData();
|
||||
}
|
||||
|
||||
// -- 插入到财务支付表中
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(cash.getUserId())
|
||||
.setUserId(imprestDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
.setProcessInstanceId(cash.getProcessInstanceId())
|
||||
.setReason(cash.getReason())
|
||||
.setProcessInstanceId(imprestDO.getProcessInstanceId())
|
||||
.setReason(imprestDO.getReason())
|
||||
.setObjectId(id)
|
||||
.setType(2)
|
||||
.setStatus(0)
|
||||
.setAmountPayable(cash.getAmount())
|
||||
.setAmountPayable(imprestDO.getAmount())
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
.setCompanyId(deptRespDTO != null ? deptRespDTO.getId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (imprestMapper.selectById(id) == null) {
|
||||
private BpmOAImprestDO validateLeaveExists(Long id) {
|
||||
BpmOAImprestDO imprestDO = imprestMapper.selectById(id);
|
||||
if (imprestDO == null) {
|
||||
throw exception(OA_IMPREST_NOT_EXISTS);
|
||||
}
|
||||
return imprestDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALoanDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -50,11 +53,11 @@ public interface BpmOALoanService {
|
||||
BpmOALoanDO getByProcessInstanceId(String processInstanceId);
|
||||
|
||||
/**
|
||||
* 获得指定用户的借支列表
|
||||
* @param staffId 员工编号
|
||||
* 获得指定用户的借支分页列表
|
||||
* @param pageReqVO 分页参数
|
||||
* @return 借支列表
|
||||
*/
|
||||
List<BpmOALoanDO> getListByStaffId(Long staffId);
|
||||
PageResult<BpmOALoanDO> getListByStaffId(BpmOALoanPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取员工当月需抵扣的借支金额
|
||||
@ -62,4 +65,11 @@ public interface BpmOALoanService {
|
||||
* @return 借支金额统计
|
||||
*/
|
||||
List<BpmOALoanSumDTO> getListByStaffId(Collection<Long> staffId, String month);
|
||||
|
||||
/**
|
||||
* 获取员工还款分页列表
|
||||
* @param pageReqVO 分页信息
|
||||
* @return 还款分页列表
|
||||
*/
|
||||
PageResult<BpmOAReturnVO> getReturnList(BpmOALoanPageReqVO pageReqVO);
|
||||
}
|
||||
|
@ -2,12 +2,16 @@ package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOALoanPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALoanDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
@ -16,8 +20,13 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
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.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -30,6 +39,7 @@ 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_LOAN_NOT_CREATE;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LOAN_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -61,10 +71,26 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
@Resource
|
||||
private FinancialPaymentService financialPaymentService;
|
||||
|
||||
@Resource
|
||||
private StaffApi staffApi;
|
||||
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createLoan(Long userId, BpmOALoanCreateReqVO vo) {
|
||||
|
||||
// 提交是费用借支时
|
||||
if (vo.getLoanType() == 2) {
|
||||
|
||||
// 校验创建
|
||||
StaffDTO staffDTO = validateCreate(userId, vo);
|
||||
vo.setSfUserId(staffDTO.getId());
|
||||
vo.setFactoryId(staffDTO.getFactoryId());
|
||||
}
|
||||
|
||||
//插入OA 借支申请
|
||||
BpmOALoanDO loan = BeanUtils.toBean(vo, BpmOALoanDO.class)
|
||||
.setUserId(userId)
|
||||
@ -92,9 +118,19 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
return loan.getId();
|
||||
}
|
||||
|
||||
private StaffDTO validateCreate(Long userId, BpmOALoanCreateReqVO vo) {
|
||||
|
||||
StaffDTO staffDTO = staffApi.getStaffByUserId(userId).getCheckedData();
|
||||
if (staffDTO == null) {
|
||||
throw exception(OA_LOAN_NOT_CREATE);
|
||||
}
|
||||
|
||||
return staffDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLoanResult(String processInstanceId, Long id, Integer result) {
|
||||
BpmOALoanDO loanDO = validateLeaveExists(id);
|
||||
BpmOALoanDO loanDO = validateLoanExists(id);
|
||||
loanMapper.updateById(new BpmOALoanDO().setId(id).setResult(result));
|
||||
|
||||
//审核通过 (最后节点)
|
||||
@ -106,6 +142,10 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
BpmProcessInstanceExtDO processInstance = processInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(loanDO.getUserId());
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = bankApi.getBank(loanDO.getBankId()).getCheckedData();
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(loanDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
@ -118,12 +158,13 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BpmOALoanDO validateLeaveExists(Long id) {
|
||||
private BpmOALoanDO validateLoanExists(Long id) {
|
||||
BpmOALoanDO loanDO = loanMapper.selectById(id);
|
||||
if (loanDO == null) {
|
||||
throw exception(OA_LOAN_NOT_EXISTS);
|
||||
@ -148,9 +189,10 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmOALoanDO> getListByStaffId(Long staffId) {
|
||||
return loanMapper.selectList(new LambdaQueryWrapperX<BpmOALoanDO>()
|
||||
.eq(BpmOALoanDO::getSfUserId, staffId)
|
||||
public PageResult<BpmOALoanDO> getListByStaffId(BpmOALoanPageReqVO pageReqVO) {
|
||||
return loanMapper.selectPage(pageReqVO, new LambdaQueryWrapperX<BpmOALoanDO>()
|
||||
.eq(BpmOALoanDO::getSfUserId, pageReqVO.getStaffId())
|
||||
.eq(BpmOALoanDO::getLoanType, pageReqVO.getLoanType())
|
||||
.eq(BpmOALoanDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult()));
|
||||
}
|
||||
|
||||
@ -158,4 +200,10 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
public List<BpmOALoanSumDTO> getListByStaffId(Collection<Long> staffId, String month) {
|
||||
return loanMapper.selectSumByStaffId(staffId, month);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmOAReturnVO> getReturnList(BpmOALoanPageReqVO pageReqVO) {
|
||||
IPage<BpmOAReturnVO> page = loanMapper.selectReturnList(pageReqVO, MyBatisUtils.buildPage(pageReqVO));
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,16 @@ public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPa
|
||||
BpmProcessInstanceExtDO processInstance = processInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(paymentDO.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(paymentDO.getPaymentCompany()).getCheckedData();
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = new BankRespDTO();
|
||||
if (paymentDO.getBankId() != null) {
|
||||
bankRespDTO = bankApi.getBank(paymentDO.getBankId()).getCheckedData();
|
||||
}
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(paymentDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
@ -137,6 +147,8 @@ public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPa
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
.setCompanyId(deptRespDTO != null ? deptRespDTO.getId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
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.user.AdminUserApi;
|
||||
@ -181,12 +182,6 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
|
||||
//判断是否有采购报销
|
||||
List<Long> procureIds = new ArrayList<>();
|
||||
// List<Reimbursement> reimbursements = bpmOAReimbursementDO.getReimbursements();
|
||||
//
|
||||
// //直接从数据库取出来的List<Reimbursement> 实际上是List<LinkedHashMap>类型 所以不能直接遍历
|
||||
// //将list再次转为json串,然后由json串再转为list
|
||||
// String json = JsonUtils.toJsonString(reimbursements);
|
||||
// reimbursements = JsonUtils.parseArray(json, Reimbursement.class);
|
||||
for (BpmOAReimbursementItemDO reimbursement : reimbursements) {
|
||||
//报销类别为 采购费时
|
||||
if ("4".equals(reimbursement.getType())) {
|
||||
@ -238,6 +233,10 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
BpmProcessInstanceExtDO processInstance = bpmProcessInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(bpmOAReimbursementDO.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getCompanyByDept(reimbursements.get(0).getDeptId()).getCheckedData();
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(bpmOAReimbursementDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
@ -250,6 +249,8 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bpmOAReimbursementDO.getNickname())
|
||||
.setCompanyId(deptRespDTO != null ? deptRespDTO.getId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
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.user.AdminUserApi;
|
||||
@ -110,6 +111,10 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
|
||||
BpmProcessInstanceExtDO processInstance = processInstanceService.getProcessInstanceDO(processInstanceId);
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(salaryDO.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(salaryDO.getCompanyDeptId()).getCheckedData();
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(salaryDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
@ -122,6 +127,7 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setCompanyId(deptRespDTO != null && deptRespDTO.getFactoryId() == null ? deptRespDTO.getId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,14 @@ public interface BpmProcessInstanceService {
|
||||
*/
|
||||
void updateProcessInstanceExtReject(String id, String reason);
|
||||
|
||||
/**
|
||||
* 更新 ProcessInstance 拓展记录结果
|
||||
*
|
||||
* @param id 流程编号
|
||||
* @param result 结果
|
||||
*/
|
||||
void updateProcessInstanceResult(String id, Integer result);
|
||||
|
||||
/**
|
||||
* /**
|
||||
* 流程实例数量统计查询
|
||||
|
File diff suppressed because one or more lines are too long
@ -15,11 +15,14 @@
|
||||
a.*,
|
||||
b.nickname as nickname,
|
||||
c.name as deptName,
|
||||
d.nickname as receiveUserNickName
|
||||
d.nickname as receiveUserNickName,
|
||||
case when ISNULL(a.company_id) THEN sf.short_name ELSE company.short_name END as companyName
|
||||
from bpm_financial_payment as a
|
||||
left join system_users as b on a.user_id = b.id
|
||||
left join system_dept as c on b.dept_id = c.id
|
||||
left join system_users as d on a.receive_user_id = d.id
|
||||
left join system_dept as company on company.id = a.company_id
|
||||
left join sf_factory_info as sf on sf.id = a.company_factory_id
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="vo.deptIds != null and vo.deptIds.size() > 0">
|
||||
|
@ -26,7 +26,8 @@
|
||||
ub.bank_name AS bankName,
|
||||
b.total_money AS totalMoney,
|
||||
b.process_instance_id AS processInstanceId,
|
||||
c.end_time AS endTime
|
||||
c.end_time AS endTime,
|
||||
b.status AS status
|
||||
FROM bpm_oa_expenses b
|
||||
JOIN bpm_oa_expenses_item a ON a.expenses_id = b.id
|
||||
JOIN bpm_process_instance_ext c ON c.process_instance_id = b.process_instance_id
|
||||
@ -62,8 +63,9 @@
|
||||
|
||||
<select id="selectTotal" resultType="cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.expenses.BpmOAExpensesTotal">
|
||||
SELECT
|
||||
SUM(a.total_money) AS payableAmount,
|
||||
SUM(a.amount_paid) AS amountPaid,
|
||||
SUM(a.total_money) - SUM(a.amount_paid) AS payableAmount
|
||||
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
|
||||
FROM
|
||||
bpm_oa_expenses a
|
||||
JOIN bpm_oa_expenses_item b ON b.expenses_id = b.id
|
||||
|
@ -19,11 +19,58 @@
|
||||
deleted = 0
|
||||
AND result = 2
|
||||
AND return_date = #{month}
|
||||
sf_user_id IN
|
||||
AND sf_user_id IN
|
||||
<foreach item="item" index="index" collection="staffId" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
sf_user_id
|
||||
</select>
|
||||
|
||||
<select id="selectReturnList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO">
|
||||
<if test="pageReqVO.loanType == 1">
|
||||
SELECT
|
||||
s.staff_id AS staffId,
|
||||
CONVERT(st.nick_name USING utf8mb4) COLLATE utf8mb4_unicode_ci AS staffName,
|
||||
s.factory_id AS factoryId,
|
||||
sf.short_name AS factoryName,
|
||||
s.month AS month,
|
||||
s.return_amount AS repaymentAmount,
|
||||
2 AS type
|
||||
FROM
|
||||
sf_staff_salary s
|
||||
LEFT JOIN sf_staff st ON s.staff_id = st.id
|
||||
LEFT JOIN sf_factory_info sf ON s.factory_id = sf.id
|
||||
WHERE
|
||||
s.staff_id = #{pageReqVO.staffId}
|
||||
AND s.return_amount > 0
|
||||
AND s.deleted = 0
|
||||
AND st.deleted = 0
|
||||
AND sf.deleted = 0
|
||||
</if>
|
||||
<if test="pageReqVO.loanType == 2">
|
||||
SELECT
|
||||
e.user_id AS staffId,
|
||||
u.nickname AS staffName,
|
||||
d.factory_id AS factoryId,
|
||||
d.name AS factoryName,
|
||||
DATE_FORMAT( p.end_time, '%Y-%m' ) AS month,
|
||||
e.amount_paid AS repaymentAmount,
|
||||
1 AS type
|
||||
FROM
|
||||
bpm_oa_expenses e
|
||||
JOIN bpm_oa_loan l ON e.user_id = l.user_id AND l.sf_user_id = #{pageReqVO.staffId}
|
||||
LEFT JOIN system_users u ON e.user_id = u.id
|
||||
LEFT JOIN system_dept d ON u.dept_id = d.id
|
||||
LEFT JOIN bpm_process_instance_ext p ON e.process_instance_id = p.process_instance_id
|
||||
WHERE
|
||||
e.deleted = 0
|
||||
AND e.result = 2
|
||||
AND e.status = 2
|
||||
AND l.deleted = 0
|
||||
AND u.deleted = 0
|
||||
AND d.deleted = 0
|
||||
AND p.deleted = 0
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -62,21 +62,24 @@
|
||||
<select id="getReceiptSettlement"
|
||||
resultType="cn.iocoder.yudao.module.bpm.api.oa.vo.receipt.ReceiptSettlementDTO">
|
||||
SELECT
|
||||
user_id AS userId,
|
||||
SUM(money) AS money
|
||||
a.user_id AS userId,
|
||||
SUM( a.money ) AS money,
|
||||
SUM( CASE WHEN b.is_channel = 1 THEN a.money ELSE 0 END ) AS channelAmount
|
||||
FROM
|
||||
bpm_oa_receipt
|
||||
bpm_oa_receipt a
|
||||
INNER JOIN bpm_oa_contract c on a.contract_id = c.id
|
||||
INNER JOIN crm_business b on b.id = c.business_id
|
||||
WHERE
|
||||
deleted = 0
|
||||
AND result = 2
|
||||
<if test="vo.createTime != null and vo.createTime.length > 0">
|
||||
<if test="vo.createTime[0] != null">
|
||||
and create_time >= #{vo.createTime[0]}
|
||||
deleted = 0
|
||||
AND result = 2
|
||||
<if test="vo.createTime != null and vo.createTime.length > 0">
|
||||
<if test="vo.createTime[0] != null">
|
||||
and create_time >= #{vo.createTime[0]}
|
||||
</if>
|
||||
<if test="vo.createTime[1] != null">
|
||||
and create_time <= #{vo.createTime[1]}
|
||||
</if>
|
||||
</if>
|
||||
<if test="vo.createTime[1] != null">
|
||||
and create_time <= #{vo.createTime[1]}
|
||||
</if>
|
||||
</if>
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user