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
@@ -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();
}
}