正式合同定时任务;

This commit is contained in:
王奎兴
2026-09-04 15:40:19 +08:00
parent c25a9a5f68
commit 5a329904c3
11 changed files with 187 additions and 26 deletions
@@ -72,4 +72,10 @@ public interface BmsServiceFeign {
@PostMapping("/businessDocumentApi/feignSave")
public AjaxResult feignSaveBusinessDocument(@RequestBody BusinessDocumentFeign businessDocumentFeign);
/**
* 根据结算对象id查询结算对象参数列表
*/
@GetMapping("/settlementCustomersParametersApi/getListBySettlementCustomersId")
AjaxResult getListBySettlementCustomersId(@RequestParam("settlementCustomersId") Long settlementCustomersId);
}
@@ -72,6 +72,11 @@ public class RemoteBmsFeignFallbackFactory implements FallbackFactory<BmsService
public AjaxResult feignSaveBusinessDocument(BusinessDocumentFeign businessDocumentFeign) {
return AjaxResult.error("保存业务单据失败");
}
@Override
public AjaxResult getListBySettlementCustomersId(Long settlementCustomersId) {
return AjaxResult.error(throwable.getMessage());
}
};
}
}
@@ -0,0 +1,58 @@
package com.mhd.common.core.domain.po;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "结算对象参数对象", description = "结算对象参数响应对象")
public class SettlementCustomersParametersPO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("结算对象编码")
@Excel(name = "结算对象编码")
private String settlementCustomersCode;
@ApiModelProperty("结算主体id")
@Excel(name = "结算主体id")
private Long settlementEntityId;
@ApiModelProperty("结算主体")
@Excel(name = "结算主体")
private String settlementEntity;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同管理id")
private Long contractManageId;
@ApiModelProperty("参数内容")
@Excel(name = "参数内容")
private String content;
@ApiModelProperty("参数名称")
@Excel(name = "参数名称")
private String parametersName;
}
@@ -1302,6 +1302,23 @@ public class ContractManageApplicationService {
}
}
/*
* 根据结算对象id获取结算对象参数列表
* */
public List<SettlementCustomersParametersPO> getSettlementCustomersParameters(Long settlementCustomersId) {
try {
AjaxResult ajaxResult = bmsServiceFeign.getListBySettlementCustomersId(settlementCustomersId);
if (ajaxResult == null || !"200".equals(String.valueOf(ajaxResult.get("code"))) || ajaxResult.get("data") == null) {
log.warn("按 settlementCustomersId 查询结算对象参数未成功:settlementCustomersId={}, code={}", settlementCustomersId, ajaxResult != null ? ajaxResult.get("code") : null);
return null;
}
return JSON.parseArray(JSON.toJSONString(ajaxResult.get("data")), SettlementCustomersParametersPO.class);
} catch (Exception e) {
log.warn("按 settlementCustomersId 查询结算对象参数异常,settlementCustomersId={}", settlementCustomersId, e);
return null;
}
}
public void pushContractManageToBms(String shipperId) {
SettlementCustomersPO settlementCustomers = getSettlementCustomers(Long.valueOf(shipperId));
if (settlementCustomers == null) {
@@ -1309,31 +1326,65 @@ public class ContractManageApplicationService {
return;
}
Long settlementCustomersId = settlementCustomers.getSettlementCustomersId();
List<ContractManage> contractManages = contractManageMapper.selectList(new LambdaQueryWrapper<ContractManage>()
.eq(ContractManage::getContractRentType, "NORMAL")
.eq(ContractManage::getContractState, 2)
.eq(ContractManage::getDelFlag, 1)
.eq(ContractManage::getSettlementCustomersId, settlementCustomers.getSettlementCustomersId()));
if (contractManages == null || contractManages.isEmpty()) {
log.warn("未找到正式合同");
List<SettlementCustomersParametersPO> parametersList = getSettlementCustomersParameters(settlementCustomersId);
if (parametersList == null || parametersList.isEmpty()) {
log.warn("pushContractManageToBms 未找到结算对象参数,settlementCustomersId={}", settlementCustomersId);
return;
}
for (ContractManage contractManage : contractManages) {
Long contractManageId = contractManage.getContractManageId();
ContractManageParameters contractManageParameters = contractManageParametersService.getOne(new LambdaQueryWrapper<ContractManageParameters>()
.eq(ContractManageParameters::getContractManageId, contractManageId),false);
if (contractManageParameters == null) {
for (SettlementCustomersParametersPO param : parametersList) {
String parametersName = param.getParametersName();
String content = param.getContent();
if (StringUtils.isEmpty(content)) {
log.warn("结算对象参数 content 为空,parametersName={}, settlementCustomersId={}", parametersName, settlementCustomersId);
continue;
}
String parametersJson = contractManageParameters.getParametersJson();
Map<String, Object> parametersMap = JSON.parseObject(parametersJson, new TypeReference<Map<String, Object>>() {});
//合约价
BigDecimal hyj = (BigDecimal) parametersMap.get("hyj");
buildBusinessDocument(hyj,settlementCustomers,contractManage,"","","");
Map<String, Object> contentMap = JSON.parseObject(content, new TypeReference<Map<String, Object>>() {});
Integer sfzdcz = Integer.valueOf(contentMap.get("sfzdcz").toString());
if (sfzdcz != 1) {
log.info("结算对象参数 sfzdcz 不为1,跳过推送,parametersName={}, sfzdcz={}", parametersName, sfzdcz);
continue;
}
String warehouseTempLayerType;
String serviceItemsName;
if ("冻仓计费配置".equals(parametersName)) {
warehouseTempLayerType = "DC";
serviceItemsName = "冻仓仓租费用";
} else if ("干仓计费配置".equals(parametersName)) {
warehouseTempLayerType = "GC";
serviceItemsName = "干仓仓租费用";
} else {
log.warn("未知的结算对象参数类型,parametersName={}", parametersName);
continue;
}
List<ContractManage> contractManages = contractManageMapper.selectList(new LambdaQueryWrapper<ContractManage>()
.eq(ContractManage::getContractRentType, "NORMAL")
.eq(ContractManage::getContractState, 2)
.eq(ContractManage::getDelFlag, 1)
.eq(ContractManage::getSettlementCustomersId, settlementCustomersId)
.eq(ContractManage::getWarehouseTempLayerType, warehouseTempLayerType));
if (contractManages == null || contractManages.isEmpty()) {
log.warn("未找到正式合同,warehouseTempLayerType={}, settlementCustomersId={}", warehouseTempLayerType, settlementCustomersId);
continue;
}
for (ContractManage contractManage : contractManages) {
Long contractManageId = contractManage.getContractManageId();
ContractManageParameters contractManageParameters = contractManageParametersService.getOne(new LambdaQueryWrapper<ContractManageParameters>()
.eq(ContractManageParameters::getContractManageId, contractManageId), false);
if (contractManageParameters == null) {
continue;
}
String parametersJson = contractManageParameters.getParametersJson();
Map<String, Object> parametersMap = JSON.parseObject(parametersJson, new TypeReference<Map<String, Object>>() {});
BigDecimal hyj = (BigDecimal) parametersMap.get("hyj");
buildBusinessDocument(hyj, settlementCustomers, contractManage, "0D081", "干仓仓租费用", warehouseTempLayerType, serviceItemsName);
}
}
}
private void buildBusinessDocument(BigDecimal fee, SettlementCustomersPO settlementCustomers,ContractManage contractManage, String code, String name, String warehouseType) {
private void buildBusinessDocument(BigDecimal fee, SettlementCustomersPO settlementCustomers, ContractManage contractManage, String code, String name, String warehouseType, String serviceItemsName) {
Long settlementCustomersId = settlementCustomers.getSettlementCustomersId();
Long settlementEntityId = settlementCustomers.getSettlementEntityId();
@@ -1357,7 +1408,7 @@ public class ContractManageApplicationService {
businessDocumentFeign.setFirstSubjectName(name);
businessDocumentFeign.setBillingTime(new Date());
businessDocumentFeign.setServiceItemsCode("GC_CZ");
businessDocumentFeign.setServiceItemsName("干仓仓租费用");
businessDocumentFeign.setServiceItemsName(serviceItemsName);
businessDocumentFeign.setSettlementWay(1);
businessDocumentFeign.setOriginalBusinessNum(contractManage.getContractNumber());
businessDocumentFeign.setWarehouseType(warehouseType);
@@ -242,7 +242,5 @@ public class ContractManageDomainService {
return contractManagePO;
}
public Map<String,Object> getSettlementCustomers(String shipperId) {
}
}
@@ -263,6 +263,7 @@ public class ContractManageApi extends BaseController{
String shipperId = XxlJobHelper.getJobParam();
logger.info("XXL-JOB 开始入库业务单推送bms计费流水,货主id参数:{}", shipperId);
try {
contractManageApplicationService.pushContractManageToBms(shipperId);
// 设置任务执行结果
XxlJobHelper.handleSuccess("入库业务单推送bms计费流水执行成功");
} catch (Exception e) {
@@ -84,4 +84,11 @@ public class SettlementCustomersParametersApplicationService {
Long[] ids = idSet.stream().map(Long::valueOf).toArray(Long[]::new);
return settlementCustomersParametersDomainService.delete(ids);
}
}
/**
* 根据结算对象id查询结算对象参数列表
*/
public List<SettlementCustomersParametersPO> getListBySettlementCustomersId(Long settlementCustomersId) {
return settlementCustomersParametersDomainService.getListBySettlementCustomersId(settlementCustomersId);
}
}
@@ -39,4 +39,9 @@ public interface ISettlementCustomersParametersService extends IService<Settleme
* 查询结算对象参数
*/
public SettlementCustomersParametersPO getInfo(Long id);
}
/**
* 根据结算对象id查询结算对象参数列表
*/
public List<SettlementCustomersParametersPO> getListBySettlementCustomersId(Long settlementCustomersId);
}
@@ -1,5 +1,6 @@
package com.mhd.bms.domain.settlementCustomersParameters.repository.persistence;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.settlementCustomersParameters.entity.SettlementCustomersParameters;
import com.mhd.bms.domain.settlementCustomersParameters.repository.facade.ISettlementCustomersParametersService;
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 结算对象参数Service业务层处理
@@ -78,4 +80,16 @@ public class SettlementCustomersParametersImpl extends ServiceImpl<SettlementCus
BeanUtils.copyProperties(settlementCustomersParameters, settlementCustomersParametersPO);
return settlementCustomersParametersPO;
}
}
@Override
public List<SettlementCustomersParametersPO> getListBySettlementCustomersId(Long settlementCustomersId) {
List<SettlementCustomersParameters> list = this.list(new LambdaQueryWrapper<SettlementCustomersParameters>()
.eq(SettlementCustomersParameters::getSettlementCustomersId, settlementCustomersId)
.eq(SettlementCustomersParameters::getDelFlag, 1));
return list.stream().map(item -> {
SettlementCustomersParametersPO po = new SettlementCustomersParametersPO();
BeanUtils.copyProperties(item, po);
return po;
}).collect(Collectors.toList());
}
}
@@ -56,4 +56,11 @@ public class SettlementCustomersParametersDomainService {
public SettlementCustomersParametersPO getInfo(Long id) {
return settlementCustomersParametersService.getInfo(id);
}
}
/**
* 根据结算对象id查询结算对象参数列表
*/
public List<SettlementCustomersParametersPO> getListBySettlementCustomersId(Long settlementCustomersId) {
return settlementCustomersParametersService.getListBySettlementCustomersId(settlementCustomersId);
}
}
@@ -89,4 +89,13 @@ public class SettlementCustomersParametersApi extends BaseController {
public AjaxResult getInfoById(SettlementCustomersParametersDTO settlementCustomersParametersDTO) {
return AjaxResult.success(settlementCustomersParametersApplicationService.getInfo(settlementCustomersParametersDTO.getId()));
}
}
/**
* 根据结算对象id查询结算对象参数列表
*/
@ApiOperation("根据结算对象id查询结算对象参数列表")
@GetMapping(value = "/getListBySettlementCustomersId")
public AjaxResult getListBySettlementCustomersId(@RequestParam("settlementCustomersId") Long settlementCustomersId) {
return AjaxResult.success(settlementCustomersParametersApplicationService.getListBySettlementCustomersId(settlementCustomersId));
}
}