定时任务方法;

This commit is contained in:
王奎兴
2026-09-10 17:29:09 +08:00
parent 432f71de06
commit cf3299165d
7 changed files with 237 additions and 25 deletions
@@ -292,6 +292,28 @@ public class BillManageApplicationService {
return billManageDomainService.confirmBilling(billManageDO);
}
@Transactional
public Boolean confirmBillingJob(BillManageDTO billManageDTO) {
//确认账单:未收款状态之前都可以进行确认账单,跳过核账流程,直接到未收款状态
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
throw new ServiceException("账单管理ids不能为空");
}
//校验
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
BillManageDO billManageDO = new BillManageDO();
billManageDO.setBillManageIdSet(billManageIds);
List<BillManagePO> billManageList = billManageDomainService.queryList(billManageDO);
for (BillManagePO billManage : billManageList) {
if(billManage.getBillState() > 2){
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不可操作确认账单");
}
}
billManageDO.setOrganizationId(billManageDTO.getOrganizationId());
billManageDO.setOrganizationName(billManageDTO.getOrganizationName());
billManageDO.setTopOrganizationId(billManageDTO.getTopOrganizationId());
return billManageDomainService.confirmBillingJob(billManageDO);
}
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
{
@@ -894,7 +894,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -930,7 +930,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1003,7 +1003,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1039,7 +1039,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1127,7 +1127,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1163,7 +1163,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1258,7 +1258,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1294,7 +1294,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1367,7 +1367,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1403,7 +1403,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1491,7 +1491,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1527,7 +1527,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1618,7 +1618,10 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
params.setOrganizationId(organizationId);
params.setTopOrganizationId(topOrganizationId);
params.setOrganizationName(organizationName);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1626,7 +1629,9 @@ public class BillingStatementApplicationService {
.eq(BillDetail::getDelFlag, 1));
BmsInvoiceListAddDTO tmsInvoiceListAddDTO = new BmsInvoiceListAddDTO();
tmsInvoiceListAddDTO.setBillManageId(billManageId);
tmsInvoiceListAddDTO.setOrganizationId(organizationId);
tmsInvoiceListAddDTO.setTopOrganizationId(topOrganizationId);
tmsInvoiceListAddDTO.setOrganizationName(organizationName);
if (ObjectUtil.isNotNull(billManage)) {
tmsInvoiceListAddDTO.setSettlementCurrency(billManage.getSettlementCurrency());
tmsInvoiceListAddDTO.setBillAmount(billManage.getBillAmount());
@@ -1654,7 +1659,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1727,7 +1732,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1763,7 +1768,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1851,7 +1856,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -1887,7 +1892,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -1982,7 +1987,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -2018,7 +2023,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -2091,7 +2096,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -2127,7 +2132,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -2215,7 +2220,7 @@ public class BillingStatementApplicationService {
//确认账单
BillManageDTO params = new BillManageDTO();
params.setBillManageIds(String.valueOf(billManageId));
billManageApplicationService.confirmBilling(params);
billManageApplicationService.confirmBillingJob(params);
//申请发票
BillManage billManage = billManageService.getById(billManageId);
List<BillDetail> billDetails = billDetailService.list(new LambdaQueryWrapper<BillDetail>()
@@ -2251,7 +2256,7 @@ public class BillingStatementApplicationService {
bmsMakeOutInvoices.add(bmsMakeOutInvoice);
tmsInvoiceListAddDTO.setBmsMakeOutInvoices(bmsMakeOutInvoices);
bmsInvoiceListService.addReceivableBill(tmsInvoiceListAddDTO);
bmsInvoiceListService.addReceivableBillJob(tmsInvoiceListAddDTO);
}
}
}
@@ -557,6 +557,32 @@ public class BillManageDomainService {
return flag && three;
}
public Boolean confirmBillingJob(BillManageDO billManageDO) {
//直接修改状态到未收款3状态
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
// }
LambdaUpdateWrapper<BillManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillManage::getBillManageId,billManageDO.getBillManageIdSet())
.set(BillManage::getBillStep,4)
.set(BillManage::getBillState,3)
// .set(BillManage::getUpdateBy,loginUser.getUserPo().getUserId())
// .set(BillManage::getUpdateByName,loginUser.getUserPo().getUserName())
.set(BillManage::getUpdateTime,new Date());
boolean flag = billManageService.update(updateWrapper);
//保存账单操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageIdSet(billManageDO.getBillManageIdSet());
billOperationLogDO.setOperationInfo(BillLogsConstants.confirm_bill_text);
billOperationLogDO.setOperationType(3);
billOperationLogDO.setOrganizationId(billManageDO.getOrganizationId());
billOperationLogDO.setOrganizationName(billManageDO.getOrganizationName());
billOperationLogDO.setTopOrganizationId(billManageDO.getTopOrganizationId());
boolean three = billOperationLogDomainService.saveBillOperationLogBatchJob(billOperationLogDO);
return flag && three;
}
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
{
@@ -139,6 +139,40 @@ public class BillOperationLogDomainService {
return billOperationLogService.saveBatch(saveList);
}
public Boolean saveBillOperationLogBatchJob(BillOperationLogDO billOperationLogDO) {
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
// }
if(billOperationLogDO.getBillManageIdSet()==null || billOperationLogDO.getBillManageIdSet().size()==0){
throw new ServiceException("账单集合不能为空");
}
// String userName = loginUser.getUserPo().getUserName();
// // 获取登录人id
// Long userId = loginUser.getUserid();
BillOperationLogDO common = new BillOperationLogDO();
// common.setCreateByName(userName);
// common.setUpdateByName(userName);
common.setCreateTime(new Date());
common.setUpdateTime(new Date());
common.setDelFlag(1);
// common.setCreateBy(userId);
// common.setUpdateBy(userId);
// common.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
// common.setOrganizationId(loginUser.getUserPo().getOrganizationId());
// common.setOrganizationName(loginUser.getUserPo().getOrganizationName());
common.setOperationType(billOperationLogDO.getOperationType());
common.setOperationInfo(billOperationLogDO.getOperationInfo());
List<BillOperationLog> saveList = new ArrayList<>();
for (String billManageId : billOperationLogDO.getBillManageIdSet()) {
BillOperationLog save = new BillOperationLog();
BeanUtils.copyProperties(common, save);
save.setBillManageId(Long.valueOf(billManageId));
saveList.add(save);
}
return billOperationLogService.saveBatch(saveList);
}
/**
* 批量保存数据
@@ -26,6 +26,8 @@ public interface IBmsInvoiceListService extends IService<BmsInvoiceList> {
void addReceivableBill(BmsInvoiceListAddDTO tmsInvoiceListAddDTO);
void addReceivableBillJob(BmsInvoiceListAddDTO tmsInvoiceListAddDTO);
void update(BmsInvoiceListDTO tmsInvoiceListDTO);
int delete(List<String> ids);
@@ -216,6 +216,76 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl<BmsInvoiceListMapper,
}*/
}
@Transactional
@Override
public void addReceivableBillJob(BmsInvoiceListAddDTO bmsInvoiceListAddDTO) {
//获取登录人
// WlhyLoginUser sysUser = SecurityUtils.getLoginUser().getWlhyLoginUser();
// if (null == sysUser) {
// throw new ServiceException("sysUser是空值!");
// }
/*if (StringUtils.isEmpty(bmsInvoiceListAddDTO.getInvoiceTitle())){
throw new ServiceException("发票抬头不能为空!");
}*/
bmsInvoiceListAddDTO.setInvoiceValue(bmsInvoiceListAddDTO.getBillAmount());
BmsInvoiceList bmsInvoiceList = new BmsInvoiceList(); // 销项发票表
BeanUtils.copyProperties(bmsInvoiceListAddDTO, bmsInvoiceList);
// String createBy = sysUser.getId(); // 创建人ID
if(StringUtils.isNotBlank(bmsInvoiceListAddDTO.getCompanyName())){
bmsInvoiceList.setShipperName(bmsInvoiceListAddDTO.getCompanyName());
bmsInvoiceList.setCompanyName(bmsInvoiceListAddDTO.getCompanyName());
}
// 保存销项发票表数据
Long listId = saveBmsInvoiceListJob(bmsInvoiceList, bmsInvoiceListAddDTO, null, null);
//预保存发票明细信息
if(ObjectUtil.isNotNull(listId)){
List<BmsMakeOutInvoice> bmsMakeOutInvoices = bmsInvoiceListAddDTO.getBmsMakeOutInvoices();
if (ObjectUtil.isNotNull(bmsMakeOutInvoices) && bmsMakeOutInvoices.size() > 0) {
for (BmsMakeOutInvoice bmsMakeOutInvoice : bmsMakeOutInvoices) {
bmsMakeOutInvoice.setInvoiceId(listId);
//bmsMakeOutInvoice.setCreateBy(sysUser.getId());
bmsMakeOutInvoice.setCreateTime(new Date());
bmsMakeOutInvoiceMapper.insert(bmsMakeOutInvoice);
for (BmsMakeOutInvoiceItem bmsMakeOutInvoiceItem : bmsMakeOutInvoice.getBmsMakeOutInvoiceItems()) {
bmsMakeOutInvoiceItem.setMakeId(bmsMakeOutInvoice.getId());
//bmsMakeOutInvoiceItem.setCreateBy(sysUser.getId());
bmsMakeOutInvoiceItem.setCreateTime(new Date());
bmsMakeOutInvoiceItemMapper.insert(bmsMakeOutInvoiceItem);
}
}
}
}
// BillManage billManage = billManageMapper.selectById(bmsInvoiceListAddDTO.getBillManageId());
// if (billManage != null) {
// billManage.setIsInvoice(1);
// billManage.setInvoiceId(bmsInvoiceList.getId().toString());
// billManage.setApplyNumber(bmsInvoiceList.getApplyNumber());
// billManageMapper.updateById(billManage);
// }
List<Long> billManageIds = bmsInvoiceListAddDTO.getBillManageIds();
if (billManageIds != null && billManageIds.size() > 0){
} else {
billManageIds = new ArrayList<>();
billManageIds.add(bmsInvoiceListAddDTO.getBillManageId());
}
List<BillManage> billManages = billManageMapper.selectList(new LambdaQueryWrapper<BillManage>().in(BillManage::getBillManageId, billManageIds));
if (billManages != null && billManages.size() > 0) {
for (BillManage billManage : billManages) {
billManage.setIsInvoice(1);
billManage.setInvoiceId(bmsInvoiceList.getId().toString());
billManage.setApplyNumber(bmsInvoiceList.getApplyNumber());
billManageMapper.updateById(billManage);
}
}
/*AjaxResult ajaxResult = financeServiceFeign.editIsInvoice(transportationId,1,bmsInvoiceList.getId(),"",bmsInvoiceList.getApplyNumber());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new com.mhd.common.core.exception.ServiceException(ajaxResult.get("msg").toString());
}*/
}
@Override
public BmsSettlementPartyInvoice selectSettlementPartyInfoByName(String settlementPartyName) {
return null;
@@ -932,4 +1002,43 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl<BmsInvoiceListMapper,
}
return null;
}
public Long saveBmsInvoiceListJob(BmsInvoiceList bmsInvoiceList, BmsInvoiceListAddDTO bmsInvoiceListAddDTO, WlhyLoginUser sysUser, String createBy){
bmsInvoiceList.setReceivingAddressId(bmsInvoiceListAddDTO.getReceivingAddressId());
//bmsInvoiceList.setCreateBy(createBy);
bmsInvoiceList.setApplyNumber(OrderSequence.getOrderCode("XF"));
bmsInvoiceList.setCreateTime(new Date());
bmsInvoiceList.setInvoiceApplyTime(new Date());
// bmsInvoiceList.setApplicantId(sysUser.getId());
// bmsInvoiceList.setRealCreateBy(sysUser.getId());
// bmsInvoiceList.setRealCreateName(sysUser.getRealname());
bmsInvoiceList.setCompanyName(bmsInvoiceListAddDTO.getSettlementEntity());
// 设置组织相关字段从当前登录用户获取组织信息
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if (loginUser != null && loginUser.getUserPo() != null) {
// // 设置组织ID
// if (loginUser.getUserPo().getOrganizationId() != null) {
// bmsInvoiceList.setOrganizationId(loginUser.getUserPo().getOrganizationId());
// }
// // 设置组织名称
// if (StringUtils.isNotBlank(loginUser.getUserPo().getOrganizationName())) {
// bmsInvoiceList.setOrganizationName(loginUser.getUserPo().getOrganizationName());
// }
// // 设置一级组织ID
// if (loginUser.getUserPo().getTopOrganizationId() != null) {
// bmsInvoiceList.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
// }
// }
boolean saveSuccess = this.save(bmsInvoiceList);
// 3. 插入成功后直接从实体对象获取ID已被MyBatis-Plus自动赋值
if (saveSuccess) {
Long id = bmsInvoiceList.getId();
System.out.println("插入成功,生成的ID" + id);
return id;
}
return null;
}
}
@@ -79,5 +79,19 @@ public class BmsInvoiceListAddDTO implements Serializable {
@ApiModelProperty(value = "对账单id列表")
@Excel(name = "对账单id列表", width = 15)
private List<Long> billManageIds;
/**组织ID*/
@ApiModelProperty(value = "组织ID")
@Excel(name = "组织ID", width = 15)
private Long organizationId;
/**组织名称*/
@ApiModelProperty(value = "组织名称")
@Excel(name = "组织名称", width = 15)
private String organizationName;
/**一级组织ID*/
@ApiModelProperty(value = "一级组织ID")
@Excel(name = "一级组织ID", width = 15)
private Long topOrganizationId;
}