UI:车间一楼,申请领料修改
WMS:PDA接口原材料入库和成品入库完善;申请领料接口完善
master
xins 8 months ago
parent bcb57874eb
commit 890f8d3ba3

@ -8,10 +8,7 @@ import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.wms.domain.*;
import com.hw.wms.domain.vo.*;
import com.hw.wms.service.IWmsBaseWarehouseService;
import com.hw.wms.service.IWmsRawInstockService;
import com.hw.wms.service.IWmsRawOutstockService;
import com.hw.wms.service.IWmsRawReturnService;
import com.hw.wms.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -36,9 +33,12 @@ public class WmsApiController extends BaseController {
@Autowired
private IWmsRawReturnService wmsRawReturnService;
@Autowired
private IWmsStockTotalService wmsStockTotalService;
/**
*
*
*/
// @RequiresPermissions("wms:rawoutstock:list")
@GetMapping("/getWarehouses")
@ -48,6 +48,20 @@ public class WmsApiController extends BaseController {
}
/**
*
*/
// @RequiresPermissions("mes:materialBom:list")
@GetMapping("/getStockTotal")
public AjaxResult getStockTotal(WmsStockTotal queryStockTotal) {
// String ancestors = mesMaterialBom.getAncestors();
// ancestors = "0," + ancestors;
// mesMaterialBom.setAncestors(ancestors);
List<WmsStockTotal> list = wmsStockTotalService.selectWmsStockTotalJoinList(queryStockTotal);
return success(list);
}
/**
*
*/

@ -4,29 +4,21 @@ 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.poi.ExcelUtil;
import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.web.page.TableDataInfo;
import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.wms.domain.*;
import com.hw.wms.domain.vo.*;
import com.hw.wms.service.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import javafx.scene.control.Tab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

@ -0,0 +1,105 @@
package com.hw.wms.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.wms.domain.WmsStockTotal;
import com.hw.wms.service.IWmsStockTotalService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author xins
* @date 2024-03-14
*/
@RestController
@RequestMapping("/stocktotal")
public class WmsStockTotalController extends BaseController
{
@Autowired
private IWmsStockTotalService wmsStockTotalService;
/**
*
*/
@RequiresPermissions("wms:stocktotal:list")
@GetMapping("/list")
public TableDataInfo list(WmsStockTotal wmsStockTotal)
{
startPage();
List<WmsStockTotal> list = wmsStockTotalService.selectWmsStockTotalList(wmsStockTotal);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:export")
@Log(title = "原材料库存", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, WmsStockTotal wmsStockTotal)
{
List<WmsStockTotal> list = wmsStockTotalService.selectWmsStockTotalList(wmsStockTotal);
ExcelUtil<WmsStockTotal> util = new ExcelUtil<WmsStockTotal>(WmsStockTotal.class);
util.exportExcel(response, list, "原材料库存数据");
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:query")
@GetMapping(value = "/{stockTotalId}")
public AjaxResult getInfo(@PathVariable("stockTotalId") Long stockTotalId)
{
return success(wmsStockTotalService.selectWmsStockTotalByStockTotalId(stockTotalId));
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:add")
@Log(title = "原材料库存", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WmsStockTotal wmsStockTotal)
{
return toAjax(wmsStockTotalService.insertWmsStockTotal(wmsStockTotal));
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:edit")
@Log(title = "原材料库存", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WmsStockTotal wmsStockTotal)
{
return toAjax(wmsStockTotalService.updateWmsStockTotal(wmsStockTotal));
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:remove")
@Log(title = "原材料库存", businessType = BusinessType.DELETE)
@DeleteMapping("/{stockTotalIds}")
public AjaxResult remove(@PathVariable Long[] stockTotalIds)
{
return toAjax(wmsStockTotalService.deleteWmsStockTotalByStockTotalIds(stockTotalIds));
}
}

@ -27,6 +27,8 @@ public class WmsBaseLocation extends BaseEntity
private String agvPositionCode;
private Long warehouseFloor;
@Excel(name = "库位编码")
private String locationCode;
@ -172,6 +174,14 @@ public class WmsBaseLocation extends BaseEntity
this.agvPositionCode = agvPositionCode;
}
public Long getWarehouseFloor() {
return warehouseFloor;
}
public void setWarehouseFloor(Long warehouseFloor) {
this.warehouseFloor = warehouseFloor;
}
public void setLocationCode(String locationCode)
{
this.locationCode = locationCode;

@ -0,0 +1,204 @@
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;
import com.hw.common.core.annotation.Excel;
import com.hw.common.core.web.domain.BaseEntity;
/**
* wms_stock_total
*
* @author xins
* @date 2024-03-14
*/
public class WmsStockTotal extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 总库存ID */
private Long stockTotalId;
/** 仓库ID */
@Excel(name = "仓库ID")
private Long warehouseId;
/** 仓库楼层 */
@Excel(name = "仓库楼层")
private Long warehouseFloor;
/** 库存类型1原材料2半成品3成品 */
@Excel(name = "库存类型1原材料2半成品3成品")
private String stockType;
/** 物料ID */
@Excel(name = "物料ID")
private Long materialId;
/** 总数量;仓库存放的总数量 */
@Excel(name = "总数量;仓库存放的总数量")
private BigDecimal totalAmount;
/** 冻结数量;手动冻结的,暂时可不用 */
@Excel(name = "冻结数量;手动冻结的,暂时可不用")
private BigDecimal frozenAmount;
/** 占用数量;申请时占用的数量,在出库时要减去出库数量,并且总数量要同步更新; */
@Excel(name = "占用数量;申请时占用的数量,在出库时要减去出库数量,并且总数量要同步更新;")
private BigDecimal occupyAmount;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate;
/** 最后更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updateDate;
/** 有效标记 */
@Excel(name = "有效标记")
private String activeFlag;
private String materialCode;
private String materialName;
public void setStockTotalId(Long stockTotalId)
{
this.stockTotalId = stockTotalId;
}
public Long getStockTotalId()
{
return stockTotalId;
}
public void setWarehouseId(Long warehouseId)
{
this.warehouseId = warehouseId;
}
public Long getWarehouseId()
{
return warehouseId;
}
public void setWarehouseFloor(Long warehouseFloor)
{
this.warehouseFloor = warehouseFloor;
}
public Long getWarehouseFloor()
{
return warehouseFloor;
}
public void setStockType(String stockType)
{
this.stockType = stockType;
}
public String getStockType()
{
return stockType;
}
public void setMaterialId(Long materialId)
{
this.materialId = materialId;
}
public Long getMaterialId()
{
return materialId;
}
public void setTotalAmount(BigDecimal totalAmount)
{
this.totalAmount = totalAmount;
}
public BigDecimal getTotalAmount()
{
return totalAmount;
}
public void setFrozenAmount(BigDecimal frozenAmount)
{
this.frozenAmount = frozenAmount;
}
public BigDecimal getFrozenAmount()
{
return frozenAmount;
}
public void setOccupyAmount(BigDecimal occupyAmount)
{
this.occupyAmount = occupyAmount;
}
public BigDecimal getOccupyAmount()
{
return occupyAmount;
}
public void setCreateDate(Date createDate)
{
this.createDate = createDate;
}
public Date getCreateDate()
{
return createDate;
}
public void setUpdateDate(Date updateDate)
{
this.updateDate = updateDate;
}
public Date getUpdateDate()
{
return updateDate;
}
public void setActiveFlag(String activeFlag)
{
this.activeFlag = activeFlag;
}
public String getActiveFlag()
{
return activeFlag;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("stockTotalId", getStockTotalId())
.append("warehouseId", getWarehouseId())
.append("warehouseFloor", getWarehouseFloor())
.append("stockType", getStockType())
.append("materialId", getMaterialId())
.append("totalAmount", getTotalAmount())
.append("frozenAmount", getFrozenAmount())
.append("occupyAmount", getOccupyAmount())
.append("createBy", getCreateBy())
.append("createDate", getCreateDate())
.append("updateBy", getUpdateBy())
.append("updateDate", getUpdateDate())
.append("activeFlag", getActiveFlag())
.toString();
}
}

@ -20,20 +20,20 @@ public class WmsProductInstockVo {
@NotBlank(message="成品条码必须输入")
private String materialBarcode;
//成品批次
@NotBlank(message="成品批次必须输入")
private String productBatch;
//成品批次
@NotNull(message="成品ID必须输入")
private Long productId;
//生产计划ID
@NotBlank(message="生产计划编号必须输入")
private String planCode;
//生产计划明细编号
private String planDetailCode;
// //成品批次
// //@NotBlank(message="成品批次必须输入")
// private String productBatch;
//
// //成品批次
// //@NotNull(message="成品ID必须输入")
// private Long productId;
//
// //生产计划ID
// //@NotBlank(message="生产计划编号必须输入")
// private String planCode;
//
// //生产计划明细编号
// private String planDetailCode;
//库位编码
@NotBlank(message="库位编码必须输入")
private String locationCode;

@ -0,0 +1,75 @@
package com.hw.wms.mapper;
import java.util.List;
import com.hw.wms.domain.WmsStockTotal;
/**
* Mapper
*
* @author xins
* @date 2024-03-14
*/
public interface WmsStockTotalMapper
{
/**
*
*
* @param stockTotalId
* @return
*/
public WmsStockTotal selectWmsStockTotalByStockTotalId(Long stockTotalId);
/**
*
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalList(WmsStockTotal wmsStockTotal);
/**
*
*
* @param wmsStockTotal
* @return
*/
public int insertWmsStockTotal(WmsStockTotal wmsStockTotal);
/**
*
*
* @param wmsStockTotal
* @return
*/
public int updateWmsStockTotal(WmsStockTotal wmsStockTotal);
/**
*
*
* @param stockTotalId
* @return
*/
public int deleteWmsStockTotalByStockTotalId(Long stockTotalId);
/**
*
*
* @param stockTotalIds
* @return
*/
public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds);
/**
*
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal);
}

@ -0,0 +1,70 @@
package com.hw.wms.service;
import java.util.List;
import com.hw.wms.domain.WmsStockTotal;
/**
* Service
*
* @author xins
* @date 2024-03-14
*/
public interface IWmsStockTotalService
{
/**
*
*
* @param stockTotalId
* @return
*/
public WmsStockTotal selectWmsStockTotalByStockTotalId(Long stockTotalId);
/**
*
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalList(WmsStockTotal wmsStockTotal);
/**
*
*
* @param wmsStockTotal
* @return
*/
public int insertWmsStockTotal(WmsStockTotal wmsStockTotal);
/**
*
*
* @param wmsStockTotal
* @return
*/
public int updateWmsStockTotal(WmsStockTotal wmsStockTotal);
/**
*
*
* @param stockTotalIds
* @return
*/
public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds);
/**
*
*
* @param stockTotalId
* @return
*/
public int deleteWmsStockTotalByStockTotalId(Long stockTotalId);
/**
* ,Join material
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal);
}

@ -6,6 +6,9 @@ import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.enums.WmsLocationStatus;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.mapper.WmsBaseWarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsBaseLocationMapper;
@ -23,6 +26,9 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
@Autowired
private WmsBaseLocationMapper wmsBaseLocationMapper;
@Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
/**
*
*
@ -54,6 +60,9 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
@Override
public int insertWmsBaseLocation(WmsBaseLocation wmsBaseLocation) {
wmsBaseLocation.setCreateTime(DateUtils.getNowDate());
wmsBaseLocation.setCreateBy(SecurityUtils.getUsername());
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(wmsBaseLocation.getWarehouseId());
wmsBaseLocation.setWarehouseFloor(warehouse.getWarehouseFloor());
return wmsBaseLocationMapper.insertWmsBaseLocation(wmsBaseLocation);
}

@ -9,6 +9,7 @@ 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.*;
import com.hw.wms.domain.vo.WmsProductInstockVo;
@ -26,6 +27,8 @@ import org.springframework.transaction.annotation.Transactional;
import com.hw.wms.mapper.WmsProductInstockMapper;
import com.hw.wms.service.IWmsProductInstockService;
import javax.annotation.Resource;
/**
* ;Service
*
@ -47,6 +50,10 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
@Autowired
private WmsBaseLocationMapper wmsBaseLocationMapper;
@Resource
private RemoteMesService remoteMesService;
/**
* ;
*
@ -154,15 +161,20 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
@Override
public int insertWmsProductInstock(WmsProductInstockVo wmsProductInstockVo) {
String materialBarcode = wmsProductInstockVo.getMaterialBarcode();
String productBatch = wmsProductInstockVo.getProductBatch();
Long productId = wmsProductInstockVo.getProductId();
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
String productBatch = baseBarcodeInfo.getBatchCode();
Long productId =baseBarcodeInfo.getMaterialId();
String locationCode = wmsProductInstockVo.getLocationCode();
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (baseLocation == null) {
throw new ServiceException("库位编码有误");
}
//todo 入库人权限判断;物料类型判断是否可以入此库位
//todo 仓库可存储此物料判断是否可以入此库位
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();//todo 是否改成nickname
@ -172,8 +184,8 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
wmsProductInstock.setProductType(WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT);
wmsProductInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsProductInstock.setPlanCode(wmsProductInstockVo.getPlanCode());
wmsProductInstock.setPlanDetailCode(wmsProductInstockVo.getPlanDetailCode());
wmsProductInstock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductInstock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT);
wmsProductInstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsProductInstock.setApplyBy(userName);
@ -186,10 +198,9 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
insertWmsProductInstockDetail(wmsProductInstock, materialBarcode, productBatch, productId, wmsProductInstockVo);
//更新库存
updateProductStock(wmsProductInstock, wmsProductInstockVo, baseLocation,
updateProductStock(wmsProductInstock, baseBarcodeInfo, baseLocation,
productBatch, productId, userName, currentDate);
//todo判断质检状态同步erp
return rows;
}
@ -230,7 +241,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
* @param userName
* @param currentDate
*/
public void updateProductStock(WmsProductInstock wmsProductInstock, WmsProductInstockVo wmsProductInstockVo, WmsBaseLocation baseLocation,
public void updateProductStock(WmsProductInstock wmsProductInstock, MesBaseBarcodeInfo baseBarcodeInfo, WmsBaseLocation baseLocation,
String productBatch, Long productId, String userName, Date currentDate) {
String locationCode = wmsProductInstock.getLocationCode();
BigDecimal instockAmount = new BigDecimal(1);
@ -258,8 +269,9 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
wmsProductStock.setStockType(WmsConstants.PRODUCT_STOCK_STOCK_TYPE_PRODUCT);
wmsProductStock.setProductId(productId);
wmsProductStock.setProductBatch(productBatch);
wmsProductStock.setPlanCode(wmsProductInstockVo.getPlanCode());
wmsProductStock.setPlanDetailCode(wmsProductInstockVo.getPlanDetailCode());
wmsProductStock.setPlanCode(baseBarcodeInfo.getPlanCode());
wmsProductStock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode());
wmsProductStock.setWarehouseFloor(baseLocation.getWarehouseFloor());
// wmsProductStock.setQualityStatus(wmsRawInstockVo.getQualityStatus());
wmsProductStock.setTotalAmount(instockAmount);
wmsProductStock.setCreateBy(userName);

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
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;
@ -176,12 +177,21 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService {
if (baseLocation == null) {
throw new ServiceException("库位编码有误");
}
//todo 入库人权限判断
//todo 物料类型判断是否可以入此库位
//todo 可入物料wms_warehouse_material判断是否可以入此库位
BigDecimal instockAmount = wmsRawInstockVo.getInstockAmount();
if (baseBarcodeInfo.getBatchFlag().equals(MesConstants.IS_BATCH)) {
if (instockAmount.compareTo(BigDecimal.ONE) <= 0) {
throw new ServiceException("入库数量需大于等于1");
}
} else {
if (instockAmount.compareTo(BigDecimal.ONE) > 0) {
throw new ServiceException("入库数量需等于1");
}
}
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();//todo 是否改成nickname
String userName = SecurityUtils.getUsername();
WmsRawInstock wmsRawInstock = new WmsRawInstock();
wmsRawInstock.setWarehouseId(baseLocation.getWarehouseId());
wmsRawInstock.setLocationCode(locationCode);
@ -189,8 +199,7 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService {
wmsRawInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsRawInstock.setInstockType(WmsConstants.RAW_INSTOCK_INSTOCK_TYPE_PURCHASE);
wmsRawInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
//todo根据系统参数判断保存审核状态
wmsRawInstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_TOAUDIT);
wmsRawInstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsRawInstock.setApplyBy(userName);
wmsRawInstock.setApplyDate(currentDate);
@ -200,10 +209,9 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService {
//插入明细
insertWmsRawInstockDetail(wmsRawInstock, wmsRawInstockVo, baseBarcodeInfo);
//更新库
//更新库位库
updateRawStock(wmsRawInstock, wmsRawInstockVo, baseLocation, baseBarcodeInfo, userName, currentDate);
//todo同步erp
return rows;
}
@ -271,6 +279,7 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService {
wmsRawStock.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW);
wmsRawStock.setMaterialId(baseBarcodeInfo.getMaterialId());
wmsRawStock.setInstockBatch(instockBatch);
wmsRawStock.setWarehouseFloor(baseLocation.getWarehouseFloor());
// wmsRawStock.setLastOutstockTime(baseBarcodeInfo.getLastOutstockDate());
// wmsRawStock.setQualityStatus(wmsRawInstockVo.getQualityStatus());
wmsRawStock.setTotalAmount(wmsRawInstockVo.getInstockAmount());

@ -7,6 +7,7 @@ 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.StringUtils;
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.MesBaseMaterialInfo;
@ -164,6 +165,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
List<WmsRawOutstockDetail> list = new ArrayList<WmsRawOutstockDetail>();
for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList) {
wmsRawOutstockDetail.setRawOutstockId(rawOutstockId);
wmsRawOutstockDetail.setTaskCode(wmsRawOutstock.getTaskCode());
list.add(wmsRawOutstockDetail);
}
if (list.size() > 0) {
@ -380,6 +382,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
/**
*
*
*
* @param wmsRawOutstock
* @return
@ -387,103 +390,119 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
@Transactional(rollbackFor = Exception.class)
@Override
public int applyRawOutstock(WmsRawOutstock wmsRawOutstock) {
//todo:不能取拆分后的,只能是组装出库才能获取
Long warehouseId = wmsRawOutstock.getWarehouseId();
List<WmsRawOutstockDetail> rawOutstockDetails = wmsRawOutstock.getWmsRawOutstockDetailList();
//根据物料ID分组获取总申请数量
Map<Long, BigDecimal> rawOutstockDetailMap = rawOutstockDetails.stream()
.collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId, HashMap::new, Collectors.reducing(BigDecimal.ZERO, WmsRawOutstockDetail::getPlanAmount, BigDecimal::add)));
// Map<Long, BigDecimal> rawOutstockDetailMap = rawOutstockDetails.stream()
// .collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId, HashMap::new, Collectors.reducing(BigDecimal.ZERO, WmsRawOutstockDetail::getPlanAmount, BigDecimal::add)));
//判断仓库类型,出库记录保存对应操作类型,出库记录明细保存对应出库方式
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseWithLocationByWarehouseId(warehouseId);
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
String warehouseType = warehouse.getWarehouseType();
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
String outstockWay = WmsConstants.OUTSTOCK_WAY_MAP.get(warehouseType);
String queryQualityStatus = WmsConstants.WMS_QUALITY_STATUS_PASS;
List<WmsRawOutstockDetail> toUpdatedRawOutstockDetails = new ArrayList<>();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
for (Long materialId : rawOutstockDetailMap.keySet()) {
BigDecimal planAmount = rawOutstockDetailMap.get(materialId);
BigDecimal realRawStock = BigDecimal.ZERO;//实际库存总量
WmsRawStock queryRawStock = new WmsRawStock();
queryRawStock.setWarehouseId(warehouseId);
queryRawStock.setMaterialId(materialId);
rawOutstockDetails.forEach(rawOutstockDetail->{
BigDecimal planAmount = rawOutstockDetail.getPlanAmount()==null?BigDecimal.ZERO:rawOutstockDetail.getPlanAmount();
Long materialId = rawOutstockDetail.getMaterialId();
if(planAmount.compareTo(BigDecimal.ZERO)>0){
BigDecimal realRawStock = BigDecimal.ZERO;//实际库存总量
WmsRawStock queryRawStock = new WmsRawStock();
queryRawStock.setWarehouseId(warehouseId);
queryRawStock.setMaterialId(materialId);
queryRawStock.setCompleteFlag(WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAY_YES);
// queryRawStock.setQualityStatus(queryQualityStatus);//todo先不过滤质检状态
//判断库位和可用数量(总数量减冻结数量和占用数量),按先进先出(按入库时间排序获取)
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStocks4Apply(queryRawStock);
if (wmsRawStocks != null && !wmsRawStocks.isEmpty()) {
for (WmsRawStock wmsRawStock : wmsRawStocks) {
BigDecimal totalAmount = wmsRawStock.getTotalAmount();
BigDecimal frozenAmount = wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount();
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
realRawStock = realRawStock.add(availableAmount);
//可出库数量大于0
if (availableAmount.compareTo(BigDecimal.ZERO) > 0) {
//如果申请数量大于此库位可出库的数量则继续进行下一库位判断
if (planAmount.compareTo(availableAmount) > 0) {
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(availableAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理(最好避免前端可以传多条同一个物料的申请),提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = planAmount.subtract(availableAmount);
} else if (planAmount.compareTo(availableAmount) == 0) {//计划数量等于可出库数量
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(availableAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
} else if (planAmount.compareTo(availableAmount) < 0) {
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(planAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
planAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
//TODO:需要先查看wms_raw_stock_occupy是否有此生产订单的占用明细,有的话需要计算并且更新
//判断库位和可用数量(总数量减冻结数量和占用数量),按先进先出(按入库时间排序获取)
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStocks4Apply(queryRawStock);
if (wmsRawStocks != null && !wmsRawStocks.isEmpty()) {
for (WmsRawStock wmsRawStock : wmsRawStocks) {
BigDecimal totalAmount = wmsRawStock.getTotalAmount();
BigDecimal frozenAmount = wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount();
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
realRawStock = realRawStock.add(availableAmount);
//可出库数量大于0
if (availableAmount.compareTo(BigDecimal.ZERO) > 0) {
//如果申请数量大于此库位可出库的数量则继续进行下一库位判断
if (planAmount.compareTo(availableAmount) > 0) {
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(availableAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理(最好避免前端可以传多条同一个物料的申请),
// 提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = planAmount.subtract(availableAmount);
} else if (planAmount.compareTo(availableAmount) == 0) {//计划数量等于可出库数量
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(availableAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
} else if (planAmount.compareTo(availableAmount) < 0) {
//占用数量更改
wmsRawStock.setOccupyAmount(occupyAmount.add(planAmount));
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
planAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
}
}
}
}
}
if (planAmount.compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException("物料编号为[" + materialId + "]库存不足,只有" + realRawStock);
if (planAmount.compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException("物料编号为[" + materialId + "]库存不足,只有" + realRawStock);
}
}
});
//出库要求 0申请出库1申请审核出库2直接出库
String outRequirement = warehouse.getOutRequirement();
String auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
if(outRequirement.equals(WmsConstants.WMS_WAREHOUSE_OUT_REQUIREMENT_APPLY_AUDIT)){
wmsRawOutstock.setAuditStatus(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
}else{
wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
}
wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType,Seq.rawOutstockSeqCode));
wmsRawOutstock.setStationId(SecurityUtils.getStationId());
//todo 审核状态默认为待审核,后续可根据系统参数判断保存是待审核还是直接审核通过
wmsRawOutstock.setOperationType(operationType);
wmsRawOutstock.setApplyBy(userName);
wmsRawOutstock.setApplyDate(currentDate);
wmsRawOutstock.setAuditStatus(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
int rows = wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock);
wmsRawOutstock.setWmsRawOutstockDetailList(toUpdatedRawOutstockDetails);

@ -0,0 +1,113 @@
package com.hw.wms.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsStockTotalMapper;
import com.hw.wms.domain.WmsStockTotal;
import com.hw.wms.service.IWmsStockTotalService;
/**
* Service
*
* @author xins
* @date 2024-03-14
*/
@Service
public class WmsStockTotalServiceImpl implements IWmsStockTotalService
{
@Autowired
private WmsStockTotalMapper wmsStockTotalMapper;
/**
*
*
* @param stockTotalId
* @return
*/
@Override
public WmsStockTotal selectWmsStockTotalByStockTotalId(Long stockTotalId)
{
return wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(stockTotalId);
}
/**
*
*
* @param wmsStockTotal
* @return
*/
@Override
public List<WmsStockTotal> selectWmsStockTotalList(WmsStockTotal wmsStockTotal)
{
return wmsStockTotalMapper.selectWmsStockTotalList(wmsStockTotal);
}
/**
*
*
* @param wmsStockTotal
* @return
*/
@Override
public int insertWmsStockTotal(WmsStockTotal wmsStockTotal)
{
return wmsStockTotalMapper.insertWmsStockTotal(wmsStockTotal);
}
/**
*
*
* @param wmsStockTotal
* @return
*/
@Override
public int updateWmsStockTotal(WmsStockTotal wmsStockTotal)
{
return wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal);
}
/**
*
*
* @param stockTotalIds
* @return
*/
@Override
public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds)
{
return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalIds(stockTotalIds);
}
/**
*
*
* @param stockTotalId
* @return
*/
@Override
public int deleteWmsStockTotalByStockTotalId(Long stockTotalId)
{
return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalId(stockTotalId);
}
/**
* ,Join material
*
* @param wmsStockTotal
* @return
*/
@Override
public List<WmsStockTotal> selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal)
{
//todo:还需要计算锁库的数量
return wmsStockTotalMapper.selectWmsStockTotalJoinList(wmsStockTotal);
}
}

@ -9,6 +9,7 @@
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseName" column="warehouse_name" />
<result property="agvPositionCode" column="agv_position_code" />
<result property="warehouseFloor" column="warehouse_floor" />
<result property="locationCode" column="location_code" />
<result property="locRow" column="loc_row" />
<result property="layerNum" column="layer_num" />
@ -40,7 +41,7 @@
</resultMap>
<sql id="selectWmsBaseLocationVo">
select location_id, warehouse_id, location_code, loc_row, layer_num, loc_column, active_flag, manual_flag, qty_limit, instock_flag, outstock_flag, location_status, batch_mix, create_by, create_time, update_by, update_time, remark, del_flag, shelf_order, check_order, pick_order, pick_flag, is_open_kn_flag, location_scrap_type, volume_limit, weight_limit, length, width, height from wms_base_location
select location_id, warehouse_id, location_code,agv_position_code, warehouse_floor,loc_row, layer_num, loc_column, active_flag, manual_flag, qty_limit, instock_flag, outstock_flag, location_status, batch_mix, create_by, create_time, update_by, update_time, remark, del_flag, shelf_order, check_order, pick_order, pick_flag, is_open_kn_flag, location_scrap_type, volume_limit, weight_limit, length, width, height from wms_base_location
</sql>
<select id="selectWmsBaseLocationList" parameterType="WmsBaseLocation" resultMap="WmsBaseLocationResult">
@ -82,6 +83,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">warehouse_id,</if>
<if test="agvPositionCode != null and agvPositionCode != ''">agv_position_code,</if>
<if test="warehouseFloor != null">warehouse_floor,</if>
<if test="locationCode != null and locationCode != ''">location_code,</if>
<if test="locRow != null">loc_row,</if>
<if test="layerNum != null">layer_num,</if>
@ -114,6 +116,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">#{warehouseId},</if>
<if test="agvPositionCode != null and agvPositionCode != ''">#{agvPositionCode},</if>
<if test="warehouseFloor != null">#{warehouseFloor},</if>
<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
<if test="locRow != null">#{locRow},</if>
<if test="layerNum != null">#{layerNum},</if>

@ -66,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into wms_product_stock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">warehouse_id,</if>
<if test="warehouseFloor != null">warehouse_floor,</if>
<if test="locationCode != null and locationCode != ''">location_code,</if>
<if test="stockType != null and stockType != ''">stock_type,</if>
<if test="productBatch != null">product_batch,</if>
@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">#{warehouseId},</if>
<if test="warehouseFloor != null">#{warehouseFloor},</if>
<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
<if test="stockType != null and stockType != ''">#{stockType},</if>
<if test="productBatch != null">#{productBatch},</if>

@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into wms_raw_stock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">warehouse_id,</if>
<if test="warehouseFloor != null">warehouse_floor,</if>
<if test="locationCode != null and locationCode != ''">location_code,</if>
<if test="stockType != null and stockType != ''">stock_type,</if>
<if test="materialId != null">material_id,</if>
@ -81,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">#{warehouseId},</if>
<if test="warehouseFloor != null">#{warehouseFloor},</if>
<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
<if test="stockType != null and stockType != ''">#{stockType},</if>
<if test="materialId != null">#{materialId},</if>

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.wms.mapper.WmsStockTotalMapper">
<resultMap type="WmsStockTotal" id="WmsStockTotalResult">
<result property="stockTotalId" column="stock_total_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseFloor" column="warehouse_floor" />
<result property="stockType" column="stock_type" />
<result property="materialId" column="material_id" />
<result property="totalAmount" column="total_amount" />
<result property="frozenAmount" column="frozen_amount" />
<result property="occupyAmount" column="occupy_amount" />
<result property="createBy" column="create_by" />
<result property="createDate" column="create_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="activeFlag" column="active_flag" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
</resultMap>
<sql id="selectWmsStockTotalVo">
select stock_total_id, warehouse_id, warehouse_floor, stock_type, material_id, total_amount, frozen_amount, occupy_amount, create_by, create_date, update_by, update_date, active_flag from wms_stock_total
</sql>
<select id="selectWmsStockTotalList" parameterType="WmsStockTotal" resultMap="WmsStockTotalResult">
<include refid="selectWmsStockTotalVo"/>
<where>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="warehouseFloor != null "> and warehouse_floor = #{warehouseFloor}</if>
<if test="stockType != null and stockType != ''"> and stock_type = #{stockType}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="totalAmount != null "> and total_amount = #{totalAmount}</if>
<if test="frozenAmount != null "> and frozen_amount = #{frozenAmount}</if>
<if test="occupyAmount != null "> and occupy_amount = #{occupyAmount}</if>
<if test="createDate != null "> and create_date = #{createDate}</if>
<if test="updateDate != null "> and update_date = #{updateDate}</if>
<if test="activeFlag != null and activeFlag != ''"> and active_flag = #{activeFlag}</if>
</where>
</select>
<select id="selectWmsStockTotalByStockTotalId" parameterType="Long" resultMap="WmsStockTotalResult">
<include refid="selectWmsStockTotalVo"/>
where stock_total_id = #{stockTotalId}
</select>
<insert id="insertWmsStockTotal" parameterType="WmsStockTotal" useGeneratedKeys="true" keyProperty="stockTotalId">
insert into wms_stock_total
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">warehouse_id,</if>
<if test="warehouseFloor != null">warehouse_floor,</if>
<if test="stockType != null and stockType != ''">stock_type,</if>
<if test="materialId != null">material_id,</if>
<if test="totalAmount != null">total_amount,</if>
<if test="frozenAmount != null">frozen_amount,</if>
<if test="occupyAmount != null">occupy_amount,</if>
<if test="createBy != null">create_by,</if>
<if test="createDate != null">create_date,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateDate != null">update_date,</if>
<if test="activeFlag != null">active_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="warehouseId != null">#{warehouseId},</if>
<if test="warehouseFloor != null">#{warehouseFloor},</if>
<if test="stockType != null and stockType != ''">#{stockType},</if>
<if test="materialId != null">#{materialId},</if>
<if test="totalAmount != null">#{totalAmount},</if>
<if test="frozenAmount != null">#{frozenAmount},</if>
<if test="occupyAmount != null">#{occupyAmount},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateDate != null">#{updateDate},</if>
<if test="activeFlag != null">#{activeFlag},</if>
</trim>
</insert>
<update id="updateWmsStockTotal" parameterType="WmsStockTotal">
update wms_stock_total
<trim prefix="SET" suffixOverrides=",">
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="warehouseFloor != null">warehouse_floor = #{warehouseFloor},</if>
<if test="stockType != null and stockType != ''">stock_type = #{stockType},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="totalAmount != null">total_amount = #{totalAmount},</if>
<if test="frozenAmount != null">frozen_amount = #{frozenAmount},</if>
<if test="occupyAmount != null">occupy_amount = #{occupyAmount},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createDate != null">create_date = #{createDate},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateDate != null">update_date = #{updateDate},</if>
<if test="activeFlag != null">active_flag = #{activeFlag},</if>
</trim>
where stock_total_id = #{stockTotalId}
</update>
<delete id="deleteWmsStockTotalByStockTotalId" parameterType="Long">
delete from wms_stock_total where stock_total_id = #{stockTotalId}
</delete>
<delete id="deleteWmsStockTotalByStockTotalIds" parameterType="String">
delete from wms_stock_total where stock_total_id in
<foreach item="stockTotalId" collection="array" open="(" separator="," close=")">
#{stockTotalId}
</foreach>
</delete>
<select id="selectWmsStockTotalJoinList" parameterType="WmsStockTotal" resultMap="WmsStockTotalResult">
select wst.stock_total_id, wst.warehouse_id, wst.warehouse_floor, wst.stock_type, wst.material_id,
wst.total_amount, wst.frozen_amount, wst.occupy_amount,
mbmi.material_code,mbmi.material_name
from wms_stock_total wst left join mes_base_material_info mbmi on wst.material_id = mbmi.material_id
<where>
<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>
<if test="materialId != null "> and wst.material_id = #{materialId}</if>
<if test="materialName != null and materialName != ''">and mbmi.material_name like concat('%', #{materialName},
'%')
</if>
</where>
</select>
</mapper>

@ -45,9 +45,9 @@ export function insertProductPlanDetails(query) {
})
}
export function getMaterialBoms(query) {
export function getStockTotal(query) {
return request({
url: '/mes/api/getMaterialBoms',
url: '/wms/api/getStockTotal',
method: 'get',
params: query
})

@ -380,13 +380,13 @@
width="40%">
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="工单编号">
<el-input v-model="form.planCode"></el-input>
<el-input v-model="form.planCode" disabled></el-input>
</el-form-item>
<el-form-item label="明细编号">
<el-input v-model="form.planDetailCode"></el-input>
<el-input v-model="form.planDetailCode" disabled></el-input>
</el-form-item>
<el-form-item label="领料仓库">
<el-select v-model="form.warehouseId" placeholder="请选择领料仓库" @change="form.wmsRawOutstockDetailList =[]">
<el-select v-model="form.warehouseId" placeholder="请选择领料仓库" @change="warehouseChange">
<el-option v-for="item in warehouseList" :key="item.warehouseId" :label="item.warehouseName"
:value="item.warehouseId"></el-option>
</el-select>
@ -404,7 +404,7 @@
>
<el-table-column
label="物料编号"
prop="materialId"
prop="materialCode"
>
</el-table-column>
<el-table-column
@ -414,12 +414,12 @@
</el-table-column>
<el-table-column
label="可用库存数量"
prop="materialName"
prop="availableAmount"
>
</el-table-column>
<el-table-column
label="占用库存数量"
prop="materialName"
prop="unavailableAmount"
>
</el-table-column>
<el-table-column
@ -430,7 +430,7 @@
<template slot-scope="scope">
<el-input-number
:min="0"
v-model="scope.row.quantityAcquired"
v-model="scope.row.planAmount"
controls-position="right"
style="width: 100%"
>
@ -448,14 +448,6 @@
size="mini"
@change="searchMaterial"/>
</template>
<template slot-scope="scope">
<el-button
size="small"
type="text"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<div style="text-align: center;margin-top: 12px">
@ -469,7 +461,7 @@
import Chart from '@/components/board/Chart'
import * as echarts from 'echarts'
import {
getMaterialBoms,
getStockTotal,
getWarehouses,
applyRawOutstock,
getProductPlans,
@ -830,6 +822,7 @@ export default {
this.dialogVisible = true
this.form = {
warehouseId: '',
planId: val.row.planId,
planCode: val.row.planCode,
planDetailCode: val.row.planDetailCode,
applyReason: '',
@ -837,23 +830,16 @@ export default {
wmsRawOutstockDetailList: []
}
//
getWarehouses().then(e => {
getWarehouses({"warehouseFloor":1}).then(e => {
this.warehouseList = e.data
this.form.warehouseId = e.data[0]?.warehouseId
this.searchMaterial("");
})
//
getMaterialBoms({
ancestors: this.materialBomId,
}).then(e => {
this.form.wmsRawOutstockDetailList = e.data.map(r => {
return {
materialId: r.materialId,
materialName: r.materialName,
planAmount: 0,
}
})
})
},
//
receiveMaterial() {
applyRawOutstock(this.form).then(e => {
@ -868,19 +854,27 @@ export default {
},
//
searchMaterial(val) {
getMaterialBoms({
warehouseFloor:1,
ancestors: this.materialBomId,
getStockTotal({
warehouseId:this.form.warehouseId,
materialName: val
}).then(e => {
this.form.wmsRawOutstockDetailList = e.data.map(r => {
return {
materialId: r.materialId,
materialCode: r.materialCode,
materialName: r.materialName,
planAmount: 0,
availableAmount: r.totalAmount-r.occupyAmount-r.frozenAmount,
unavailableAmount: r.occupyAmount+r.frozenAmount,
planAmount: r.planAmount
}
})
})
},
warehouseChange(warehouseId){
this.form.wmsRawOutstockDetailList =[];
this.form.warehouseId = warehouseId;
this.getStockTotal();
}
}
}

Loading…
Cancel
Save