WMS:PDA接口原材料退库审核、PDA接口人工成品出库申请、PDA接口人工成品出库、PDA接口半成品入成品库完善
master
xins 8 months ago
parent 40718d7950
commit 21db948cfc

@ -108,7 +108,7 @@ public class MesBaseBarcodeInfo extends BaseEntity
/** 销售订单编号;适合生产出入库等 */
@Excel(name = "销售订单ID")
private String saleOrderId;
private Long saleOrderId;
/** 销售订单编号;适合生产出入库等 */
@Excel(name = "销售订单编号")
@ -322,11 +322,11 @@ public class MesBaseBarcodeInfo extends BaseEntity
return planDetailCode;
}
public String getSaleOrderId() {
public Long getSaleOrderId() {
return saleOrderId;
}
public void setSaleOrderId(String saleOrderId) {
public void setSaleOrderId(Long saleOrderId) {
this.saleOrderId = saleOrderId;
}

@ -118,6 +118,17 @@ public class Seq {
// 设备报修工单标识
public static final String dmsBillsFaultInstanceSeqCode = "BF";
// 物料转库记录序列类型
public static final String wmsTransferSeqType = "WMSTRANSFER";
// 物料转库记录接口序列数
private static AtomicInteger wmsTransferSeq = new AtomicInteger(1);
// 物料转库记录标识
public static final String wmsTransferSeqCode = "TF";
/**
*
*
@ -200,6 +211,8 @@ public class Seq {
atomicInt = dmsBillsFaultInstanceSeq;
}else if (rawOutstockSeqType.equals(type)) {
atomicInt = rawOutstockSeq;
}else if (wmsTransferSeqType.equals(type)) {
atomicInt = wmsTransferSeq;
}
return getId(atomicInt, 3, code);
}

@ -311,12 +311,12 @@ public class WmsMobileController extends BaseController {
*/
// @RequiresPermissions("wms:rawoutstock:query")
@GetMapping(value = "/getProductStocksBySalesorderCode")
public TableDataInfo getProductStocksBySalesorderCode(WmsProductStockSaleorder queryProductStockSaleorder) {
public TableDataInfo getProductStocksBySalesorderCode(WmsProductStock queryProductStock) {
startPage();
// WmsProductStock queryProductStock = new WmsProductStock();
// queryProductStock.setSaleorderCode(request.getParameter("salesorderCode"));
// queryProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
List list = wmsProductStockSaleorderService.selectWmsProductStockSaleordersBySaleorder(queryProductStockSaleorder);
List list = wmsProductStockService.selectWmsProductStocksBySaleorder(queryProductStock);
return getDataTable(list);
}
@ -373,6 +373,16 @@ public class WmsMobileController extends BaseController {
}
/**
*
*/
@Log(title = "成品出库确认", businessType = BusinessType.UPDATE)
@PostMapping(("/finalConfirmProductOutstock"))
public AjaxResult finalConfirmProductOutstock(@RequestBody WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo) {
return toAjax(1);
}
/**
*
*/

@ -71,6 +71,7 @@ public class WmsProductOutstock extends BaseEntity {
@Excel(name = "计划明细编号,关联pd_base_plan_detail的plan_detail_code")
private String planDetailCode;
private Long saleOrderId;
private String saleorderCode;
private String projectNo;
@ -166,6 +167,7 @@ public class WmsProductOutstock extends BaseEntity {
/**
*
*/
@ -243,6 +245,14 @@ public class WmsProductOutstock extends BaseEntity {
this.planDetailCode = planDetailCode;
}
public Long getSaleOrderId() {
return saleOrderId;
}
public void setSaleOrderId(Long saleOrderId) {
this.saleOrderId = saleOrderId;
}
public String getSaleorderCode() {
return saleorderCode;
}
@ -403,8 +413,6 @@ public class WmsProductOutstock extends BaseEntity {
this.materialName = materialName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -58,7 +58,7 @@ public class WmsProductOutstockDetail extends BaseEntity
private BigDecimal confirmAmount;
/** 执行状态(0待执行,1执行中,2执行完成) */
@Excel(name = "执行状态(0待执行,1执行中,2执行完成)")
@Excel(name = "执行状态(0待执行,1执行中,2执行完成3已确认)")
private String executeStatus;
/** 同步ERP状态(0:失败,1成功) */

@ -61,6 +61,7 @@ public class WmsProductStock extends BaseEntity
@Excel(name = "计划明细编号,关联pd_base_plan_detail的plan_detail_code")
private String planDetailCode;
private Long saleOrderId;
/**
*
*/
@ -103,6 +104,8 @@ public class WmsProductStock extends BaseEntity
private String warehouseName;
private BigDecimal applyAmount;
public void setProductStockId(Long productStockId)
{
@ -193,6 +196,14 @@ public class WmsProductStock extends BaseEntity
this.planDetailCode = planDetailCode;
}
public Long getSaleOrderId() {
return saleOrderId;
}
public void setSaleOrderId(Long saleOrderId) {
this.saleOrderId = saleOrderId;
}
public String getSaleorderCode() {
return saleorderCode;
}
@ -297,6 +308,14 @@ public class WmsProductStock extends BaseEntity
this.warehouseName = warehouseName;
}
public BigDecimal getApplyAmount() {
return applyAmount;
}
public void setApplyAmount(BigDecimal applyAmount) {
this.applyAmount = applyAmount;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,25 @@
package com.hw.wms.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Description: VO
* @ClassName: WmsProductOutstockConfirmVo
* @Author : xins
* @Date :2024-03-18 15:21
* @Version :1.0
*/
@Data
public class WmsProductOutstockConfirmVo {
//成品条码
@NotBlank(message="成品条码必须输入")
private String materialBarcode;
@NotBlank(message="销售订单号码必须输入")
private String saleorderCode;
}

@ -69,15 +69,24 @@ public interface WmsProductStockMapper
*/
public BigDecimal getProductStockTotalAmount(WmsProductStock wmsProductStock);
/**
*
* @param productBatch
* @return WmsRawStock
*/
public WmsProductStock selectProductStockByBatch(@Param("productBatch") String productBatch);
/**
* ID
* @param locationCode
* @param productBatch
* @param stockType
* @param saleOrderId
* @return WmsRawStock
*/
public WmsProductStock selectProductStockByLocationAndBatch(@Param("locationCode") String locationCode,
@Param("productBatch") String productBatch,@Param("stockType") String stockType);
public WmsProductStock selectProductStockByLocationAndBatchAndSaleOrderId(@Param("locationCode") String locationCode,@Param("productBatch") String productBatch,
@Param("saleOrderId") Long saleOrderId,@Param("stockType") String stockType);
/**

@ -167,7 +167,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
Long productId =baseBarcodeInfo.getMaterialId();
Long productId = baseBarcodeInfo.getMaterialId();
String locationCode = wmsProductInstockVo.getLocationCode();
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
@ -251,47 +251,39 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
throw new ServiceException("已超出库位数量限制,请重新选择库位");
}
//如果是同一库位入同一批次,则更新数量
WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
if (wmsProductStock != null) {
//一个成品一个条码,对应一条库存信息
WmsProductStock wmsProductStock = new WmsProductStock();
wmsProductStock.setWarehouseId(wmsProductInstock.getWarehouseId());
wmsProductStock.setLocationCode(locationCode);
wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
wmsProductStock.setProductId(productId);
wmsProductStock.setProductBatch(productBatch);
wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor());
wmsProductStock.setSaleorderCode(baseBarcodeInfo.getSaleorderCode());
// wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus());
wmsProductStock.setTotalAmount(wmsProductStock.getTotalAmount().add(instockAmount));
wmsProductStock.setUpdateBy(userName);
wmsProductStock.setUpdateDate(currentDate);
wmsProductStockMapper.updateWmsProductStock(wmsProductStock);
} else {
wmsProductStock = new WmsProductStock();
wmsProductStock.setWarehouseId(wmsProductInstock.getWarehouseId());
wmsProductStock.setLocationCode(locationCode);
wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
wmsProductStock.setProductId(productId);
wmsProductStock.setProductBatch(productBatch);
wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor());
wmsProductStock.setSaleorderCode(baseBarcodeInfo.getSaleorderCode());
// wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus());
wmsProductStock.setTotalAmount(instockAmount);
wmsProductStock.setCreateBy(userName);
wmsProductStock.setCreateDate(currentDate);
wmsProductStock.setInstockDate(currentDate);
wmsProductStockMapper.insertWmsProductStock(wmsProductStock);
}
wmsProductStock.setTotalAmount(instockAmount);
wmsProductStock.setCreateBy(userName);
wmsProductStock.setCreateDate(currentDate);
wmsProductStock.setInstockDate(currentDate);
wmsProductStockMapper.insertWmsProductStock(wmsProductStock);
}
/**
*
*
* @param wmsProduceInstockVo
* @return
*/
@Override
public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo){
public int produceInstock(WmsProduceInstockVo wmsProduceInstockVo) {
return 1;
}
public void syncToErp() {
//todo 根据质检状态是通过的同步给ERP
}

@ -4,9 +4,13 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.domain.WmsProductOutstock;
import com.hw.wms.domain.WmsProductStock;
@ -20,6 +24,8 @@ import com.hw.wms.domain.WmsProductOutstockDetail;
import com.hw.wms.service.IWmsProductOutstockDetailService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Service
*
@ -74,8 +80,7 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
@Transactional(rollbackFor = Exception.class)
public int insertWmsProductOutstockDetail(WmsProductOutstockDetail wmsProductOutstockDetail) {
String locationCode = wmsProductOutstockDetail.getLocationCode();
String productBarcode = wmsProductOutstockDetail.getProductBarcode();
String productBatch = wmsProductOutstockDetail.getProductBatch();
String productBarcode = wmsProductOutstockDetail.getProductBarcode();//成品条码和批次码相同
Long productOutstockId = wmsProductOutstockDetail.getProductOutstockId();
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
@ -96,10 +101,12 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
throw new ServiceException("此出库申请已完成,不能再出库");
}
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch, WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatchAndSaleOrderId(locationCode,
productBarcode, productOutstock.getSaleOrderId(), WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
if (productStock == null) {
throw new ServiceException("此库位没有库存");
throw new ServiceException("此库位没有对应订单库存");
}
BigDecimal totalAmount = productStock.getTotalAmount();
BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();
BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();
@ -109,6 +116,8 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
throw new ServiceException("此库位没有可出库存");
}
/**判断已出库数量和申请的数量*/
BigDecimal applyQty = productOutstock.getApplyQty() == null ? BigDecimal.ZERO : productOutstock.getApplyQty();
BigDecimal outstockQty = productOutstock.getOutstockQty() == null ? BigDecimal.ZERO : productOutstock.getOutstockQty();
@ -128,18 +137,19 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
}
productOutstock.setOutstockQty(currentOutstockQty);
if(productOutstock.getBeginTime()==null) {
productOutstock.setBeginTime(currentDate);
if (productOutstock.getBeginTime() == null) {
productOutstock.setBeginTime(currentDate);
}
productOutstock.setUpdateDate(currentDate);
productOutstock.setUpdateBy(userName);
wmsProductOutstockMapper.updateWmsProductOutstock(productOutstock);
//更新库存
productStock.setTotalAmount(totalAmount.subtract(BigDecimal.ONE));
productStock.setUpdateBy(userName);
productStock.setUpdateDate(currentDate);
wmsProductStockMapper.updateWmsProductStock(productStock);
//删除库存(由于一个成品对应一个库存信息,删除即可)
// productStock.setTotalAmount(totalAmount.subtract(BigDecimal.ONE));
// productStock.setUpdateBy(userName);
// productStock.setUpdateDate(currentDate);
// wmsProductStockMapper.updateWmsProductStock(productStock);
wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
//插入出库记录明细
wmsProductOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
@ -151,8 +161,6 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD
wmsProductOutstockDetailMapper.insertWmsProductOutstockDetail(wmsProductOutstockDetail);
//todo:同步erp
return 1;
}

@ -80,6 +80,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
queryProductStock.setWarehouseId(warehouseId);
queryProductStock.setSaleorderCode(saleorderCode);
queryProductStock.setProductId(productId);
queryProductStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId());
List<WmsProductStock> productStocks = wmsProductStockMapper.selectWmsProductStocksBySaleorder(queryProductStock);
if (productStocks == null || productStocks.isEmpty()) {
throw new ServiceException("没有库存");
@ -89,15 +90,18 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
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 frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用
BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();//
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
BigDecimal sumApplyQty = productStock.getApplyAmount();//获取已申请出库数量
/*获取已申请出库数量*/
WmsProductOutstock queryProductOutStock = new WmsProductOutstock();
queryProductOutStock.setSaleorderCode(saleorderCode);
List<WmsProductOutstock> wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock);
BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add);
// WmsProductOutstock queryProductOutStock = new WmsProductOutstock();
// queryProductOutStock.setSaleorderCode(saleorderCode);
// queryProductOutStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId());
// queryProductOutStock.setWarehouseId(warehouseId);
// queryProductOutStock.setProductId(productId);
// List<WmsProductOutstock> wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock);
// BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add);
//可申请数量
BigDecimal availableApplyQty = availableAmount.subtract(sumApplyQty);
@ -123,7 +127,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
int rows = wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock);
//todo:如果是agv自动仓库需要调用WCS进行调度出库
//如果是agv自动仓库需要调用WCS轮询查询成品出库记录进行调度出库
return rows;
}

@ -3,6 +3,7 @@ package com.hw.wms.service.impl;
import java.math.BigDecimal;
import java.util.*;
import com.hw.common.core.constant.MesConstants;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
@ -18,8 +19,7 @@ import com.hw.wms.domain.vo.WmsRawOutstockAuditVo;
import com.hw.wms.domain.vo.WmsRawOutstockConfirmVo;
import com.hw.wms.domain.vo.WmsRawReturnAuditVo;
import com.hw.wms.domain.vo.WmsRawReturnConfirmVo;
import com.hw.wms.mapper.WmsRawReturnDetailMapper;
import com.hw.wms.mapper.WmsRawStockMapper;
import com.hw.wms.mapper.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -28,7 +28,6 @@ import java.util.stream.Collectors;
import com.hw.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.hw.wms.mapper.WmsRawReturnMapper;
import com.hw.wms.service.IWmsRawReturnService;
import javax.annotation.Resource;
@ -47,6 +46,12 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
@Autowired
private WmsRawReturnDetailMapper wmsRawReturnDetailMapper;
@Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
@Autowired
private WmsBaseLocationMapper wmsBaseLocationMapper;
@Autowired
private WmsRawStockMapper wmsRawStockMapper;
@ -102,9 +107,9 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
Long productId = rawReturn.getProductId() == null ? 0L : rawReturn.getProductId();
Long[] rawReturnMaterialIds = {materialId, productId};
List<WmsRawReturnDetail> wmsRawReturnDetailList = rawReturn.getWmsRawReturnDetailList();
Long[] rawReturnDetailMaterialIds = wmsRawReturnDetailList.stream().map(o -> o.getMaterialId()).toArray(Long[]::new);
Long[] materialIds = ArrayUtils.addAll(rawReturnMaterialIds, rawReturnDetailMaterialIds);
// List<WmsRawReturnDetail> wmsRawReturnDetailList = rawReturn.getWmsRawReturnDetailList();
// Long[] rawReturnDetailMaterialIds = wmsRawReturnDetailList.stream().map(o -> o.getMaterialId()).toArray(Long[]::new);
Long[] materialIds = ArrayUtils.addAll(rawReturnMaterialIds);
if (materialIds.length > 0) {
MesBaseMaterialInfoVo mesBaseMaterialInfoVo = new MesBaseMaterialInfoVo();
@ -117,20 +122,13 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
.collect(Collectors.toMap(MesBaseMaterialInfo::getMaterialId, mesBaseMaterialInfo -> mesBaseMaterialInfo));
MesBaseMaterialInfo materialInfo = mesBaseMaterialInfoMap.get(materialId);
if (materialInfo != null) {
rawReturn.setMaterialName(materialInfo.getMaterialName());
rawReturn.setMaterialName(materialInfo.getMaterialName());//物料名称
}
MesBaseMaterialInfo productInfo = mesBaseMaterialInfoMap.get(productId);
if (productInfo != null) {
rawReturn.setProductName(productInfo.getMaterialName());
rawReturn.setProductName(productInfo.getMaterialName());//成品名称
}
wmsRawReturnDetailList.forEach(wmsRawReturnDetail -> {
MesBaseMaterialInfo detailMaterialInfo = mesBaseMaterialInfoMap.get(wmsRawReturnDetail.getMaterialId());
if (materialInfo != null) {
wmsRawReturnDetail.setMaterialCode(detailMaterialInfo.getMaterialCode());
wmsRawReturnDetail.setMaterialName(detailMaterialInfo.getMaterialName());
}
});
}
}
@ -270,6 +268,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
Long rawReturnId = wmsRawReturnConfirmVo.getRawReturnId();
String materialBarcode = wmsRawReturnConfirmVo.getMaterialBarcode();
BigDecimal returnAmount = wmsRawReturnConfirmVo.getReturnAmount();
String locationCode = wmsRawReturnConfirmVo.getLocationCode();
//todo: 判断质检状态,超出库位数量限制,超期判断
// if (wmsRawReturnDetail.getQualityStatus() != null
@ -277,6 +276,10 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
// throw new ServiceException("质检通过才能出库");
// }
if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("输入数量大于0");
}
R<MesBaseBarcodeInfo> mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
if (mesBaseBarcodeInfoR == null) {
throw new ServiceException("物料编码错误");
@ -290,6 +293,27 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
throw new ServiceException("审核未通过,不能出库");
}
String batchFlag = mesBaseBarcodeInfo.getBatchFlag();
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
if (returnAmount.compareTo(BigDecimal.ONE) != 0) {
throw new ServiceException("输入数量需为1");
}
}
if(!wmsRawReturn.getMaterialId().equals(mesBaseBarcodeInfo.getMaterialId())){
throw new ServiceException("物料编码错误");
}
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if(baseLocation == null){
throw new ServiceException("库位编码有误");
}
if(!baseLocation.getWarehouseId().equals(wmsRawReturn.getWarehouseId())){
throw new ServiceException("退库仓库有误");
}
// 判断本次退库数量+已退库数量是否大于计划退库数量
BigDecimal planAmount = wmsRawReturn.getPlanAmount();
BigDecimal hadReturnAmount = wmsRawReturn.getReturnAmount() == null ? BigDecimal.ZERO : wmsRawReturn.getReturnAmount();
@ -299,7 +323,6 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
throw new ServiceException("退库数量不能大于" + planAmount);
}
String executeStatus = "";
if (updatedReturnAmount.compareTo(planAmount) == 0) {
executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH;
@ -321,9 +344,8 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
mesBaseBarcodeInfo, userName, currentDate);
//更新原材料库存
this.updateRawStock(wmsRawReturnConfirmVo, mesBaseBarcodeInfo, userName, currentDate);
this.updateRawStock(wmsRawReturnConfirmVo, mesBaseBarcodeInfo, baseLocation,userName, currentDate);
//todo 同步erp
return 1;
}
@ -347,13 +369,30 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
}
private void updateRawStock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo, MesBaseBarcodeInfo mesBaseBarcodeInfo, String userName, Date currentDate) {
private void updateRawStock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo, MesBaseBarcodeInfo mesBaseBarcodeInfo, WmsBaseLocation baseLocation,
String userName, Date currentDate) {
String locationCode = wmsRawReturnConfirmVo.getLocationCode();
String instockBatch = mesBaseBarcodeInfo.getBatchCode();
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch);
if (wmsRawStock == null) {
throw new ServiceException("数据异常");
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(baseLocation.getWarehouseId());
wmsRawStock = new WmsRawStock();
wmsRawStock.setWarehouseId(warehouse.getWarehouseId());
wmsRawStock.setWarehouseFloor(warehouse.getWarehouseFloor());
wmsRawStock.setLocationCode(locationCode);
wmsRawStock.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW);
wmsRawStock.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
wmsRawStock.setInstockBatch(mesBaseBarcodeInfo.getBatchCode());
wmsRawStock.setInstockDate(mesBaseBarcodeInfo.getAcceptedDate());
wmsRawStock.setLastOutstockTime(mesBaseBarcodeInfo.getLastOutstockDate());
// wmsRawStock.setQualityStatus();//TODO:质检状态
wmsRawStock.setCompleteFlag(WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAG_YES);
wmsRawStock.setTotalAmount(wmsRawReturnConfirmVo.getReturnAmount());
wmsRawStock.setCreateBy(userName);
wmsRawStock.setCreateDate(currentDate);
wmsRawStockMapper.insertWmsRawStock(wmsRawStock);
} else {
BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount();
BigDecimal updatedTotalAmount = totalAmount.add(wmsRawReturnConfirmVo.getReturnAmount());
@ -430,7 +469,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
toUpdatedWmsRawReturn.setPlanCode(wmsRawReturn.getPlanCode());
toUpdatedWmsRawReturn.setPlanDetailCode(wmsRawReturn.getPlanDetailCode());
toUpdatedWmsRawReturn.setTaskType(wmsRawReturn.getTaskType());
toUpdatedWmsRawReturn.setTaskCode(Seq.getId(Seq.rawReturnSeqType,Seq.rawReturnCode));
toUpdatedWmsRawReturn.setTaskCode(Seq.getId(Seq.rawReturnSeqType, Seq.rawReturnCode));
// toUpdatedWmsRawReturn.setProductId();
toUpdatedWmsRawReturn.setApplyReason(wmsRawReturn.getApplyReason());

@ -43,7 +43,7 @@ public class WmsTransactionalServiceImpl implements IWmsTransactionalService {
BigDecimal applyQty = wmsTransfer.getApplyQty();
String productBatch = wmsTransfer.getProductBatch();
String oriLocationCode = wmsTransfer.getOriLocationCode();
WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(oriLocationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI);
WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByBatch(productBatch);
if (wmsProductStock == null) {
throw new ServiceException("库位["+oriLocationCode+"]没有此批次["+productBatch+"]的库存");
}

@ -8,14 +8,12 @@ import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.domain.WmsProductStock;
import com.hw.wms.mapper.WmsBaseLocationMapper;
import com.hw.wms.mapper.WmsProductStockMapper;
import com.hw.wms.mapper.WmsTransferDetailMapper;
import com.hw.wms.domain.*;
import com.hw.wms.mapper.*;
import com.hw.wms.service.IWmsTransactionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -24,9 +22,6 @@ import java.util.ArrayList;
import com.hw.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.hw.wms.domain.WmsTransferDetail;
import com.hw.wms.mapper.WmsTransferMapper;
import com.hw.wms.domain.WmsTransfer;
import com.hw.wms.service.IWmsTransferService;
import javax.annotation.Resource;
@ -54,6 +49,9 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
@Autowired
private IWmsTransactionalService wmsTransactionalService;
@Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
@Resource
private RemoteMesService remoteMesService;
@ -196,7 +194,8 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
public int transferOutstock(WmsTransferDetail wmsTransferDetail) {
String userName = SecurityUtils.getUsername();
Date currentDate = new Date();
String locationCode = wmsTransferDetail.getLocationCode();
String oriLocationCode = wmsTransferDetail.getLocationCode();
String materialBarcode = wmsTransferDetail.getMaterialBarcode();
R<MesBaseBarcodeInfo> mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
@ -208,39 +207,40 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
throw new ServiceException("物料编码错误");
}
String productBatch = mesBaseBarcodeInfo.getBatchCode();
Long transferId = wmsTransferDetail.getTransferId();
WmsTransfer wmsTransfer;
if (transferId == null) {
WmsTransfer queryTransfer = new WmsTransfer();
queryTransfer.setOriLocationCode(locationCode);
queryTransfer.setProductBatch(productBatch);
queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH);
List<WmsTransfer> wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer);
if (wmsTransfers == null || wmsTransfers.isEmpty()) {
throw new ServiceException("没有此任务");
}
if (wmsTransfers.size() > 1) {
throw new ServiceException("有多条此库位任务,请选择具体任务后点击出库");
}
wmsTransfer = wmsTransfers.get(0);
} else {
wmsTransfer = wmsTransferMapper.selectWmsTransferByTransferId(transferId);
WmsTransfer queryTransfer = new WmsTransfer();
queryTransfer.setOriLocationCode(oriLocationCode);
queryTransfer.setProductBatch(materialBarcode);
queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH);
List<WmsTransfer> wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer);
if (wmsTransfers != null && !wmsTransfers.isEmpty()) {
throw new ServiceException("有此库位出库任务,请不要重复出库");
}
BigDecimal applyQty = wmsTransfer.getApplyQty();
BigDecimal outstockQty = wmsTransfer.getOutstockQty() == null ? BigDecimal.ZERO : wmsTransfer.getOutstockQty();
BigDecimal currentOutstockQty = outstockQty.add(BigDecimal.ONE);
if (applyQty.compareTo(currentOutstockQty) < 0) {
throw new ServiceException("已出库完成,不能多次出库");
WmsBaseLocation oriLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(oriLocationCode);
if (oriLocation == null) {
throw new ServiceException("库位不存在");
}
WmsTransfer wmsTransfer = new WmsTransfer();
wmsTransfer.setTaskCode(Seq.getId(Seq.wmsTransferSeqType, Seq.wmsTransferSeqCode));
wmsTransfer.setOriWarehouseId(oriLocation.getWarehouseId());
wmsTransfer.setOriLocationCode(oriLocationCode);
wmsTransfer.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
wmsTransfer.setProductBatch(materialBarcode);
wmsTransfer.setApplyQty(BigDecimal.ONE);
wmsTransfer.setOutstockQty(BigDecimal.ONE);
wmsTransfer.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsTransfer.setTransferType(WmsConstants.WMS_TRANSFER_TYPE_OUT_TO_PRODUCT_STOCK);
wmsTransfer.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
wmsTransfer.setApplyBy(userName);
wmsTransfer.setApplyDate(currentDate);
wmsTransfer.setBeginTime(currentDate);
wmsTransferMapper.insertWmsTransfer(wmsTransfer);
//插入转库任务明细
wmsTransferDetail.setTransferId(wmsTransfer.getTransferId());
wmsTransferDetail.setInstockBatch(productBatch);
wmsTransferDetail.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
wmsTransferDetail.setRealAmount(BigDecimal.ONE);
wmsTransferDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
@ -251,20 +251,10 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
wmsTransferDetail.setExecuteTime(currentDate);
wmsTransferDetailMapper.insertWmsTransferDetail(wmsTransferDetail);
//更新转库任务
wmsTransfer.setOutstockQty(currentOutstockQty);
wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
wmsTransfer.setUpdateDate(currentDate);
wmsTransfer.setUpdateBy(userName);
wmsTransferMapper.updateWmsTransfer(wmsTransfer);
//更新成品库存
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_SEMI);
productStock.setTotalAmount(productStock.getTotalAmount().subtract(BigDecimal.ONE));
productStock.setOccupyAmount(productStock.getOccupyAmount().subtract(BigDecimal.ONE));
productStock.setUpdateDate(currentDate);
productStock.setUpdateBy(userName);
wmsProductStockMapper.updateWmsProductStock(productStock);
//删除成品库存
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
return 1;
}
@ -280,7 +270,7 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
public int transferInstock(WmsTransferDetail wmsTransferDetail) {
String userName = SecurityUtils.getUsername();
Date currentDate = new Date();
String locationCode = wmsTransferDetail.getLocationCode();
String targetLocationCode = wmsTransferDetail.getLocationCode();
String materialBarcode = wmsTransferDetail.getMaterialBarcode();
R<MesBaseBarcodeInfo> mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
@ -291,43 +281,39 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
if (mesBaseBarcodeInfo == null) {
throw new ServiceException("物料编码错误");
}
String productBatch = mesBaseBarcodeInfo.getBatchCode();
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
Long warehouseId = location.getWarehouseId();
Long transferId = wmsTransferDetail.getTransferId();
WmsTransfer wmsTransfer;
if (transferId == null) {
WmsTransfer queryTransfer = new WmsTransfer();
queryTransfer.setTargetWarehouseId(warehouseId);
queryTransfer.setProductBatch(productBatch);
queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
List<WmsTransfer> wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer);
if (wmsTransfers == null || wmsTransfers.isEmpty()) {
throw new ServiceException("没有此任务或者还未出库");
}
if (wmsTransfers.size() > 1) {
throw new ServiceException("有多条此库位任务,请选择具体任务后点击出库");
}
wmsTransfer = wmsTransfers.get(0);
} else {
wmsTransfer = wmsTransferMapper.selectWmsTransferByTransferId(transferId);
WmsBaseLocation targetLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(targetLocationCode);
if (targetLocation == null) {
throw new ServiceException("库位不存在");
}
BigDecimal applyQty = wmsTransfer.getApplyQty();
BigDecimal outstockQty = wmsTransfer.getOutstockQty() == null ? BigDecimal.ZERO : wmsTransfer.getOutstockQty();
BigDecimal instockQty = wmsTransfer.getInstockQty();
BigDecimal currentInstockQty = instockQty.add(BigDecimal.ONE);
if (outstockQty.compareTo(currentInstockQty) < 0) {
throw new ServiceException("请先出库再入库");
/**判断有没有已出库的转库记录*/
WmsTransfer queryTransfer = new WmsTransfer();
queryTransfer.setProductBatch(materialBarcode);
queryTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH);
List<WmsTransfer> wmsTransfers = wmsTransferMapper.selectWmsTransferList(queryTransfer);
if(wmsTransfers==null || wmsTransfers.isEmpty()){
throw new ServiceException("没有此成品的转库出库记录,不能转库入库");
}
Long targetWarehouseId = targetLocation.getWarehouseId();
WmsBaseWarehouse targetWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(targetWarehouseId);
WmsTransfer wmsTransfer = wmsTransfers.get(0);
wmsTransfer.setTargetWarehouseId(targetWarehouseId);
wmsTransfer.setTargetLocationCode(targetLocationCode);
wmsTransfer.setInstockQty(BigDecimal.ONE);
wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsTransfer.setUpdateBy(userName);
wmsTransfer.setUpdateDate(currentDate);
wmsTransfer.setEndTime(currentDate);
wmsTransferMapper.updateWmsTransfer(wmsTransfer);
//插入转库任务明细
wmsTransferDetail.setTransferId(wmsTransfer.getTransferId());
wmsTransferDetail.setInstockBatch(productBatch);
wmsTransferDetail.setInstockBatch(materialBarcode);
wmsTransferDetail.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
wmsTransferDetail.setRealAmount(BigDecimal.ONE);
wmsTransferDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
@ -338,42 +324,25 @@ public class WmsTransferServiceImpl implements IWmsTransferService {
wmsTransferDetail.setExecuteTime(currentDate);
wmsTransferDetailMapper.insertWmsTransferDetail(wmsTransferDetail);
//更新转库任务
wmsTransfer.setInstockQty(currentInstockQty);
if (applyQty.compareTo(currentInstockQty) == 0) {//出库和入库都已完成
wmsTransfer.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
}
wmsTransfer.setUpdateDate(currentDate);
wmsTransfer.setUpdateBy(userName);
wmsTransferMapper.updateWmsTransfer(wmsTransfer);
//更新成品库存
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByLocationAndBatch(locationCode, productBatch,WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
if (productStock == null) {
productStock = new WmsProductStock();
productStock.setTotalAmount(BigDecimal.ONE);
productStock.setWarehouseId(warehouseId);
productStock.setLocationCode(locationCode);
productStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
productStock.setProductBatch(productBatch);
// productStock.setQualityStatus();//todo: 获取质检状态
productStock.setProductId(mesBaseBarcodeInfo.getMaterialId());
productStock.setPlanCode(mesBaseBarcodeInfo.getPlanCode());
productStock.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode());
productStock.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode());
productStock.setCreateDate(currentDate);
productStock.setCreateBy(userName);
wmsProductStockMapper.insertWmsProductStock(productStock);
} else {
productStock.setTotalAmount(productStock.getTotalAmount().add(BigDecimal.ONE));
productStock.setUpdateDate(currentDate);
productStock.setUpdateBy(userName);
wmsProductStockMapper.updateWmsProductStock(productStock);
}
//更新成品库存,一个成品一个条码,对应一条库存记录
WmsProductStock productStock = new WmsProductStock();
productStock.setTotalAmount(BigDecimal.ONE);
productStock.setWarehouseId(targetWarehouseId);
productStock.setLocationCode(targetLocationCode);
productStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
productStock.setProductBatch(materialBarcode);
// productStock.setQualityStatus();//todo: 获取质检状态
productStock.setWarehouseFloor(targetWarehouse.getWarehouseFloor());
productStock.setProductId(mesBaseBarcodeInfo.getMaterialId());
productStock.setPlanCode(mesBaseBarcodeInfo.getPlanCode());
productStock.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode());
productStock.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId());
productStock.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode());
productStock.setCreateDate(currentDate);
productStock.setCreateBy(userName);
wmsProductStockMapper.insertWmsProductStock(productStock);
//TODO:同步ERP库存
return 1;
}

