Merge branch 'main' of http://47.97.8.94:19527/yj/zn-cloud
This commit is contained in:
commit
2f98be54d7
@ -41,7 +41,7 @@ public class BpmOAImprestController {
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得出差申请")
|
||||
@Operation(summary = "获得备用金申请")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<BpmOAImprestRespVO> getImprest(@RequestParam("id") Long id) {
|
||||
|
||||
@ -49,4 +49,15 @@ public class BpmOAImprestController {
|
||||
|
||||
return success(BpmOAImprestConvert.INSTANCE.convert(imprest));
|
||||
}
|
||||
|
||||
@GetMapping("/getOne")
|
||||
@Operation(summary = "获得备用金表单")
|
||||
@Parameter(name = "userId", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<BpmOAImprestRespVO> getImprestByUserId(@RequestParam("userId") Long userId) {
|
||||
|
||||
//根据user 查询审批通过并且未报销得表单。
|
||||
BpmOAImprestDO imprest = imprestService.getImprestByUserId(userId);
|
||||
|
||||
return success(BpmOAImprestConvert.INSTANCE.convert(imprest));
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ public class BpmOAImprestRespVO extends BpmOABaseRespVO {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate date;
|
||||
|
||||
@Schema(description = "报销状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "上传文件", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<UploadUserFile> fileItems;
|
||||
}
|
||||
|
@ -27,6 +27,10 @@ public class BpmOAReimbursementCreateReqVO {
|
||||
@NotNull(message = "报销总金额中文大写不能为空")
|
||||
private String totalMoneyChinese ;
|
||||
|
||||
@Schema(description = "备用金差额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@NotNull(message = "备用金差额不能为空")
|
||||
private BigDecimal difference ;
|
||||
|
||||
@Schema(description = "报销发票总数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销发票总数不能为空")
|
||||
private Integer totalQuantity ;
|
||||
|
@ -28,6 +28,10 @@ public class BpmOAReimbursementRespVO extends BpmOABaseRespVO {
|
||||
@NotNull(message = "报销总金额中文大写不能为空")
|
||||
private String totalMoneyChinese ;
|
||||
|
||||
@Schema(description = "备用金差额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@NotNull(message = "备用金差额不能为空")
|
||||
private BigDecimal difference ;
|
||||
|
||||
@Schema(description = "报销发票总数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销发票总数不能为空")
|
||||
private Integer totalQuantity ;
|
||||
|
@ -29,6 +29,13 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class BpmOAImprestDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 是否已报销 0否 1是 2进行中
|
||||
*/
|
||||
public static final Integer FLAG_FALSE = 0;
|
||||
public static final Integer FLAG_TRUE = 1;
|
||||
public static final Integer IN_PROGRESS = 2;
|
||||
|
||||
/**
|
||||
* 出差表单主键
|
||||
*/
|
||||
@ -70,6 +77,14 @@ public class BpmOAImprestDO extends BaseDO {
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 报销与否状态
|
||||
* 0:未报销
|
||||
* 1:已报销
|
||||
* 2:进行中
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 对应的流程编号
|
||||
*
|
||||
|
@ -55,6 +55,11 @@ public class BpmOAReimbursementDO extends BaseDO {
|
||||
*/
|
||||
private String totalMoneyChinese;
|
||||
|
||||
/**
|
||||
* 备用差额
|
||||
*/
|
||||
private BigDecimal difference;
|
||||
|
||||
/**
|
||||
* 报销发票总张数
|
||||
*/
|
||||
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAImprestDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@ -12,4 +14,11 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOAImprestMapper extends BaseMapperX<BpmOAImprestDO> {
|
||||
|
||||
default BpmOAImprestDO selectByUserId(Long userId, Integer status){
|
||||
|
||||
return selectOne(new LambdaQueryWrapperX<BpmOAImprestDO>().eq(BpmOAImprestDO::getUserId, userId)
|
||||
.eq(BpmOAImprestDO::getResult, BpmProcessInstanceResultEnum.PROCESS.getResult())
|
||||
.eq(BpmOAImprestDO::getStatus, status));
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,12 @@ public interface BpmOAImprestService {
|
||||
* @return 备用金申请
|
||||
*/
|
||||
BpmOAImprestDO getImprest(Long id);
|
||||
|
||||
/**
|
||||
* 获得备用金表单
|
||||
*
|
||||
* @param userId 编号
|
||||
* @return 备用金申请
|
||||
*/
|
||||
BpmOAImprestDO getImprestByUserId(Long userId);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAIm
|
||||
|
||||
//插入OA 备用金申请
|
||||
BpmOAImprestDO imprest = BpmOAImprestConvert.INSTANCE.convert(createReqVO).setUserId(userId)
|
||||
.setStatus(BpmOAImprestDO.FLAG_FALSE)
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
imprestMapper.insert(imprest) ;
|
||||
|
||||
@ -83,4 +84,11 @@ public class BpmOAImprestServiceImpl extends BpmOABaseService implements BpmOAIm
|
||||
|
||||
return imprestMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOAImprestDO getImprestByUserId(Long userId) {
|
||||
|
||||
//根据user 查询审批通过并且未报销得表单。
|
||||
return imprestMapper.selectByUserId(userId, BpmOAImprestDO.FLAG_FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,11 @@ public interface BpmOAReimbursementService {
|
||||
/**
|
||||
* 更新报销申请的状态
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @param id 编号
|
||||
* @param result 结果
|
||||
*/
|
||||
void updateReimbursementResult(Long id, Integer result);
|
||||
void updateReimbursementResult(String processInstanceId, Long id, Integer result);
|
||||
|
||||
/**
|
||||
* 获得报销申请
|
||||
|
@ -5,11 +5,16 @@ import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
|
||||
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAReimbursementConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAImprestDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAImprestMapper;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReimbursementMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
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;
|
||||
@ -43,7 +48,14 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
|
||||
@Resource
|
||||
private BpmOAImprestService bpmOAImprestService;
|
||||
|
||||
@Resource
|
||||
private BpmOAImprestMapper bpmOAImprestMapper;
|
||||
|
||||
@Override
|
||||
public Long createReimbursement(Long userId, BpmOAReimbursementCreateReqVO createReqVO) {
|
||||
@ -57,9 +69,15 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(reimbursement.getId()))).getCheckedData();
|
||||
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
// 将工作流的编号,更新到 OA 报销表单中
|
||||
reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(reimbursement.getId()).setProcessInstanceId(processInstanceId));
|
||||
|
||||
//如果是备用金报销,则更新备用金流程status
|
||||
if (createReqVO.getDifference() != null) {
|
||||
BpmOAImprestDO bpmOAImprestDO = bpmOAImprestService.getImprestByUserId(userId);
|
||||
bpmOAImprestMapper.updateById(new BpmOAImprestDO().setId(bpmOAImprestDO.getId()).setStatus(BpmOAImprestDO.IN_PROGRESS));
|
||||
}
|
||||
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
||||
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||
if (fileItems != null && !fileItems.isEmpty()) {
|
||||
@ -69,8 +87,40 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReimbursementResult(Long id, Integer result) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateReimbursementResult(String processInstanceId, Long id, Integer result) {
|
||||
validateLeaveExists(id);
|
||||
|
||||
//审核通过 (最后节点)
|
||||
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
|
||||
|
||||
ProcessInstance instance = bpmProcessInstanceService.getProcessInstance(processInstanceId);
|
||||
BpmOAImprestDO bpmOAImprestDO = bpmOAImprestMapper.selectByUserId(Long.valueOf(instance.getStartUserId()), BpmOAImprestDO.IN_PROGRESS);
|
||||
|
||||
if (instance.isEnded() && bpmOAImprestDO != null) {
|
||||
|
||||
//将相应备用金申请状态改为 已报销
|
||||
bpmOAImprestMapper.updateById(new BpmOAImprestDO().setId(bpmOAImprestDO.getId()).setStatus(BpmOAImprestDO.FLAG_TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
// -- 自己取消
|
||||
// -- 审核拒绝
|
||||
//所有关联的采购申请改为 未支付状态
|
||||
if (BpmProcessInstanceResultEnum.REJECT.getResult().equals(result)
|
||||
|| BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)
|
||||
|| BpmProcessInstanceResultEnum.BACK.getResult().equals(result)) {
|
||||
|
||||
ProcessInstance instance = bpmProcessInstanceService.getProcessInstance(processInstanceId);
|
||||
BpmOAImprestDO bpmOAImprestDO = bpmOAImprestMapper.selectByUserId(Long.valueOf(instance.getStartUserId()), BpmOAImprestDO.IN_PROGRESS);
|
||||
|
||||
if (bpmOAImprestDO != null) {
|
||||
|
||||
//将相应备用金申请状态改为 未报销
|
||||
bpmOAImprestMapper.updateById(new BpmOAImprestDO().setId(bpmOAImprestDO.getId()).setStatus(BpmOAImprestDO.FLAG_FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(id).setResult(result));
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@ 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.BpmOALeaveService;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveServiceImpl;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -28,7 +26,7 @@ public class BpmOAReimbursementResultListener extends BpmProcessInstanceResultEv
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||
reimbursementService.updateReimbursementResult(Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||
reimbursementService.updateReimbursementResult(event.getId(), Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user