diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java index 396dd01..4090ee9 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java @@ -248,5 +248,5 @@ public class WmsConstants { public static final String WMS_RAW_OUTSTOCK_SPLIT_FLAG_YES = "1"; public static final String WMS_SAFE_FLAG_YES = "1";//安全库存,是 - + public static final String WMS_SAFE_FLAG_NO = "0";//安全库存,否 } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java index bbde3d4..d5d474a 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java @@ -68,6 +68,9 @@ public class WmsMobileController extends BaseController { @Autowired private IWmsInventoryCheckService wmsInventoryCheckService; + @Autowired + private IWmsStockTotalService wmsStockTotalService; + @Resource private RemoteMesService remoteMesService; @@ -316,17 +319,17 @@ public class WmsMobileController extends BaseController { /** - * 根据销售订单编号获取成品库存列表 + * 根据销售订单查询成品库存列表Join material,warehouse,saleorder,totalAmount>0,FOR PDA apply */ // @RequiresPermissions("wms:rawoutstock:query") @GetMapping(value = "/getProductStocksBySalesorderCode") - public TableDataInfo getProductStocksBySalesorderCode(WmsProductStock queryProductStock) { + public TableDataInfo getProductStocksBySalesorderCode(WmsStockTotal queryStockTotal) { startPage(); // WmsProductStock queryProductStock = new WmsProductStock(); // queryProductStock.setSaleorderCode(request.getParameter("salesorderCode")); // queryProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); - List list = wmsProductStockService.selectWmsProductStocksBySaleorder(queryProductStock); - return getDataTable(list); + List wmsStockTotals = wmsStockTotalService.selectWmsStockTotalList4ProductApply(queryStockTotal); + return getDataTable(wmsStockTotals); } /** diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsStockTotal.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsStockTotal.java index a329031..3d8e21d 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsStockTotal.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsStockTotal.java @@ -122,6 +122,13 @@ public class WmsStockTotal extends BaseEntity { private String stockTypeStr; + private BigDecimal orderAmount; + + private BigDecimal applyAmount; + + private Long productId; + + public String getWarehouseName() { return warehouseName; } @@ -307,6 +314,30 @@ public class WmsStockTotal extends BaseEntity { this.stockTypeStr = stockTypeStr; } + public BigDecimal getOrderAmount() { + return orderAmount; + } + + public void setOrderAmount(BigDecimal orderAmount) { + this.orderAmount = orderAmount; + } + + public BigDecimal getApplyAmount() { + return applyAmount; + } + + public void setApplyAmount(BigDecimal applyAmount) { + this.applyAmount = applyAmount; + } + + public Long getProductId() { + return productId; + } + + public void setProductId(Long productId) { + this.productId = productId; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsStockTotalMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsStockTotalMapper.java index d3c62f2..a1a10ef 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsStockTotalMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsStockTotalMapper.java @@ -1,6 +1,7 @@ package com.hw.wms.mapper; import java.util.List; + import com.hw.wms.domain.WmsStockTotal; /** @@ -9,8 +10,7 @@ import com.hw.wms.domain.WmsStockTotal; * @author xins * @date 2024-03-14 */ -public interface WmsStockTotalMapper -{ +public interface WmsStockTotalMapper { /** * 查询原材料库存 * @@ -60,10 +60,6 @@ public interface WmsStockTotalMapper public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds); - - - - /** * 查询总库存列表(根据销售订单查询库存,以及根据plancode和plandetailcode申请的数量,包含安全库存) * @@ -88,4 +84,22 @@ public interface WmsStockTotalMapper * @return 原材料库存集合 */ public List selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal); + + + /** + * 查询原材料库存列表,Join warehouse,material,sale_order,for pda成品出库查询使用 + * + * @param wmsStockTotal 原材料库存 + * @return 原材料库存集合 + */ + public List selectWmsStockTotalList4ProductApply(WmsStockTotal wmsStockTotal); + + /** + * 只查询stocktotal列表信息 + * @param wmsStockTotal + * @return + */ + public List selectOnlyWmsStockTotalList(WmsStockTotal wmsStockTotal); + + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsStockTotalService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsStockTotalService.java index fcbadc0..6757c2d 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsStockTotalService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsStockTotalService.java @@ -87,4 +87,13 @@ public interface IWmsStockTotalService * @return 总库存 */ public JSONObject selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal); + + + /** + * 根据销售订单查询成品库存列表Join material,warehouse,saleorder,totalAmount>0,FOR PDA apply + * + * @param wmsStockTotal 成品库存 + * @return 成品库存 + */ + public List selectWmsStockTotalList4ProductApply(WmsStockTotal wmsStockTotal); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java index 4f6e5db..f7219f1 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java @@ -13,14 +13,11 @@ import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.RemoteMesService; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.wms.config.WmsConfig; -import com.hw.wms.domain.WmsBaseWarehouse; -import com.hw.wms.domain.WmsProductStock; +import com.hw.wms.domain.*; import com.hw.wms.domain.vo.WmsProduceInstockVo; import com.hw.wms.domain.vo.WmsProductOutstockAuditVo; import com.hw.wms.domain.vo.WmsProductOutstockConfirmVo; -import com.hw.wms.mapper.WmsBaseWarehouseMapper; -import com.hw.wms.mapper.WmsProductOutstockDetailMapper; -import com.hw.wms.mapper.WmsProductStockMapper; +import com.hw.wms.mapper.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,9 +25,6 @@ import java.util.ArrayList; import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.hw.wms.domain.WmsProductOutstockDetail; -import com.hw.wms.mapper.WmsProductOutstockMapper; -import com.hw.wms.domain.WmsProductOutstock; import com.hw.wms.service.IWmsProductOutstockService; import javax.annotation.Resource; @@ -52,6 +46,9 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService @Autowired private WmsProductStockMapper wmsProductStockMapper; + @Autowired + private WmsStockTotalMapper wmsStockTotalMapper; + @Autowired private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; @@ -98,6 +95,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) public int insertWmsProductOutstock(WmsProductOutstock wmsProductOutstock) { Long warehouseId = wmsProductOutstock.getWarehouseId(); String saleorderCode = wmsProductOutstock.getSaleorderCode(); @@ -107,26 +105,22 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService throw new ServiceException("申请数量需大于0"); } - WmsProductStock queryProductStock = new WmsProductStock(); - queryProductStock.setWarehouseId(warehouseId); - queryProductStock.setSaleorderCode(saleorderCode); - queryProductStock.setProductId(productId); - queryProductStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId()); - - //group by wps.warehouse_id,wps.sale_order_id,wps.product_id获取的以下库存信息 - List productStocks = wmsProductStockMapper.selectWmsProductStocksBySaleorder(queryProductStock); - if (productStocks == null || productStocks.isEmpty()) { + WmsStockTotal queryStockTotal = new WmsStockTotal(); + queryStockTotal.setWarehouseId(warehouseId); + queryStockTotal.setMaterialId(productId); + queryStockTotal.setSaleOrderId(wmsProductOutstock.getSaleOrderId()); + List wmsStockTotals = wmsStockTotalMapper.selectOnlyWmsStockTotalList(queryStockTotal); + if (wmsStockTotals == null || wmsStockTotals.isEmpty()) { throw new ServiceException("没有库存"); } + WmsStockTotal wmsStockTotal = wmsStockTotals.get(0); - WmsProductStock productStock = productStocks.get(0); - BigDecimal orderAmount = productStock.getOrderAmount(); /*获取仓库可用库存数量*/ - BigDecimal totalAmount = productStock.getTotalAmount() == null ? BigDecimal.ZERO : productStock.getTotalAmount(); - BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用 - BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();// + BigDecimal totalAmount = wmsStockTotal.getTotalAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getTotalAmount(); + BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();//冻结数量暂时没用 + BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();// BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount); - BigDecimal sumApplyQty = productStock.getApplyAmount() == null ? BigDecimal.ZERO : productStock.getApplyAmount();//获取已申请出库数量 +// BigDecimal sumApplyQty = productStock.getApplyAmount() == null ? BigDecimal.ZERO : productStock.getApplyAmount();//获取已申请出库数量 // WmsProductOutstock queryProductOutStock = new WmsProductOutstock(); // queryProductOutStock.setSaleorderCode(saleorderCode); @@ -136,11 +130,8 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService // List wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock); // BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add); - //可申请数量 - BigDecimal availableApplyQty = availableAmount.subtract(sumApplyQty); - - if (applyQty.compareTo(availableApplyQty) > 0) { - throw new ServiceException("可申请数量为" + availableApplyQty); + if (applyQty.compareTo(availableAmount) > 0) { + throw new ServiceException("可申请数量为" + availableAmount); } WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId); @@ -165,6 +156,12 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService int rows = wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock); + wmsStockTotal.setOccupyAmount(occupyAmount.add(applyQty)); + wmsStockTotal.setUpdateBy(userName); + wmsStockTotal.setUpdateDate(currentDate); + + wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal); + //如果是agv自动仓库,需要调用WCS轮询查询成品出库记录进行调度出库 return rows; diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java index c123abd..b544f5e 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java @@ -7,6 +7,9 @@ import java.util.Map; import java.util.stream.Collectors; import com.alibaba.fastjson2.JSONObject; +import com.hw.common.core.constant.WmsConstants; +import com.hw.common.core.exception.ServiceException; +import com.hw.wms.domain.WmsProductStock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.wms.mapper.WmsStockTotalMapper; @@ -169,4 +172,24 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService } + + /** + * 根据销售订单查询成品库存列表Join material,warehouse,saleorder,totalAmount>0 + * + * @param wmsStockTotal 成品库存 + * @return 成品库存 + */ + @Override + public List selectWmsStockTotalList4ProductApply(WmsStockTotal wmsStockTotal) { + wmsStockTotal.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT); + wmsStockTotal.setSafeFlag(WmsConstants.WMS_SAFE_FLAG_NO); + List list = wmsStockTotalMapper.selectWmsStockTotalList4ProductApply(wmsStockTotal); + if (list == null || list.isEmpty()) { + throw new ServiceException("没有销售订单成品库存信息"); + } + + return list; + } + + } diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml index ac9bcda..0c52a88 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml @@ -28,6 +28,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select wst.stock_total_id, wst.warehouse_id, @@ -218,6 +245,7 @@ left join mes_base_material_info mbmi on mbmi.material_id = wst.material_id left join mes_sale_order mso on wst.sale_order_id = mso.sale_order_id + wst.total_amount > 0 and wst.warehouse_id = #{warehouseId} and wst.warehouse_floor = #{warehouseFloor} and wst.stock_type = #{stockType} @@ -234,6 +262,85 @@ and wst.update_date = #{updateDate} and wst.active_flag = #{activeFlag} + + + + + + + + + + + + diff --git a/hw-ui/src/views/mes/barcode/index.vue b/hw-ui/src/views/mes/barcode/index.vue index c93346f..57b81d2 100644 --- a/hw-ui/src/views/mes/barcode/index.vue +++ b/hw-ui/src/views/mes/barcode/index.vue @@ -231,22 +231,15 @@ v-hasPermi="['mes:barcode:printBarcode']" >打印 - - - - - - - - - - - - - - - - + 补打印 + @@ -580,7 +573,7 @@