@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="outstockType" column="outstock_type" />
<result property="planCode" column="plan_code" />
<result property="planDetailCode" column="plan_detail_code" />
<result property="saleOrderId" column="sale_order_id" />
<result property="saleorderCode" column="saleorder_code" />
<result property="projectNo" column="project_no" />
<result property="productId" column="product_id" />
@ -259,7 +260,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectOnlyWmsProductOutstockByOutstockId" parameterType="Long" resultMap="WmsProductOutstockResult">
select a.product_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.product_type, a.operation_type, a.outstock_type, a.plan_code, a.plan_detail_code, a.product_id,a.apply_qty,a.outstock_qty,a.apply_reason, a.audit_reason, a.audit_status, a.execute_status, a.apply_by, a.apply_date, a.audit_by, a.audit_date, a.update_by, a.update_date, a.begin_time, a.end_time
select a.product_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.product_type, a.operation_type, a.outstock_type, a.plan_code, a.plan_detail_code, a.product_id,a.apply_qty,a.outstock_qty,a.sale_order_id, a.execute_status, a.apply_by, a.apply_date, a.begin_time, a.end_time
from wms_product_outstock a
where a.product_outstock_id = #{productOutstockId}
</select>

@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productId" column="product_id" />
<result property="planCode" column="plan_code" />
<result property="planDetailCode" column="plan_detail_code" />
<result property="saleOrderId" column="sale_order_id" />
<result property="saleorderCode" column="saleorder_code" />
<result property="totalAmount" column="total_amount" />
<result property="frozenAmount" column="frozen_amount" />
@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="materialName" column="material_name" />
<result property="orderAmount" column="order_amount" />
<result property="warehouseName" column="warehouse_name" />
<result property="applyAmount" column="apply_amount" />
</resultMap>
<sql id="selectWmsProductStockVo">
@ -160,9 +162,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectProductStockByLocationAndBatch" resultMap="WmsProductStockResult">
<select id="selectProductStockByBatch" resultMap="WmsProductStockResult">
<include refid="selectWmsProductStockVo"/>
where location_code = #{locationCode} and product_batch = #{productBatch} and stock_type = #{stockType}
where product_batch = #{productBatch} limit 1
</select>
<select id="selectProductStockByLocationAndBatchAndSaleOrderId" resultMap="WmsProductStockResult">
<include refid="selectWmsProductStockVo"/>
where location_code = #{locationCode} and product_batch = #{productBatch} and sale_order_id=#{saleOrderId} and stock_type = #{stockType}
</select>
@ -218,6 +225,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectWmsProductStocksBySaleorder" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
select wps.warehouse_id,wps.sale_order_id,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount,
mbmi.material_code,mbmi.material_name,
wbw.warehouse_name,mso.order_amount,mso.saleorder_code,
(select sum(wpo.apply_qty) from wms_product_outstock wpo where wpo.sale_order_id=wps.sale_order_id and wpo.warehouse_id=wps.warehouse_id and wpo.product_id=wps.product_id) apply_amount
from wms_product_stock wps
left join mes_base_material_info mbmi on wps.product_id=mbmi.material_id
left join wms_base_warehouse wbw on wps.warehouse_id=wbw.warehouse_id
left join mes_sale_order mso on wps.sale_order_id=mso.sale_order_id
<where>
wps.total_amount>0 and wps.stock_type='3'
<if test="saleorderCode != null and saleorderCode != ''"> and mso.saleorder_code = #{saleorderCode}</if>
<if test="warehouseId != null ">and wps.warehouse_id = #{warehouseId}</if>
<if test="productId != null ">and wps.product_id = #{productId}</if>
</where>
group by wps.warehouse_id,wps.sale_order_id,wps.product_id
</select>
<!--select id="selectWmsProductStocksBySaleorder" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
select wgb.warehouse_id,wgb.saleorder_code,wgb.product_id,mso.order_amount,wgb.total_amount,wgb.frozen_amount,wgb.occupy_amount,wbw.warehouse_name,mbmi.material_code,mbmi.material_name from mes_sale_order mso left join
(select wps.warehouse_id,wps.saleorder_code,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount from wms_product_stock wps where wps.total_amount>0 and wps.stock_type='3'
group by wps.warehouse_id,wps.saleorder_code,wps.product_id) wgb
@ -230,7 +257,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null ">and wgb.warehouse_id = #{warehouseId}</if>
<if test="productId != null ">and wgb.product_id = #{productId}</if>
</where>
</select>
</select-->
</mapper>

