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
@@ -49,4 +49,10 @@ public interface BmsServiceFeign {
*/
@GetMapping("/documentTypeApi/getDocumentInfoByCodeSet")
AjaxResult getDocumentInfoByCodeSet(@RequestParam("documentTypeCodeSet") Set<String> documentTypeCodeSet);
/**
* 定时任务整租推送到bms
*/
@PostMapping("/businessDocumentApi/wholeRentSynchronization")
public AjaxResult businessDocumentApiSave(@RequestBody BusinessDataPushDTO businessDataPushDTO);
}
@@ -331,7 +331,16 @@ public interface SystemServiceFeign {
@GetMapping("/contractManageApi/getInfoByCustomer")
public AjaxResult getInfoByCustomer(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType);
/**
* 根据结算主体获取合同信息
*/
@GetMapping("/contractManageApi/getInfoByCustomer2")
public AjaxResult getInfoByCustomer2(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("topOrganizationId") Long topOrganizationId);
@GetMapping("/contractManageApi/queryList")
public AjaxResult queryList();
@GetMapping("/LeaseApi/wholeRentSynchronization")
public AjaxResult wholeRentSynchronization();
}
@@ -0,0 +1,65 @@
package com.mhd.system.api.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.handler.ListTypeHandler;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @author ZhouGY
* @title MaterialBaseDO
* @description: TODO
* @date 2024/7/5 10:59
**/
@EqualsAndHashCode(callSuper = true)
@Data
public class MaterialBasePO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("货主id")
@Excel(name = "货主id")
private Long shipperId;
@ApiModelProperty("货主编码")
@Excel(name = "货主编码")
private String shipperCode;
@ApiModelProperty("货主名称")
@Excel(name = "货主名称")
private String shipperName;
@ApiModelProperty("物料编码")
@Excel(name = "物料编码")
private String materialCode;
@ApiModelProperty("物料名称")
@Excel(name = "物料名称")
private String materialName;
@ApiModelProperty("物料条形码")
@Excel(name = "物料条形码")
private String barCode;
@ApiModelProperty("物料分类编码")
@Excel(name = "物料分类编码")
@TableField(typeHandler = ListTypeHandler.class)
private List<String> materialClassifyCode;
@ApiModelProperty("物料分类名称")
@Excel(name = "物料分类名称")
@TableField(typeHandler = ListTypeHandler.class)
private List<String> materialClassifyName;
@ApiModelProperty("物料种类编码 数据字典")
@Excel(name = "物料种类编码 数据字典")
private String materialType;
@ApiModelProperty("物料种类名称 数据字典")
@Excel(name = "物料种类名称 数据字典")
private String materialTypeName;
}
@@ -0,0 +1,217 @@
package com.mhd.system.api.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 物料库存对象 material_inventory
*
* @author gen
* @date 2024-05-29
*/
@Data
@ApiModel(value = "物料库存对象", description = "物料库存响应对象")
public class MaterialInventoryPO extends MaterialBasePO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("物料库存id")
private Long materialInventoryId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("物料基础信息id")
@Excel(name = "物料基础信息id")
private Long materialBaseInfoId;
@ApiModelProperty("上架单物料明细id")
@Excel(name = "上架单物料明细id")
private Long materialDetailId;
@ApiModelProperty("仓库id")
@Excel(name = "仓库id")
private Long warehouseId;
@ApiModelProperty("仓库编码")
@Excel(name = "仓库编码")
private String warehouseCode;
@ApiModelProperty("仓库名称")
@Excel(name = "仓库名称")
private String warehouseName;
@ApiModelProperty("库区id")
@Excel(name = "库区id")
private Long storageSectionId;
@ApiModelProperty("库区编码")
@Excel(name = "库区编码")
private String storageCode;
@ApiModelProperty("库区名称")
@Excel(name = "库区名称")
private String storageName;
@ApiModelProperty("库位id")
@Excel(name = "库位id")
private Long storageLocationId;
@ApiModelProperty("库位编码")
@Excel(name = "库位编码")
private String storageLocationCode;
@ApiModelProperty("库位名称")
@Excel(name = "库位名称")
private String storageLocationName;
@ApiModelProperty("批次号")
@Excel(name = "批次号")
private String batchNumber;
@ApiModelProperty("物料状态编码")
@Excel(name = "物料状态编码")
private String materialStatusCode;
@ApiModelProperty("物料状态名称")
@Excel(name = "物料状态名称")
private String materialStatusName;
@ApiModelProperty("容器id")
@Excel(name = "容器id")
private Long containerId;
@ApiModelProperty("容器编码")
@Excel(name = "容器编码")
private String containerCode;
@ApiModelProperty("容器类型 数据字典")
@Excel(name = "容器类型 数据字典")
private String containerType;
@ApiModelProperty("容器类型名称 数据字典")
@Excel(name = "容器类型名称 数据字典")
private String containerTypeName;
@ApiModelProperty("库存数量")
@Excel(name = "库存数量")
private BigDecimal inventoryQuantity;
@ApiModelProperty("可用数量")
@Excel(name = "可用数量")
private BigDecimal allocationQuantity;
@ApiModelProperty("冻结数量")
@Excel(name = "冻结数量")
private BigDecimal freezeQuantity;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty("盘点是否可用:0-禁用 1-可用")
@Excel(name = "盘点是否可用:0-禁用 1-可用")
private Integer isAble;
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unit;
@ApiModelProperty("净重(KG)")
@Excel(name = "净重(KG)")
private BigDecimal netWeight;
@ApiModelProperty("毛重(KG)")
@Excel(name = "毛重(KG)")
private BigDecimal grossWeight;
@ApiModelProperty("体积")
@Excel(name = "体积")
private BigDecimal volume;
@ApiModelProperty("面积")
@Excel(name = "面积")
private BigDecimal area;
@ApiModelProperty("Batch Ref NO's")
@Excel(name = "Batch Ref NO's")
private String batchRefNo;
@ApiModelProperty("Sheet Ref NO's")
@Excel(name = "Sheet Ref NO's")
private String sheetRefNo;
@ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号")
private String boxPalletNo;
@ApiModelProperty("扩展字段1")
@Excel(name = "扩展字段1")
private String extAttr1;
@ApiModelProperty("扩展字段2")
@Excel(name = "扩展字段2")
private String extAttr2;
@ApiModelProperty("生产日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "生产日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date productionDate;
@ApiModelProperty("过期日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "过期日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date expiryDate;
@ApiModelProperty("存货日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "存货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date inventoryDate;
@ApiModelProperty("ExtAttr3")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "ExtAttr3", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date extAttr3;
@ApiModelProperty("ExtAttr4")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "ExtAttr4", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date extAttr4;
@ApiModelProperty("物料更多属性列表(批次属性)")
private List<MaterialMoreDetailPO> materialMoreDetailList;
@ApiModelProperty("包装名")
@Excel(name = "包装名")
private String packName;
@ApiModelProperty("单位名")
@Excel(name = "单位名")
private String unitName;
}
@@ -0,0 +1,79 @@
package com.mhd.system.api.domain;
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;
/**
* 物料更多属性明细对象 material_more_detail
*
* @author gen
* @date 2024-05-21
*/
@Data
@ApiModel(value = "物料更多属性明细对象", description = "物料更多属性明细响应对象")
public class MaterialMoreDetailPO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("物料更多属性明细id")
private Long materialMoreDetailId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("来源单号")
@Excel(name = "来源单号")
private String orderNumber;
@ApiModelProperty("订单物料明细业务唯一id")
@Excel(name = "订单物料明细业务唯一id")
private Long materialDetailUniqueId;
@ApiModelProperty("批次id")
@Excel(name = "批次id")
private Long batchId;
@ApiModelProperty("批次详情id")
@Excel(name = "批次详情id")
private Long batchDetailId;
@ApiModelProperty("批次标签")
@Excel(name = "批次标签")
private String batchLabels;
@ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl;
@ApiModelProperty("属性格式:1-下拉框 2-日期 3-日期时间 4-数字 5-文本")
@Excel(name = "属性格式:1-下拉框 2-日期 3-日期时间 4-数字 5-文本")
private String attributeFormat;
@ApiModelProperty("属性选项")
@Excel(name = "属性选项")
private String attributeOption;
@ApiModelProperty("属性值")
@Excel(name = "属性值")
private String attributeValue;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
}
@@ -51,6 +51,11 @@ public class RemoteBmsFeignFallbackFactory implements FallbackFactory<BmsService
public AjaxResult getDocumentInfoByCodeSet(Set<String> documentTypeCodeSet) {
return AjaxResult.error(throwable.getMessage());
}
@Override
public AjaxResult businessDocumentApiSave(BusinessDataPushDTO businessDataPushDTO) {
return AjaxResult.error(throwable.getMessage());
}
};
}
}
@@ -264,10 +264,20 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
return AjaxResult.error("查询失败");
}
@Override
public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) {
return AjaxResult.error("查询失败");
}
@Override
public AjaxResult queryList() {
return AjaxResult.error("查询失败");
}
@Override
public AjaxResult wholeRentSynchronization() {
return AjaxResult.error("查询失败");
}
};
}
}
@@ -21,6 +21,12 @@ public class BusinessDataPushDTO{
@ApiModelProperty("组织表ID")
private Long organizationId;
@ApiModelProperty("一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
private String organizationName;
@ApiModelProperty("来源模块code")
@NotBlank(message = "来源模块不能为空")
private String belongModuleCode;
@@ -62,4 +68,7 @@ public class BusinessDataPushDTO{
@ApiModelProperty("结算主体id")
@NotNull(message = "结算主体不能为空")
private Long settlementEntityId;
@ApiModelProperty("费用类型code(服务项)")
private String serviceItemsCode;
}
@@ -10,11 +10,14 @@ import com.mhd.common.core.enums.MessageTypeEnum;
import com.mhd.common.core.service.jPush.AsyncJPushApplicationService;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.redis.service.RedisService;
import com.mhd.job.domain.SysJob;
import com.mhd.job.service.ISysJobService;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.WlhyServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.quartz.SchedulerException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -44,6 +47,26 @@ public class AppLocationTask {
@Resource
private SystemServiceFeign systemServiceFeign;
@Autowired
private ISysJobService jobService;
/**
* 整租同步bms调用
*/
public void getBms(){
systemServiceFeign.wholeRentSynchronization();
log.info("租赁同步bms调定任务调用完成");
SysJob sysJob = new SysJob();
sysJob.setInvokeTarget("appLocationTask.getBms");
List<SysJob> sysJobs = jobService.selectJobList(sysJob);
try {
jobService.deleteJob(sysJobs.get(0));
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
}
public void getUserException(){
// log.info("app离线司机任务开始调用,时间{}", DateUtil.date());
//所有在运输的司机
@@ -2,9 +2,9 @@ package com.mhd.basic.application.service.Lease;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.basic.application.service.storageSection.StorageSectionApplicationService;
import com.mhd.basic.domain.lease.entity.Lease;
@@ -21,12 +21,16 @@ import com.mhd.basic.domain.storageSection.repository.po.StorageSectionPO;
import com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.basic.interfaces.dto.shipperLeaseDetailsApi.ShipperLeaseDetailsDTO;
import com.mhd.common.core.domain.dto.BusinessDataPushDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.BmsServiceFeign;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.domain.MaterialInventoryPO;
import com.mhd.system.api.domain.WarehouseFeignPO;
import com.mhd.system.api.model.LoginUser;
import com.mhd.system.service.ISysDictTypeService;
@@ -71,6 +75,12 @@ public class LeaseApplicationService {
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private BmsServiceFeign bmsServiceFeign;
@Autowired
private WmsServiceFeign WmsServiceFeign;
/**
* 分页查询租赁管理列表
*/
@@ -419,6 +429,88 @@ public class LeaseApplicationService {
return warehouseOccupancyRatesList;
}
/**
* 定时任务整租推送到bms
*/
public void wholeRentSynchronization() {
log.info("定时任务整租推送到bms触发--开始");
LeaseDO leaseDO = new LeaseDO();
leaseDO.setTime(new Date());
leaseDO.setLeaseType("整租");
List<LeasePO> leasePOList = queryList(leaseDO);
log.info("整租数据{}",JSONObject.toJSONString(leasePOList));
for (LeasePO leasePO: leasePOList) {
if (leasePO.getShipperId() == null) {
continue;
}
log.info("开始执行{}",JSONObject.toJSONString(leasePOList));
BusinessDataPushDTO businessDataPushDTO = new BusinessDataPushDTO();
businessDataPushDTO.setOrganizationId(leasePO.getOrganizationId());
businessDataPushDTO.setTopOrganizationId(leasePO.getTopOrganizationId());
businessDataPushDTO.setOrganizationName(leasePO.getOrganizationName());
businessDataPushDTO.setBelongModuleCode("wms");
// businessDataPushDTO.setBillAmount();//计费金额
JSONObject jsonObject = new JSONObject();
jsonObject.put("lease_area",leasePO.getLeaseArea());//租赁面积
jsonObject.put("jiecun_cbm",0);//结存体积
businessDataPushDTO.setDocumentFormJson(jsonObject.toJSONString());
businessDataPushDTO.setDocumentTypeCode("ckzld");
businessDataPushDTO.setSettlementEntityId(leasePO.getShipperId());
businessDataPushDTO.setSecondSubjectCode("26WMS01");
businessDataPushDTO.setServiceItemsCode("26WMS费用");
bmsServiceFeign.businessDocumentApiSave(businessDataPushDTO);
}
log.info("定时任务整租推送到bms触发--结束");
}
/**
* 定时任务散租推送到bms
*/
@Scheduled(cron = "0 0 0 * * ?")
public void ScatteredRentalSynchronization() {
LeaseDO leaseDO = new LeaseDO();
leaseDO.setTime(new Date());
leaseDO.setLeaseType("散租");
List<LeasePO> leasePOList = queryList(leaseDO);
for (LeasePO leasePO: leasePOList) {
if (leasePO.getShipperId() == null) {
continue;
}
MaterialInventoryDTO materialInventoryDTO = new MaterialInventoryDTO();
materialInventoryDTO.setShipperId(leasePO.getShipperId());
BigDecimal totalVolume = BigDecimal.ZERO;
AjaxResult ajaxResult = WmsServiceFeign.materialInventoryApiListAll(materialInventoryDTO);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<MaterialInventoryPO> batchDetailFeignPOList = JSON.parseArray(
com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), MaterialInventoryPO.class);
if (batchDetailFeignPOList != null && batchDetailFeignPOList.size() > 0) {
continue;//没有货跳过
}
totalVolume = batchDetailFeignPOList.stream()
.map(MaterialInventoryPO::getVolume)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
BusinessDataPushDTO businessDataPushDTO = new BusinessDataPushDTO();
businessDataPushDTO.setOrganizationId(leasePO.getOrganizationId());
businessDataPushDTO.setTopOrganizationId(leasePO.getTopOrganizationId());
businessDataPushDTO.setOrganizationName(leasePO.getOrganizationName());
businessDataPushDTO.setBelongModuleCode("wms");
// businessDataPushDTO.setBillAmount();//计费金额
JSONObject jsonObject = new JSONObject();
jsonObject.put("lease_area",0);//租赁面积
jsonObject.put("jiecun_cbm",totalVolume);//结存体积
businessDataPushDTO.setDocumentFormJson(jsonObject.toJSONString());
businessDataPushDTO.setDocumentTypeCode("ckzld");
businessDataPushDTO.setSettlementEntityId(leasePO.getShipperId());
businessDataPushDTO.setSecondSubjectCode("26WMS01");
businessDataPushDTO.setServiceItemsCode("26WMS费用");
bmsServiceFeign.businessDocumentApiSave(businessDataPushDTO);
}
}
// /**
// * @description 设置数据字典键值
// * @author ZhouGY
@@ -37,6 +37,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.*;
import java.util.stream.Collectors;
@@ -351,14 +352,14 @@ public class ContractManageApplicationService {
* @param settlementCustomersCode 结算主体code
* @param contractType 合同类型
*/
public ContractManagePO getInfoByCustomer(String settlementCustomersCode,Integer contractType) {
public ContractManagePO getInfoByCustomer(String settlementCustomersCode,Integer contractType, Long topOrganizationId) {
/*
首先根据合同类型(仓储、运输),以及结算客户,查询合同信息
如果传了结算主体,则根据结算主体以及当前时间查询有效的特殊合同,如果特殊合同没有,则查询通用合同
*/
//获取当前登录人信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
if (ObjectUtil.isNull(loginUser) && topOrganizationId == null) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(contractType==null){
@@ -368,7 +369,11 @@ public class ContractManageApplicationService {
//查询当前日期在有效期内的合同
ContractManageDO queryParam = new ContractManageDO();
queryParam.setNowDateString(DateUtil.format(new Date(),"yyyy-MM-dd"));
queryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
if (!ObjectUtil.isNull(loginUser)) {
queryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}else {
queryParam.setTopOrganizationId(topOrganizationId);
}
List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam);
if(contractManagePOList != null && contractManagePOList.size()>0){
if(StringUtils.isNotEmpty(settlementCustomersCode)){
@@ -81,7 +81,9 @@ public class ExpenseAccountDomainService {
public ExpenseAccountPO getInfoByCode(String subjectCode) {
ExpenseAccountDO expenseAccountDO = new ExpenseAccountDO();
expenseAccountDO.setSubjectCode(subjectCode);
expenseAccountDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
if (SecurityUtils.getLoginUser() != null) {
expenseAccountDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}
return expenseAccountService.getInfoByCode(expenseAccountDO);
}
public List<QueryExpenseAccountPO> selectExpenseAccount(SearchExpenseAccountDO searchExpenseAccountDO){
@@ -109,7 +109,14 @@ public class ContractManageApi extends BaseController{
@GetMapping(value = "/getInfoByCustomer")
public AjaxResult getInfoByCustomer(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType)
{
return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType));
return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType,null));
}
@ApiOperation("根据结算主体获取合同信息")
@GetMapping(value = "/getInfoByCustomer2")
public AjaxResult getInfoByCustomer2(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("topOrganizationId") Long topOrganizationId)
{
return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType,topOrganizationId));
}
@ApiOperation("根据合同编码获取合同管理")
@@ -108,5 +108,15 @@ public class LeaseApi extends BaseController{
return toAjax(leaseApplicationService.nullifyByIds(leaseIds));
}
/**
* 批量作废租赁
*/
@ApiOperation("整租同步到bms计费单据")
@GetMapping("/wholeRentSynchronization")
public AjaxResult wholeRentSynchronization()
{
leaseApplicationService.wholeRentSynchronization();
return AjaxResult.success();
}
}
@@ -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());
}
}
/**
* 批量删除业务单据
*/