定时任务每小时执行一次会计凭证关联原始凭证(附件、审批流程)
parent
4b7407b8a1
commit
5faeaf334e
@ -0,0 +1,61 @@
|
||||
package cn.iocoder.yudao.module.accounting.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.bankslip.BankSlipDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.flow.FlowDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.attachment.AttachmentMapper;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.bankslip.BankSlipMapper;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.flow.FlowMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@TenantJob // 多租户
|
||||
@Slf4j
|
||||
public class injoinJob implements JobHandler {
|
||||
|
||||
@Resource
|
||||
private BankSlipMapper bankSlipMapper;
|
||||
@Resource
|
||||
private FlowMapper flowMapper;
|
||||
@Resource
|
||||
private AttachmentMapper attachmentMapper;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
//银行回单流程号OA/ERP流程编号得到凭证id
|
||||
List<BankSlipDO> BankSlipDOList = bankSlipMapper.selectList(new QueryWrapperX<BankSlipDO>()
|
||||
.isNotNull("flow_code"));
|
||||
for (BankSlipDO bankSlip:BankSlipDOList
|
||||
) {
|
||||
//每个回单的流程号 获取后查找绑定附件、审批流程
|
||||
Long voucherId = bankSlip.getVoucherId();
|
||||
String flowCode = bankSlip.getFlowCode();
|
||||
//通过flowCode查找附件、审批流程
|
||||
List<FlowDO> flowDOList = flowMapper.selectList(new QueryWrapperX<FlowDO>()
|
||||
.eq("flow_code", flowCode));
|
||||
for (FlowDO flowDO:flowDOList
|
||||
) {
|
||||
flowDO.setVoucherId(voucherId);
|
||||
flowMapper.updateById(flowDO);
|
||||
}
|
||||
List<AttachmentDO> attachmentDOList = attachmentMapper.selectList(new QueryWrapperX<AttachmentDO>()
|
||||
.eq("flow_code", flowCode));
|
||||
for (AttachmentDO attachmentDO:attachmentDOList
|
||||
) {
|
||||
attachmentDO.setVoucherId(voucherId);
|
||||
attachmentMapper.updateById(attachmentDO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return "injoinJob 执行了";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue