wms租赁定时任务推送到bms(未完成 定时任务没有当前登录人 需要改造后面方法)

This commit is contained in:
zhou-hongcheng
2026-02-25 19:56:10 +08:00
parent d4a30d8b40
commit 2a570fbefc
19 changed files with 668 additions and 16 deletions
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.service.BillingParamsDomainService;
@@ -12,6 +13,7 @@ import com.mhd.bms.domain.costCalculation.entity.BillingOutputEntity;
import com.mhd.bms.domain.costCalculation.entity.BillingParamsEntity;
import com.mhd.bms.domain.costCalculation.po.BillingCostPo;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.facade.IDocumentTypeService;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
@@ -77,10 +79,10 @@ public class CostCalculationApplicationService {
3:产生计费任务记录
*/
//获取当前登录人信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
// }
BillingCostPo result = new BillingCostPo();
BeanUtils.copyProperties(costCalculationDTO, result);
TaskFlowRecordsDO taskFlowRecordsDO = new TaskFlowRecordsDO();
@@ -104,7 +106,8 @@ public class CostCalculationApplicationService {
return result;
}
@Autowired
private IDocumentTypeService documentTypeService;
/**
* 校验必填,并获取本次计算合适的计费参数公式
* @param costCalculationDTO 计算参数
@@ -125,7 +128,15 @@ public class CostCalculationApplicationService {
}
//查询单据信息
DocumentType documentType = documentTypeDomainService.queryByCode(costCalculationDTO.getDocumentTypeCode());
LambdaQueryWrapper<DocumentType> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DocumentType::getDocumentTypeCode, costCalculationDTO.getDocumentTypeCode());
if (SecurityUtils.getLoginUser() != null) {
queryWrapper.eq(DocumentType::getTopOrganizationId, SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}else {
queryWrapper.eq(DocumentType::getTopOrganizationId, costCalculationDTO.getTopOrganizationId());
}
queryWrapper.eq(DocumentType::getDelFlag ,1);
DocumentType documentType = documentTypeService.getOne(queryWrapper);
if(documentType == null){
throw new ServiceException("单据类型未找到");
}
@@ -3,8 +3,10 @@ package com.mhd.bms.application.server.businessDocument;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.application.server.billingRules.CostCalculationApplicationService;
import com.mhd.bms.application.server.settlementCustomers.SettlementCustomersApplicationService;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
@@ -13,9 +15,11 @@ import com.mhd.bms.domain.businessDocument.service.BusinessDocumentDomainService
import com.mhd.bms.domain.costCalculation.po.BillingCostPo;
import com.mhd.bms.domain.documentType.entity.DocumentFromEntity;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.facade.IDocumentTypeService;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.infrastructure.feign.vo.ContractManageDetailPO;
@@ -76,6 +80,8 @@ public class BusinessDocumentApplicationService {
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private CostCalculationApplicationService costCalculationApplicationService;
@Autowired
private ISettlementCustomersService settlementCustomersService;
/**
@@ -163,6 +169,8 @@ public class BusinessDocumentApplicationService {
return businessDocumentDomainService.insert(businessDocumentDO);
}
@Autowired
private IDocumentTypeService documentTypeService;
/**
* 校验表单单据类型必填
* @param businessDocumentDO
@@ -171,7 +179,15 @@ public class BusinessDocumentApplicationService {
if(!StringUtils.isNotEmpty(businessDocumentDO.getDocumentTypeCode())){
throw new ServiceException("所选表单不能为空");
}
DocumentType documentType = documentTypeDomainService.queryByCode(businessDocumentDO.getDocumentTypeCode());
LambdaQueryWrapper<DocumentType> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DocumentType::getDocumentTypeCode, businessDocumentDO.getDocumentTypeCode());
if (SecurityUtils.getLoginUser() != null) {
queryWrapper.eq(DocumentType::getTopOrganizationId, SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}else {
queryWrapper.eq(DocumentType::getTopOrganizationId, businessDocumentDO.getTopOrganizationId());
}
queryWrapper.eq(DocumentType::getDelFlag ,1);
DocumentType documentType = documentTypeService.getOne(queryWrapper);
if(null == documentType){
throw new ServiceException("表单类型信息未找到");
}
@@ -221,7 +237,15 @@ public class BusinessDocumentApplicationService {
}
//根据单据类型id查询单据类型数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getDocumentTypeCode())){
DocumentType documentType = documentTypeDomainService.queryByCode(businessDocumentDO.getDocumentTypeCode());
LambdaQueryWrapper<DocumentType> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DocumentType::getDocumentTypeCode, businessDocumentDO.getDocumentTypeCode());
if (SecurityUtils.getLoginUser() != null) {
queryWrapper.eq(DocumentType::getTopOrganizationId, SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}else {
queryWrapper.eq(DocumentType::getTopOrganizationId, businessDocumentDO.getTopOrganizationId());
}
queryWrapper.eq(DocumentType::getDelFlag ,1);
DocumentType documentType = documentTypeService.getOne(queryWrapper);
if(null != documentType){
businessDocumentDO.setDocumentType(documentType.getDocumentType());
businessDocumentDO.setDocumentTypeCode(documentType.getDocumentTypeCode());
@@ -247,7 +271,15 @@ public class BusinessDocumentApplicationService {
//根据结算对象code查询结算对象数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getSettlementCustomersCode())){
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(businessDocumentDO.getSettlementCustomersCode());
LambdaQueryWrapper<SettlementCustomers> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SettlementCustomers::getSettlementCustomersCode, businessDocumentDO.getSettlementCustomersCode());
if (SecurityUtils.getLoginUser() != null) {
queryWrapper.eq(SettlementCustomers::getTopOrganizationId, SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}else {
queryWrapper.eq(SettlementCustomers::getTopOrganizationId, businessDocumentDO.getTopOrganizationId());
}
queryWrapper.eq(SettlementCustomers::getDelFlag, 1);
SettlementCustomers settlementCustomers = settlementCustomersService.getOne(queryWrapper);
if(null == settlementCustomers){
throw new ServiceException("结算对象信息未找到");
}
@@ -305,7 +337,7 @@ public class BusinessDocumentApplicationService {
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1;
}
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomer(businessDocumentDO.getSettlementCustomersCode(),contractType);
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomer2(businessDocumentDO.getSettlementCustomersCode(),contractType,businessDocumentDO.getTopOrganizationId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}
@@ -760,4 +792,44 @@ public class BusinessDocumentApplicationService {
}
return true;
}
@Transactional(rollbackFor = Exception.class)
public Boolean wholeRentSynchronization(BusinessDocumentDO businessDocumentDO) {
log.info("定时任务进入BMS业务单据保存--开始");
//根据结算主题id查询 结算对象编码
Long settlementEntityId = businessDocumentDO.getSettlementEntityId();
List<SettlementCustomers> settlementCustomersList = settlementCustomersService.list(new LambdaQueryWrapper<SettlementCustomers>()
.eq(SettlementCustomers::getSettlementEntityId, settlementEntityId)
.eq(SettlementCustomers::getDelFlag, 1)
);
if (settlementCustomersList != null && settlementCustomersList.size() > 0) {
businessDocumentDO.setSettlementCustomersCode(settlementCustomersList.get(0).getSettlementCustomersCode());
}else {
return false;
}
//校验使用的表单是否必填校验
checkDoucumentType(businessDocumentDO);
//处理数据
handleDate(businessDocumentDO);
businessDocumentDO.setDataSources(2);
businessDocumentDO.setBusinessFlow(OrderSequence.getOrderCode("LS"));
businessDocumentDO.setTopOrganizationId(businessDocumentDO.getTopOrganizationId());
businessDocumentDO.setOrganizationId(businessDocumentDO.getOrganizationId());
businessDocumentDO.setOrganizationName(businessDocumentDO.getOrganizationName());
//调用费用计算,计算费用金额进行保存
CostCalculationDTO costCalculationDTO = new CostCalculationDTO();
costCalculationDTO.setOriginalBusinessNum(businessDocumentDO.getOriginalBusinessNum());
costCalculationDTO.setContractNumber(businessDocumentDO.getContractNumber());
costCalculationDTO.setFormJson(businessDocumentDO.getDocumentFormJson());
costCalculationDTO.setSubjectCode(StringUtils.isEmpty(businessDocumentDO.getSecondSubjectCode()) ? businessDocumentDO.getFirstSubjectCode():businessDocumentDO.getSecondSubjectCode());
costCalculationDTO.setDocumentTypeCode(businessDocumentDO.getDocumentTypeCode());
costCalculationDTO.setTopOrganizationId(businessDocumentDO.getTopOrganizationId());
BillingCostPo billingCostPo = costCalculationApplicationService.costCalculation(costCalculationDTO);
businessDocumentDO.setEstimatedCost(billingCostPo.getComputationalCost());
businessDocumentDO.setBillAmount(billingCostPo.getComputationalCost());//计费金额与计算金额一致
log.info("定时任务进入BMS业务单据保存--结束");
return businessDocumentDomainService.insert(businessDocumentDO);
}
}
@@ -1,5 +1,6 @@
package com.mhd.bms.interfaces.dto.billingRules;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;
@@ -35,6 +36,10 @@ public class CostCalculationDTO{
@NotBlank(message = "计费参数不能为空")
private String formJson;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@@ -8,6 +8,7 @@ import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@@ -196,4 +197,7 @@ public class BusinessDocumentDTO extends BaseVOEntity{
@ApiModelProperty("重算金额")
private BigDecimal recalculateCost;
@ApiModelProperty("结算主体id")
private Long settlementEntityId;
}
@@ -4,6 +4,7 @@ import java.util.List;
import com.mhd.bms.application.server.businessDocument.BusinessDocumentApplicationService;
import com.mhd.common.core.domain.dto.BusinessDataPushDTO;
import com.mhd.common.core.utils.IgnoreNullUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -75,6 +76,26 @@ public class BusinessDocumentApi extends BaseController{
}
/**
* 整租推送
*/
@ApiOperation("整租推送")
@PostMapping("/wholeRentSynchronization")
public AjaxResult wholeRentSynchronization(@RequestBody BusinessDocumentDTO businessDocumentDTO)
{
try {
//转换实体
BusinessDocumentDO businessDocumentDO = new BusinessDocumentDO();
// 拷贝
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(businessDocumentDTO, businessDocumentDO, IgnoreNullUtil.getNullPropertyNames(businessDocumentDTO));
return toAjax(businessDocumentApplicationService.wholeRentSynchronization(businessDocumentDO));
}catch (Exception e){
return AjaxResult.error("保存业务单据失败" +e.getMessage());
}
}
/**
* 批量删除业务单据
*/