@ -90,8 +90,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectWmsRawReturnByRawReturnId" parameterType="Long" resultMap="WmsRawReturnWmsRawReturnDetailResult">
select a.raw_return_id, a.task_code, a.warehouse_id, a.location_code, a.plan_code, a.plan_detail_code, a.product_id, a.operation_type, a.task_type, a.apply_reason, a.audit_reason, a.audit_status, a.execute_status, a.apply_by, a.apply_date, a.audit_by, a.audit_date, a.update_by, a.update_date, a.begin_time, a.end_time,a.material_id,a.product_id,
b.raw_return_detail_id as sub_raw_return_detail_id, b.raw_return_id as sub_raw_return_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.material_id as sub_material_id, b.instock_batch as sub_instock_batch, b.material_production_Date as sub_material_production_Date, b.plan_amount as sub_plan_amount, b.return_amount as sub_return_amount, b.execute_status as sub_execute_status, b.erp_status as sub_erp_status, b.return_person as sub_return_person, b.return_time as sub_return_time, b.return_way as sub_return_way, b.machine_name as sub_machine_name, b.quality_status as sub_quality_status, b.create_by as sub_create_by, b.create_date as sub_create_date, b.update_by as sub_update_by, b.update_date as sub_update_date, b.stack_amount as sub_stack_amount
select a.raw_return_id, a.task_code, a.warehouse_id, a.location_code, a.plan_code, a.plan_detail_code, a.product_id, a.operation_type, a.task_type, a.apply_reason, a.audit_reason, a.audit_status, a.execute_status, a.apply_by, a.apply_date, a.audit_by, a.audit_date,a.plan_amount,a.return_amount, a.begin_time, a.end_time,a.material_id,a.product_id,
b.raw_return_detail_id as sub_raw_return_detail_id, b.raw_return_id as sub_raw_return_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.material_id as sub_material_id, b.instock_batch as sub_instock_batch, b.material_production_Date as sub_material_production_Date, b.plan_amount as sub_plan_amount, b.return_amount as sub_return_amount,
b.execute_status as sub_execute_status, b.erp_status as sub_erp_status, b.return_person as sub_return_person, b.return_time as sub_return_time, b.return_way as sub_return_way, b.machine_name as sub_machine_name, b.quality_status as sub_quality_status, b.create_by as sub_create_by, b.stack_amount as sub_stack_amount
from wms_raw_return a
left join wms_raw_return_detail b on b.raw_return_id = a.raw_return_id
where a.raw_return_id = #{rawReturnId}

Loading…
Cancel
Save