bms改造;
This commit is contained in:
+111
-2
@@ -3,16 +3,21 @@ package com.mhd.wms.application.service.materialInventory;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
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.domain.BatchDetailFeignPO;
|
||||
import com.mhd.system.api.domain.BusinessDocumentFeign;
|
||||
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
|
||||
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper;
|
||||
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO;
|
||||
@@ -32,9 +37,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -49,8 +57,10 @@ import java.util.stream.Collectors;
|
||||
public class MaterialInventoryApplicationService {
|
||||
@Autowired
|
||||
private MaterialInventoryDomainService materialInventoryDomainService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Resource
|
||||
private BmsServiceFeign bmsServiceFeign;
|
||||
@Autowired
|
||||
private MaterialInventoryMapper materialInventoryMapper;
|
||||
@Autowired
|
||||
@@ -59,6 +69,8 @@ public class MaterialInventoryApplicationService {
|
||||
private IStockOutOrderService stockOutOrderService;
|
||||
@Autowired
|
||||
private OutMaterialDetailMapper outMaterialDetailMapper;
|
||||
@Autowired
|
||||
private MaterialBaseInfoMapper materialBaseInfoMapper;
|
||||
|
||||
|
||||
/**
|
||||
@@ -873,4 +885,101 @@ public class MaterialInventoryApplicationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pushBillingRecord(String shipperId) {
|
||||
//非首次推送
|
||||
List<MaterialInventoryPO> materialInventoryPOS = materialInventoryDomainService.queryPushBms(shipperId);
|
||||
if (materialInventoryPOS==null || materialInventoryPOS.size()==0) return;
|
||||
for (MaterialInventoryPO materialInventoryPO : materialInventoryPOS) {
|
||||
Date createTime = materialInventoryPO.getCreateTime();
|
||||
Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId();
|
||||
String lotNumber = materialInventoryPO.getLotNumber();
|
||||
String inOrderNumber = materialInventoryPO.getInOrderNumber();
|
||||
List<Map<String, Object>> monthFee = materialInventoryDomainService.getMonthFee(inOrderNumber, materialBaseInfoId,lotNumber);
|
||||
if (monthFee == null || monthFee.size()==0) return;
|
||||
Map<String, Object> feeMap = monthFee.get(0);
|
||||
//半月仓租
|
||||
BigDecimal halfMonthWhFee = (BigDecimal) feeMap.get("halfMonthWhFee");
|
||||
//整月仓租
|
||||
BigDecimal monthlyWarehouseFee = (BigDecimal) feeMap.get("monthlyWarehouseFee");
|
||||
// 判断是否为昨天
|
||||
boolean isYesterday = false;
|
||||
if (createTime != null) {
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
LocalDate createDate = createTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
isYesterday = yesterday.isEqual(createDate);
|
||||
}
|
||||
if (isYesterday) {
|
||||
//首次计费 需要夫力费
|
||||
//库存数量
|
||||
BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
||||
//仓租
|
||||
BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee);
|
||||
//夫力费
|
||||
BigDecimal manpowerFee = totalWarehouseRent.multiply(new BigDecimal("0.2"));
|
||||
MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId);
|
||||
BigDecimal unitPrice = materialBaseInfo.getUnitPrice();
|
||||
//火险保费
|
||||
BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003"));
|
||||
|
||||
|
||||
} else {
|
||||
//期间付费 不需要夫力费
|
||||
//库存数量
|
||||
BigDecimal inventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
||||
//仓租
|
||||
BigDecimal totalWarehouseRent = inventoryQuantity.multiply(monthlyWarehouseFee);
|
||||
MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId);
|
||||
BigDecimal unitPrice = materialBaseInfo.getUnitPrice();
|
||||
//火险保费
|
||||
BigDecimal fireInsureFee = unitPrice.multiply(inventoryQuantity).multiply(new BigDecimal("0.0003"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void buildBusinessDocument(BigDecimal fee, MaterialInventoryPO materialInventoryPO) {
|
||||
Long shipperId = materialInventoryPO.getShipperId();
|
||||
Map<String, Object> shipper = materialInventoryMapper.querySetlleByShipperId(shipperId);
|
||||
if (shipper == null) {
|
||||
return;
|
||||
}
|
||||
Long settlementCustomersId = (Long) shipper.get("settlementCustomersId");
|
||||
Long settlementEntityId = (Long) shipper.get("settlementEntityId");
|
||||
String settlementEntity = (String) shipper.get("settlementEntity");
|
||||
String settlementCustomersCode = (String) shipper.get("settlementCustomersCode");
|
||||
BusinessDocumentFeign businessDocumentFeign = new BusinessDocumentFeign();
|
||||
businessDocumentFeign.setBillAmount(fee);
|
||||
businessDocumentFeign.setOrganizationId(materialInventoryPO.getOrganizationId());
|
||||
businessDocumentFeign.setOrganizationName(materialInventoryPO.getOrganizationName());
|
||||
businessDocumentFeign.setTopOrganizationId(materialInventoryPO.getTopOrganizationId());
|
||||
businessDocumentFeign.setBelongModuleCode("wms");
|
||||
businessDocumentFeign.setBelongModule("WMS");
|
||||
businessDocumentFeign.setDataSources(1);
|
||||
businessDocumentFeign.setSettlementEntity(settlementEntity);
|
||||
businessDocumentFeign.setSettlementCustomersId(settlementCustomersId);
|
||||
businessDocumentFeign.setSettlementCustomersCode(settlementCustomersCode);
|
||||
businessDocumentFeign.setDocumentTypeId(5l);
|
||||
businessDocumentFeign.setDocumentTypeCode("CM_SZ");
|
||||
businessDocumentFeign.setDocumentType("仓码散租");
|
||||
businessDocumentFeign.setFirstSubjectCode("0D81");
|
||||
businessDocumentFeign.setFirstSubjectName("仓租费");
|
||||
businessDocumentFeign.setBillingTime(new Date());
|
||||
businessDocumentFeign.setServiceItemsCode("CMCZ");
|
||||
businessDocumentFeign.setServiceItemsName("干仓仓租");
|
||||
businessDocumentFeign.setSettlementWay(1);
|
||||
Map<String, Object> contract = materialInventoryDomainService.queryContract(materialInventoryPO.getShipperId());
|
||||
if (contract == null) {return;}
|
||||
String contractName = (String) contract.get("contractName");
|
||||
String contractNumber = (String) contract.get("contractNumber");
|
||||
Long contractManageId = (Long) contract.get("contractManageId");
|
||||
businessDocumentFeign.setContractName(contractName);
|
||||
businessDocumentFeign.setContractNumber(contractNumber);
|
||||
businessDocumentFeign.setContractManageId(contractManageId);
|
||||
AjaxResult ajaxResult = bmsServiceFeign.feignSaveBusinessDocument(businessDocumentFeign);
|
||||
if (ajaxResult == null || !"200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
log.error("保存业务单据失败: {}", ajaxResult != null ? ajaxResult.get("msg") : "feign调用异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -14,6 +14,7 @@ import com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物料库存Service接口
|
||||
@@ -120,4 +121,14 @@ public interface IMaterialInventoryService extends IService<MaterialInventory>
|
||||
public void xgkc(MaterialInventoryParamDO materialInventoryParamDO);
|
||||
|
||||
public void kctzjl(MaterialInventoryParamDO materialInventoryParamDO,String adjustAction,LoginUser loginUser);
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBmsFirst(String shipperId);
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBms(String shipperId);
|
||||
|
||||
public List<Map<String,Object>> getMonthFee(String shipperId, Long materialBaseInfoId,String lotNumber);
|
||||
|
||||
public Map<String,Object> querySetlleByShipperId(Long ShipperId);
|
||||
|
||||
public Map<String,Object> queryContract(Long shipperId);
|
||||
}
|
||||
+12
@@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物料库存Mapper接口
|
||||
@@ -124,4 +125,15 @@ public interface MaterialInventoryMapper extends BaseMapper<MaterialInventory>
|
||||
MaterialInventoryPO selectByIdWithBatchAttributes(@Param("materialInventoryId") Long materialInventoryId);
|
||||
|
||||
public void insertReservationInventoryAdjustmentRecord(com.mhd.wms.domain.inventoryAdjustmentRecord.entity.InventoryAdjustmentRecord inventoryAdjustmentRecord);
|
||||
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBmsFirst(@Param("shipperId") String shipperId);
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBms(@Param("shipperId") String shipperId);
|
||||
|
||||
public List<Map<String,Object>> getMonthFee(@Param("inOrderNumber") String inOrderNumber,@Param("materialBaseInfoId") Long materialBaseInfoId,@Param("lotNumber") String lotNumber);
|
||||
|
||||
public Map<String,Object> querySetlleByShipperId(@Param("shipperId") Long shipperId);
|
||||
|
||||
public Map<String,Object> queryContract(@Param("shipperId") Long shipperId);
|
||||
}
|
||||
+21
@@ -37,6 +37,7 @@ import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
|
||||
import com.mhd.wms.domain.shelfMaterialDetail.entity.ShelfMaterialDetail;
|
||||
import com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO;
|
||||
import com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -1235,4 +1236,24 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
materialInventoryMapper.updateById(materialInventory);
|
||||
}
|
||||
}
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBmsFirst(String shipperId) {
|
||||
return materialInventoryMapper.queryPushBmsFirst(shipperId);
|
||||
}
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBms(String shipperId) {
|
||||
return materialInventoryMapper.queryPushBms(shipperId);
|
||||
}
|
||||
|
||||
public List<Map<String,Object>> getMonthFee(String shipperId ,Long materialBaseInfoId,String lotNumber) {
|
||||
return materialInventoryMapper.getMonthFee(shipperId, materialBaseInfoId,lotNumber);
|
||||
}
|
||||
|
||||
public Map<String,Object> querySetlleByShipperId(Long shipperId) {
|
||||
return materialInventoryMapper.querySetlleByShipperId(shipperId);
|
||||
}
|
||||
|
||||
public Map<String,Object> queryContract(Long shipperId) {
|
||||
return materialInventoryMapper.queryContract(shipperId);
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物料库存
|
||||
@@ -120,4 +121,24 @@ public class MaterialInventoryDomainService {
|
||||
public MaterialInventoryPO selectOneByWhere(MaterialInventoryDO materialInventoryDO) {
|
||||
return materialInventoryService.selectOneByWhere(materialInventoryDO);
|
||||
}
|
||||
}
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBmsFirst(String shipperId) {
|
||||
return materialInventoryService.queryPushBmsFirst(shipperId);
|
||||
}
|
||||
|
||||
public List<MaterialInventoryPO> queryPushBms(String shipperId) {
|
||||
return materialInventoryService.queryPushBms(shipperId);
|
||||
}
|
||||
|
||||
public List<Map<String,Object>> getMonthFee(String shipperId,Long materialBaseInfoId,String lotNumber) {
|
||||
return materialInventoryService.getMonthFee(shipperId,materialBaseInfoId,lotNumber);
|
||||
}
|
||||
|
||||
public Map<String,Object> querySetlleByShipperId(Long shipperId) {
|
||||
return materialInventoryService.querySetlleByShipperId(shipperId);
|
||||
}
|
||||
|
||||
public Map<String,Object> queryContract(Long shipperId) {
|
||||
return materialInventoryService.queryContract(shipperId);
|
||||
}
|
||||
}
|
||||
+21
@@ -19,6 +19,8 @@ import com.mhd.wms.interfaces.assember.materialInventory.MaterialInventoryAssemb
|
||||
import com.mhd.wms.interfaces.dto.materialInventory.MaterialInventoryDTO;
|
||||
import com.mhd.wms.interfaces.dto.materialInventory.MaterialInventoryQueryListDTO;
|
||||
import com.mhd.wms.util.TongyuOrgUtil;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -262,4 +264,23 @@ public class MaterialInventoryApi extends BaseController {
|
||||
return AjaxResult.success(materialInventoryApplicationService.sumInventoryQuantity(materialInventoryDO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 简单任务示例(Bean模式)
|
||||
* 这里的 demoJobHandler 必须和调度中心配置一致
|
||||
*/
|
||||
@XxlJob("pushBillingRecord")
|
||||
public void pushBillingRecord() {
|
||||
// 获取任务参数(货主id)
|
||||
String shipperId = XxlJobHelper.getJobParam();
|
||||
logger.info("XXL-JOB 开始入库业务单推送bms计费流水,货主id参数:{}", shipperId);
|
||||
try {
|
||||
materialInventoryApplicationService.pushBillingRecord(shipperId);
|
||||
// 设置任务执行结果
|
||||
XxlJobHelper.handleSuccess("入库业务单推送bms计费流水执行成功");
|
||||
} catch (Exception e) {
|
||||
logger.error("XXL-JOB 执行失败", e);
|
||||
XxlJobHelper.handleFail("入库业务单推送bms计费流水执行失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user