WMS:
根据采购订单和销售订单绑定关系修改原材料出库接口逻辑
master
xins 6 months ago
parent 25cb4da81d
commit 23e4502cbe

@ -82,6 +82,7 @@ public class WmsScadaController extends BaseController {
/**此方法暂时不用*/
@Log(title = "原材料出库记录", businessType = BusinessType.AUDIT)
@PostMapping(("/applyAgvRawOutstock"))
public AjaxResult applyAgvRawOutstock(@Validated @RequestBody WmsAgvRawOutstockVo wmsAgvRawOutstockVo) {

@ -2,6 +2,7 @@ package com.hw.wms.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -14,30 +15,41 @@ import com.hw.common.core.web.domain.BaseEntity;
* @author xins
* @date 2024-03-14
*/
public class WmsStockTotal extends BaseEntity
{
public class WmsStockTotal extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 总库存ID */
/**
* ID
*/
private Long stockTotalId;
/** 仓库ID */
/**
* ID
*/
@Excel(name = "仓库ID")
private Long warehouseId;
/** 仓库名称 */
/**
*
*/
@Excel(name = "仓库名称")
private String warehouseName;
/** 仓库楼层 */
/**
*
*/
@Excel(name = "仓库楼层")
private Long warehouseFloor;
/** 库存类型1原材料2半成品3成品 */
/**
* 123
*/
@Excel(name = "库存类型1原材料2半成品3成品")
private String stockType;
/** 物料ID */
/**
* ID
*/
@Excel(name = "物料ID")
private Long materialId;
@ -46,37 +58,53 @@ public class WmsStockTotal extends BaseEntity
private String safeFlag;
/** 物料编号 */
/**
*
*/
@Excel(name = "物料编号")
private String materialCode;
/** 物料名称 */
/**
*
*/
@Excel(name = "物料名称")
private String materialName;
/** 总数量;仓库存放的总数量 */
/**
* ;
*/
@Excel(name = "总数量;仓库存放的总数量")
private BigDecimal totalAmount;
/** 冻结数量;手动冻结的,暂时可不用 */
/**
* ;
*/
@Excel(name = "冻结数量;手动冻结的,暂时可不用")
private BigDecimal frozenAmount;
/** 占用数量;申请时占用的数量,在出库时要减去出库数量,并且总数量要同步更新; */
/**
* ;;
*/
@Excel(name = "占用数量;申请时占用的数量,在出库时要减去出库数量,并且总数量要同步更新;")
private BigDecimal occupyAmount;
/** 创建时间 */
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
/** 最后更新时间 */
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date updateDate;
/** 有效标记 */
/**
*
*/
@Excel(name = "有效标记")
private String activeFlag;
@ -89,49 +117,43 @@ public class WmsStockTotal extends BaseEntity
this.warehouseName = warehouseName;
}
public void setStockTotalId(Long stockTotalId)
{
public void setStockTotalId(Long stockTotalId) {
this.stockTotalId = stockTotalId;
}
public Long getStockTotalId()
{
public Long getStockTotalId() {
return stockTotalId;
}
public void setWarehouseId(Long warehouseId)
{
public void setWarehouseId(Long warehouseId) {
this.warehouseId = warehouseId;
}
public Long getWarehouseId()
{
public Long getWarehouseId() {
return warehouseId;
}
public void setWarehouseFloor(Long warehouseFloor)
{
public void setWarehouseFloor(Long warehouseFloor) {
this.warehouseFloor = warehouseFloor;
}
public Long getWarehouseFloor()
{
public Long getWarehouseFloor() {
return warehouseFloor;
}
public void setStockType(String stockType)
{
public void setStockType(String stockType) {
this.stockType = stockType;
}
public String getStockType()
{
public String getStockType() {
return stockType;
}
public void setMaterialId(Long materialId)
{
public void setMaterialId(Long materialId) {
this.materialId = materialId;
}
public Long getMaterialId()
{
public Long getMaterialId() {
return materialId;
}
@ -151,58 +173,52 @@ public class WmsStockTotal extends BaseEntity
this.safeFlag = safeFlag;
}
public void setTotalAmount(BigDecimal totalAmount)
{
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
public BigDecimal getTotalAmount()
{
return totalAmount;
public BigDecimal getTotalAmount() {
return totalAmount == null || totalAmount.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : totalAmount;
}
public void setFrozenAmount(BigDecimal frozenAmount)
{
public void setFrozenAmount(BigDecimal frozenAmount) {
this.frozenAmount = frozenAmount;
}
public BigDecimal getFrozenAmount()
{
return frozenAmount;
public BigDecimal getFrozenAmount() {
return frozenAmount == null || frozenAmount.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : frozenAmount;
}
public void setOccupyAmount(BigDecimal occupyAmount)
{
public void setOccupyAmount(BigDecimal occupyAmount) {
this.occupyAmount = occupyAmount;
}
public BigDecimal getOccupyAmount()
{
return occupyAmount;
public BigDecimal getOccupyAmount() {
return occupyAmount == null || occupyAmount.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : occupyAmount;
}
public void setCreateDate(Date createDate)
{
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getCreateDate()
{
public Date getCreateDate() {
return createDate;
}
public void setUpdateDate(Date updateDate)
{
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Date getUpdateDate()
{
public Date getUpdateDate() {
return updateDate;
}
public void setActiveFlag(String activeFlag)
{
public void setActiveFlag(String activeFlag) {
this.activeFlag = activeFlag;
}
public String getActiveFlag()
{
public String getActiveFlag() {
return activeFlag;
}

@ -114,7 +114,7 @@ public interface WmsRawOutstockMapper
/**
* ,join material
* ,join material,warehouse
*
* @param wmsRawOutstock
* @return

@ -240,7 +240,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
BigDecimal planAmount = wmsRawOutstock.getOutstockAmount();
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(instockBatch);
if (wmsRawStock != null) {
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ?
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ||
wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ?
BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
if (occupyAmount.compareTo(planAmount) >= 0) {
wmsRawStock.setOccupyAmount(occupyAmount.subtract(planAmount));
@ -306,13 +307,19 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
}
String batchCode = baseBarcodeInfo.getBatchCode();
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (baseLocation == null) {
throw new ServiceException("库位码有误");
}
//todo后续判断outrequirement
//判断是否有此出库任务,人工出库的同一个出库记录同一个库位、同一个物料对应一个明细agv的有可能是多个
WmsRawOutstock wmsRawOutstock;
if (rawOutstockId != null) {
wmsRawOutstock = wmsRawOutstockMapper.selectWmsRawOutstockByRawOutstockId(rawOutstockId);
} else {
WmsRawOutstock queryRawOutstock = new WmsRawOutstock();
queryRawOutstock.setLocationCode(locationCode);
queryRawOutstock.setInstockBatch(batchCode);
queryRawOutstock.setWarehouseId(baseLocation.getWarehouseId());
queryRawOutstock.setMaterialId(baseBarcodeInfo.getMaterialId());
queryRawOutstock.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
queryRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
queryRawOutstock.setRawOutstockId(rawOutstockId);
@ -326,7 +333,9 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
throw new ServiceException("请选择具体出库任务后点击确认");
}
WmsRawOutstock wmsRawOutstock = wmsRawOutstocks.get(0);
wmsRawOutstock = wmsRawOutstocks.get(0);
}
WmsRawOutstockDetail queryRawOutstockDetail = new WmsRawOutstockDetail();
queryRawOutstockDetail.setRawOutstockId(wmsRawOutstock.getRawOutstockId());
@ -369,20 +378,22 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstock.setUpdateBy(userName);
wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock);
insertRawOutstockDetail(wmsRawOutstock, materialBarcode, batchCode, userName, currentDate);
insertRawOutstockDetail(wmsRawOutstock, locationCode, materialBarcode, baseBarcodeInfo.getBatchCode(), userName, currentDate);
updateRawStock(locationCode, batchCode, outstockAmount, userName, currentDate);
updateRawStock(materialBarcode, outstockAmount, userName, currentDate);
//trigger中更新stocktotal的占用数量和库存数量
return 1;
}
public void insertRawOutstockDetail(WmsRawOutstock wmsRawOutstock, String materialBarcode, String batchCode,
public void insertRawOutstockDetail(WmsRawOutstock wmsRawOutstock, String locationCode, String materialBarcode, String batchCode,
String userName, Date currentDate) {
WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail();
wmsRawOutstockDetail.setRawOutstockId(wmsRawOutstock.getRawOutstockId());
wmsRawOutstockDetail.setTaskCode(wmsRawOutstock.getTaskCode());
wmsRawOutstockDetail.setWarehouseId(wmsRawOutstock.getWarehouseId());
wmsRawOutstockDetail.setLocationCode(wmsRawOutstock.getLocationCode());
wmsRawOutstockDetail.setLocationCode(locationCode);
wmsRawOutstockDetail.setMaterialId(wmsRawOutstock.getMaterialId());
wmsRawOutstockDetail.setMaterialBarcode(materialBarcode);
wmsRawOutstockDetail.setInstockBatch(batchCode);
@ -398,15 +409,14 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
public void updateRawStock(String locationCode, String batchCode, BigDecimal outstockAmount, String userName, Date currentDate) {
public void updateRawStock(String materialBarcode, BigDecimal outstockAmount, String userName, Date currentDate) {
//更新原材料库存占用数量和总数量
//todo 批次码
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(batchCode);
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode);
if (wmsRawStock == null) {
throw new ServiceException("没找到库存信息");
} else {
BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount();
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null || wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal updatedOccupyAmount = occupyAmount.subtract(outstockAmount);
BigDecimal updatedTotalAmount = totalAmount.subtract(outstockAmount);
updatedOccupyAmount = updatedOccupyAmount.compareTo(BigDecimal.ZERO) >= 0 ? updatedOccupyAmount : BigDecimal.ZERO;
@ -508,8 +518,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
Long stockTotalId = rawOutstockDetail.getStockTotalId();
WmsStockTotal wmsStockTotal = wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(stockTotalId);
BigDecimal totalAmount = wmsStockTotal.getTotalAmount();
BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();
BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();
BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null || wmsStockTotal.getFrozenAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();
BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null || wmsStockTotal.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
BigDecimal planAmount = rawOutstockDetail.getPlanAmount() == null ?
@ -692,8 +702,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
String moveMaterialBarcode = "";
Long moveMaterialId = null;
for (WmsRawStock wmsRawStock : rawStockList) {
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal frozenAmount = wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount();
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null || wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal frozenAmount = wmsRawStock.getFrozenAmount() == null || wmsRawStock.getFrozenAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount();
WmsBaseLocation wmsBaseLocation = baseLocationsMap.get(wmsRawStock.getLocationCode());
//先确认出库库位,可用数量>=1库位状态是正常的
@ -1042,8 +1052,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
queryRawStock.setWarehouseId(wmsConfig.getFourthFloorPalteWarehouseId());
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStockList(queryRawStock);
List<WmsRawStock> availableRawStocks = wmsRawStocks.stream().filter(wmsRawStock ->
(wmsRawStock.getTotalAmount().subtract(wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount())
.subtract(wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount())).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
(wmsRawStock.getTotalAmount().subtract(wmsRawStock.getOccupyAmount() == null || wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount())
.subtract(wmsRawStock.getFrozenAmount() == null || wmsRawStock.getFrozenAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount())).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
if (availableRawStocks != null && !availableRawStocks.isEmpty()) {
List<String> returnMsg = availableRawStocks.stream().map(WmsRawStock::getLocationAndMaterial).collect(Collectors.toList());
return returnMsg.toString();
@ -1058,8 +1068,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
querySafeRawStock.setWarehouseId(wmsConfig.getFourthFloorPalteWarehouseId());
List<WmsRawStock> safeRawStocks = wmsRawStockMapper.selectWmsRawStockList(querySafeRawStock);
List<WmsRawStock> availableSafeRawStocks = safeRawStocks.stream().filter(wmsRawStock ->
(wmsRawStock.getTotalAmount().subtract(wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount())
.subtract(wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount())).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
(wmsRawStock.getTotalAmount().subtract(wmsRawStock.getOccupyAmount() == null || wmsRawStock.getOccupyAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount())
.subtract(wmsRawStock.getFrozenAmount() == null || wmsRawStock.getFrozenAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount())).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
if (availableSafeRawStocks != null && !availableSafeRawStocks.isEmpty()) {
List<String> returnMsg = availableSafeRawStocks.stream().map(WmsRawStock::getLocationAndMaterial).collect(Collectors.toList());
return returnMsg.toString();
@ -1108,7 +1118,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstock.setApplyDate(currentDate);
wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock);
this.insertRawOutstockDetail(wmsRawOutstock, materialBarcode, batchCode,
this.insertRawOutstockDetail(wmsRawOutstock, locationCode,materialBarcode, batchCode,
userName, currentDate);
directOutstockUpdateRawStock(locationCode, materialBarcode, outstockAmount, userName, currentDate);

@ -281,13 +281,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select wro.raw_outstock_id as raw_outstock_detail_id, wro.task_code,wro.location_code,wro.material_batch as instock_batch,wro.outstock_amount as plan_amount,wro.real_outstock_amount as outstock_amount,
wro.apply_by,wro.apply_date,wro.apply_reason,wro.audit_by,wro.audit_date,wro.audit_reason,wro.plan_code,wro.plan_detail_code,wro.audit_status,wro.task_type,
wro.execute_status,wro.erp_status,wro.erp_amount,
mbmi.material_code,mbmi.material_name
mbmi.material_code,mbmi.material_name,
mbr.warehouse_name
from wms_raw_outstock wro left join mes_base_material_info mbmi on wro.material_id = mbmi.material_id
left join wms_base_warehouse mbr on wro.warehouse_id = mbr.warehouse_id
<where>
<if test="taskCode != null and taskCode != ''"> and wro.task_code = #{taskCode}</if>
<if test="auditStatus != null and auditStatus != ''"> and wro.audit_status = #{auditStatus}</if>
<if test="applyBy != null and applyBy != ''"> and wro.apply_by like concat('%', #{applyBy}, '%')</if>
</where>
order by wro.raw_outstock_id desc
</select>
<insert id="batchWmsRawOutstock">

@ -142,6 +142,7 @@
from wms_stock_total wst left join mes_base_material_info mbmi on wst.material_id = mbmi.material_id
<where>
and wst.total_amount>0
<if test="warehouseId != null ">and wst.warehouse_id = #{warehouseId}</if>
<if test="warehouseFloor != null ">and wst.warehouse_floor = #{warehouseFloor}</if>
<if test="stockType != null and stockType != ''">and wst.stock_type = #{stockType}</if>

Loading…
Cancel
Save