WMS:PDA接口申请移库、PDA接口获取移库任务列表、PDA接口移库出库和PDA接口移库入库完成
master
xins 8 months ago
parent 088786aa08
commit 09228dd9f4

@ -118,7 +118,6 @@ public class WmsMobileController extends BaseController {
// public AjaxResult getRawOutstockByOutstockId(@PathVariable("rawOutstockId") Long rawOutstockId) { // public AjaxResult getRawOutstockByOutstockId(@PathVariable("rawOutstockId") Long rawOutstockId) {
// return success(wmsRawOutstockService.selectWmsRawOutstockByRawOutstockId(rawOutstockId)); // return success(wmsRawOutstockService.selectWmsRawOutstockByRawOutstockId(rawOutstockId));
// } // }
@GetMapping(value = "/getRawOutstockByTaskCode/{taskCode}") @GetMapping(value = "/getRawOutstockByTaskCode/{taskCode}")
public AjaxResult getRawOutstockByTaskCode(@PathVariable("taskCode") String taskCode) { public AjaxResult getRawOutstockByTaskCode(@PathVariable("taskCode") String taskCode) {
return success(wmsRawOutstockService.selectWmsRawOutstockByTaskCode(taskCode)); return success(wmsRawOutstockService.selectWmsRawOutstockByTaskCode(taskCode));
@ -409,18 +408,16 @@ public class WmsMobileController extends BaseController {
} }
//todo入库时校验warehousematerial,入库出库需要校验库位状态,是否是移库合库锁定等 //todo入库时校验warehousematerial,入库出库需要校验库位状态,是否是移库合库锁定等
/** /**
* *
*/ */
@Log(title = "人工移库", businessType = BusinessType.APPLY) @Log(title = "人工移库", businessType = BusinessType.APPLY)
@PostMapping(("/applyMove")) @PostMapping(("/applyMove"))
public AjaxResult applyMove(@Validated @RequestBody WmsMove wmsMove) { public AjaxResult applyMove(@Validated @RequestBody WmsMoveApplyVo wmsMoveApplyVo) {
return toAjax(wmsMoveService.applyMove(wmsMove)); return toAjax(wmsMoveService.applyMove(wmsMoveApplyVo));
} }
/** /**
@ -431,7 +428,8 @@ public class WmsMobileController extends BaseController {
public TableDataInfo getMoveList(WmsMove wmsMove) { public TableDataInfo getMoveList(WmsMove wmsMove) {
startPage(); startPage();
wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL); wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL);
List<WmsMove> wmsMoves = wmsMoveService.selectWmsMoveJoinList(wmsMove); wmsMove.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING);
List<WmsMove> wmsMoves = wmsMoveService.selectWmsMoveGroupJoinList(wmsMove);
return getDataTable(wmsMoves); return getDataTable(wmsMoves);
} }
@ -439,12 +437,12 @@ public class WmsMobileController extends BaseController {
* *
*/ */
// @RequiresPermissions("wms:rawoutstock:query") // @RequiresPermissions("wms:rawoutstock:query")
@GetMapping(value = "/getMoveDetail/{moveId}") @GetMapping(value = "/getMoveDetail/{taskCode}")
public AjaxResult getMoveDetail(@PathVariable("moveId") Long moveId) { public AjaxResult getMoveDetail(@PathVariable("taskCode") String taskCode) {
WmsMoveDetail queryMoveDetail = new WmsMoveDetail(); WmsMove queryMove = new WmsMove();
queryMoveDetail.setMoveId(moveId); queryMove.setTaskCode(taskCode);
List<WmsMoveDetail> wmsMoveDetailList = wmsMoveService.selectWmsMoveDetailJoinList(queryMoveDetail); List<WmsMove> wmsMoveList = wmsMoveService.selectWmsMoveJoinList(queryMove);
return success(wmsMoveDetailList); return success(wmsMoveList);
} }
@ -468,10 +466,4 @@ public class WmsMobileController extends BaseController {
} }
} }

@ -1,5 +1,6 @@
package com.hw.wms.domain; package com.hw.wms.domain;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
@ -37,6 +38,26 @@ public class WmsMove extends BaseEntity
@Excel(name = "目标库位编码") @Excel(name = "目标库位编码")
private String targetLocationCode; private String targetLocationCode;
/** 物料批次 */
@Excel(name = "物料批次")
private String instockBatch;
/** 物料ID */
@Excel(name = "物料ID")
private Long materialId;
/** 计划出库数量 */
@Excel(name = "计划出库数量")
private BigDecimal planAmount;
/** 实际出库数量 */
@Excel(name = "实际出库数量")
private BigDecimal realOutstockAmount;
/** 计划入库数量 */
@Excel(name = "计划入库数量")
private BigDecimal realInstockAmount;
/** 操作类型(0自动,1人工,2强制,3调度) */ /** 操作类型(0自动,1人工,2强制,3调度) */
@Excel(name = "操作类型(0自动,1人工,2强制,3调度)") @Excel(name = "操作类型(0自动,1人工,2强制,3调度)")
private String operationType; private String operationType;
@ -100,10 +121,14 @@ public class WmsMove extends BaseEntity
private String warehouseName; private String warehouseName;
private String materialName;
/** 移库合库记录明细;原材料入库记录对应的明细信息信息 */ /** 移库合库记录明细;原材料入库记录对应的明细信息信息 */
private List<WmsMoveDetail> wmsMoveDetailList; private List<WmsMoveDetail> wmsMoveDetailList;
/** 执行状态(0待执行,1执行中,2执行完成) 多个以,隔开*/
private String executeStatusStr;
public void setMoveId(Long moveId) public void setMoveId(Long moveId)
{ {
this.moveId = moveId; this.moveId = moveId;
@ -149,6 +174,47 @@ public class WmsMove extends BaseEntity
{ {
return targetLocationCode; return targetLocationCode;
} }
public String getInstockBatch() {
return instockBatch;
}
public void setInstockBatch(String instockBatch) {
this.instockBatch = instockBatch;
}
public Long getMaterialId() {
return materialId;
}
public void setMaterialId(Long materialId) {
this.materialId = materialId;
}
public BigDecimal getPlanAmount() {
return planAmount;
}
public void setPlanAmount(BigDecimal planAmount) {
this.planAmount = planAmount;
}
public BigDecimal getRealOutstockAmount() {
return realOutstockAmount;
}
public void setRealOutstockAmount(BigDecimal realOutstockAmount) {
this.realOutstockAmount = realOutstockAmount;
}
public BigDecimal getRealInstockAmount() {
return realInstockAmount;
}
public void setRealInstockAmount(BigDecimal realInstockAmount) {
this.realInstockAmount = realInstockAmount;
}
public void setOperationType(String operationType) public void setOperationType(String operationType)
{ {
this.operationType = operationType; this.operationType = operationType;
@ -286,6 +352,13 @@ public class WmsMove extends BaseEntity
this.wmsMoveDetailList = wmsMoveDetailList; this.wmsMoveDetailList = wmsMoveDetailList;
} }
public String getExecuteStatusStr() {
return executeStatusStr;
}
public void setExecuteStatusStr(String executeStatusStr) {
this.executeStatusStr = executeStatusStr;
}
public String getWarehouseName() { public String getWarehouseName() {
return warehouseName; return warehouseName;
@ -295,6 +368,14 @@ public class WmsMove extends BaseEntity
this.warehouseName = warehouseName; this.warehouseName = warehouseName;
} }
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,32 @@
package com.hw.wms.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @Description: VO
* @ClassName: WmsMoveApplyVo
* @Author : xins
* @Date :2024-03-28 14:51
* @Version :1.0
*/
@Data
public class WmsMoveApplyVo {
//仓库ID
@NotNull(message="warehouseId必须输入")
private Long warehouseId;
@NotBlank(message="原库位编码必须输入")
private String oriLocationCode;
@NotBlank(message="目标库位编码必须输入")
private String targetLocationCode;
@NotBlank(message="类型1移库2合库必须输入")
private String moveType;
}

@ -26,9 +26,9 @@ public class WmsMoveVo {
@NotNull(message="数量必须输入") @NotNull(message="数量必须输入")
private BigDecimal applyQty; private BigDecimal applyQty;
//数量 //任务编号
@NotNull(message="moveId必须输入") @NotBlank(message="taskCode必须输入")
private Long moveId; private String taskCode;
@NotBlank(message="类型必须输入") @NotBlank(message="类型必须输入")
private String moveType; private String moveType;

@ -67,11 +67,11 @@ public interface WmsMoveDetailMapper
* *
* *
* @param moveId * @param moveId
* @param batchCode * @param materialBarcode
* @return * @return
*/ */
public WmsMoveDetail selectWmsMoveDetailByMoveIdAndBatchCode(@Param("moveId") Long moveId, public WmsMoveDetail selectWmsMoveDetailByMoveIdAndBarCode(@Param("moveId") Long moveId,
@Param("batchCode") String batchCode); @Param("materialBarcode") String materialBarcode);
/** /**
@ -82,4 +82,5 @@ public interface WmsMoveDetailMapper
*/ */
public List<WmsMoveDetail> selectWmsMoveDetailJoinList(WmsMoveDetail wmsMoveDetail); public List<WmsMoveDetail> selectWmsMoveDetailJoinList(WmsMoveDetail wmsMoveDetail);
} }

@ -91,7 +91,25 @@ public interface WmsMoveMapper
/** /**
* Join warehouse * group by wm.task_code,wm.warehouse_id,wm.ori_location_code,wm.target_location_code
*
* @param wmsMove
* @return
*/
public List<WmsMove> selectWmsMoveGroupJoinList(WmsMove wmsMove);
/**
* ;
*
* @param wmsMoveList ;
* @return
*/
public int batchWmsMove(List<WmsMove> wmsMoveList);
/**
* Join material,warehouse
* *
* @param wmsMove * @param wmsMove
* @return * @return

@ -3,6 +3,7 @@ package com.hw.wms.service;
import java.util.List; import java.util.List;
import com.hw.wms.domain.WmsMove; import com.hw.wms.domain.WmsMove;
import com.hw.wms.domain.WmsMoveDetail; import com.hw.wms.domain.WmsMoveDetail;
import com.hw.wms.domain.vo.WmsMoveApplyVo;
import com.hw.wms.domain.vo.WmsMoveVo; import com.hw.wms.domain.vo.WmsMoveVo;
/** /**
@ -72,14 +73,14 @@ public interface IWmsMoveService
* @param wmsMove * @param wmsMove
* @return * @return
*/ */
public List<WmsMove> selectWmsMoveJoinList(WmsMove wmsMove); public List<WmsMove> selectWmsMoveGroupJoinList(WmsMove wmsMove);
/** /**
* *
* @param wmsMove * @param wmsMoveApplyVo
* @return * @return
*/ */
public int applyMove(WmsMove wmsMove); public int applyMove(WmsMoveApplyVo wmsMoveApplyVo);
/** /**
* join material * join material
@ -88,6 +89,13 @@ public interface IWmsMoveService
*/ */
public List<WmsMoveDetail> selectWmsMoveDetailJoinList(WmsMoveDetail wmsMoveDetail); public List<WmsMoveDetail> selectWmsMoveDetailJoinList(WmsMoveDetail wmsMoveDetail);
/**
* ,Join material
*
* @param wmsMove
* @return
*/
public List<WmsMove> selectWmsMoveJoinList(WmsMove wmsMove);
/** /**
* *
@ -102,4 +110,5 @@ public interface IWmsMoveService
* @return * @return
*/ */
public int moveInstock(WmsMoveVo wmsMoveVo); public int moveInstock(WmsMoveVo wmsMoveVo);
} }

@ -14,6 +14,7 @@ import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.RemoteMesService; import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.wms.domain.*; import com.hw.wms.domain.*;
import com.hw.wms.domain.vo.WmsMoveApplyVo;
import com.hw.wms.domain.vo.WmsMoveVo; import com.hw.wms.domain.vo.WmsMoveVo;
import com.hw.wms.mapper.*; import com.hw.wms.mapper.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -157,28 +158,28 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
/** /**
* Join warehouse * Join warehouse,group
* *
* @param wmsMove * @param wmsMove
* @return * @return
*/ */
@Override @Override
public List<WmsMove> selectWmsMoveJoinList(WmsMove wmsMove) { public List<WmsMove> selectWmsMoveGroupJoinList(WmsMove wmsMove) {
return wmsMoveMapper.selectWmsMoveJoinList(wmsMove); return wmsMoveMapper.selectWmsMoveGroupJoinList(wmsMove);
} }
/** /**
* *
* *
* @param wmsMove * @param wmsMoveApplyVo
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int applyMove(WmsMove wmsMove) { public int applyMove(WmsMoveApplyVo wmsMoveApplyVo) {
String oriLocationCode = wmsMove.getOriLocationCode(); String oriLocationCode = wmsMoveApplyVo.getOriLocationCode();
String targetLocationCode = wmsMove.getTargetLocationCode(); String targetLocationCode = wmsMoveApplyVo.getTargetLocationCode();
if (oriLocationCode.equals(targetLocationCode)) { if (oriLocationCode.equals(targetLocationCode)) {
throw new ServiceException("原库位与目标库位不能相同"); throw new ServiceException("原库位与目标库位不能相同");
} }
@ -207,9 +208,11 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
} }
WmsBaseWarehouse baseWareHouse = wmsBaseWarehouseMapper. WmsBaseWarehouse baseWareHouse = wmsBaseWarehouseMapper.
selectWmsBaseWarehouseByWarehouseId(wmsMove.getWarehouseId()); selectWmsBaseWarehouseByWarehouseId(wmsMoveApplyVo.getWarehouseId());
String warehouseInstockType = baseWareHouse.getWarehouseInstockType(); String warehouseInstockType = baseWareHouse.getWarehouseInstockType();
List<WmsMoveDetail> toInsertedMoveDetails = new ArrayList<>(); List<WmsMove> toInsertedMoves = new ArrayList<>();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
if (warehouseInstockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) {//如果是原材料 if (warehouseInstockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) {//如果是原材料
WmsRawStock queryRawStock = new WmsRawStock(); WmsRawStock queryRawStock = new WmsRawStock();
queryRawStock.setLocationCode(oriLocationCode); queryRawStock.setLocationCode(oriLocationCode);
@ -232,7 +235,7 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
throw new ServiceException("目标库位有库存,不能进行移库"); throw new ServiceException("目标库位有库存,不能进行移库");
} }
toInsertedMoveDetails = getMoveDetailsByRawStocks(wmsRawStocks); toInsertedMoves = getMovesByRawStocks(wmsRawStocks, wmsMoveApplyVo, userName, currentDate);
} else {//如果是成品 } else {//如果是成品
WmsProductStock queryProductStock = new WmsProductStock(); WmsProductStock queryProductStock = new WmsProductStock();
queryProductStock.setLocationCode(oriLocationCode); queryProductStock.setLocationCode(oriLocationCode);
@ -255,11 +258,9 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
throw new ServiceException("目标库位有库存,不能进行移库"); throw new ServiceException("目标库位有库存,不能进行移库");
} }
toInsertedMoveDetails = getMoveDetailsByProductStocks(productStocks); toInsertedMoves = getMovesByProductStocks(productStocks, wmsMoveApplyVo, userName, currentDate);
} }
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK); oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK);
oriLocation.setUpdateTime(currentDate); oriLocation.setUpdateTime(currentDate);
oriLocation.setUpdateBy(userName); oriLocation.setUpdateBy(userName);
@ -270,47 +271,78 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
targetLocation.setUpdateBy(userName); targetLocation.setUpdateBy(userName);
wmsBaseLocationMapper.updateWmsBaseLocation(targetLocation); wmsBaseLocationMapper.updateWmsBaseLocation(targetLocation);
wmsMove.setTaskCode(Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode)); int rows = wmsMoveMapper.batchWmsMove(toInsertedMoves);
return rows;
}
private List<WmsMove> getMovesByRawStocks(List<WmsRawStock> wmsRawStocks, WmsMoveApplyVo wmsMoveApplyVo,
String userName, Date currentDate) {
List<WmsMove> wmsMoveList = new ArrayList<>();
String taskCode = Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode);
wmsRawStocks.forEach(wmsRawStock -> {
WmsMove wmsMove = new WmsMove();
wmsMove.setInstockBatch(wmsRawStock.getInstockBatch());
wmsMove.setMaterialId(wmsRawStock.getMaterialId());
wmsMove.setWarehouseId(wmsRawStock.getWarehouseId());
wmsMove.setOriLocationCode(wmsMoveApplyVo.getOriLocationCode());
wmsMove.setTargetLocationCode(wmsMoveApplyVo.getTargetLocationCode());
wmsMove.setPlanAmount(wmsRawStock.getTotalAmount());
wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE);
wmsMove.setTaskCode(taskCode);
wmsMove.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); wmsMove.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL); wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL);
wmsMove.setMoveType(WmsConstants.WMS_MOVEMERGE_TYPE_MOVE); wmsMove.setMoveType(wmsMoveApplyVo.getMoveType());
wmsMove.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); wmsMove.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsMove.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE); wmsMove.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
wmsMove.setApplyBy(userName); wmsMove.setApplyBy(userName);
wmsMove.setApplyDate(currentDate); wmsMove.setApplyDate(currentDate);
int rows = wmsMoveMapper.insertWmsMove(wmsMove);
batchInsertMoveDetails(toInsertedMoveDetails, wmsMove.getMoveId(), userName, currentDate);
return rows;
}
public List<WmsMoveDetail> getMoveDetailsByRawStocks(List<WmsRawStock> wmsRawStocks) { wmsMoveList.add(wmsMove);
List<WmsMoveDetail> wmsMoveDetailList = new ArrayList<>();
wmsRawStocks.forEach(wmsRawStock -> {
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail();
wmsMoveDetail.setInstockBatch(wmsRawStock.getInstockBatch());
wmsMoveDetail.setMaterialId(wmsRawStock.getMaterialId());
wmsMoveDetail.setPlanAmount(wmsRawStock.getTotalAmount());
wmsMoveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE);
wmsMoveDetailList.add(wmsMoveDetail);
}); });
return wmsMoveDetailList; return wmsMoveList;
} }
public List<WmsMoveDetail> getMoveDetailsByProductStocks(List<WmsProductStock> wmsProductStocks) { private List<WmsMove> getMovesByProductStocks(List<WmsProductStock> wmsProductStocks, WmsMoveApplyVo wmsMoveApplyVo,
List<WmsMoveDetail> wmsMoveDetailList = new ArrayList<>(); String userName, Date currentDate) {
List<WmsMove> wmsMoveList = new ArrayList<>();
String taskCode = Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode);
wmsProductStocks.forEach(wmsProductStock -> { wmsProductStocks.forEach(wmsProductStock -> {
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail(); WmsMove wmsMove = new WmsMove();
wmsMoveDetail.setInstockBatch(wmsProductStock.getProductBatch()); wmsMove.setInstockBatch(wmsProductStock.getProductBatch());
wmsMoveDetail.setMaterialId(wmsProductStock.getProductId()); wmsMove.setWarehouseId(wmsProductStock.getWarehouseId());
wmsMoveDetail.setPlanAmount(wmsProductStock.getTotalAmount()); wmsMove.setOriLocationCode(wmsMoveApplyVo.getOriLocationCode());
wmsMoveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE); wmsMove.setTargetLocationCode(wmsMoveApplyVo.getTargetLocationCode());
wmsMoveDetailList.add(wmsMoveDetail); wmsMove.setMaterialId(wmsProductStock.getProductId());
wmsMove.setPlanAmount(wmsProductStock.getTotalAmount());
wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE);
wmsMove.setTaskCode(taskCode);
wmsMove.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL);
wmsMove.setMoveType(wmsMoveApplyVo.getMoveType());
wmsMove.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsMove.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
wmsMove.setApplyBy(userName);
wmsMove.setApplyDate(currentDate);
wmsMoveList.add(wmsMove);
}); });
return wmsMoveDetailList; return wmsMoveList;
} }
/**
* Join material,warehouse
*
* @param wmsMove
* @return
*/
@Override
public List<WmsMove> selectWmsMoveJoinList(WmsMove wmsMove) {
return wmsMoveMapper.selectWmsMoveJoinList(wmsMove);
}
public void batchInsertMoveDetails(List<WmsMoveDetail> wmsMoveDetailList, Long moveId, String userName, Date currentDate) { public void batchInsertMoveDetails(List<WmsMoveDetail> wmsMoveDetailList, Long moveId, String userName, Date currentDate) {
wmsMoveDetailList.forEach(moveDetail -> { wmsMoveDetailList.forEach(moveDetail -> {
moveDetail.setMoveId(moveId); moveDetail.setMoveId(moveId);
@ -341,7 +373,7 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int moveOutstock(WmsMoveVo wmsMoveVo) { public int moveOutstock(WmsMoveVo wmsMoveVo) {
Long moveId = wmsMoveVo.getMoveId(); String taskCode = wmsMoveVo.getTaskCode();
String materialBarcode = wmsMoveVo.getMaterialBarcode(); String materialBarcode = wmsMoveVo.getMaterialBarcode();
String locationCode = wmsMoveVo.getLocationCode(); String locationCode = wmsMoveVo.getLocationCode();
BigDecimal applyQty = wmsMoveVo.getApplyQty(); BigDecimal applyQty = wmsMoveVo.getApplyQty();
@ -355,6 +387,13 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
throw new ServiceException("物料编码有误"); throw new ServiceException("物料编码有误");
} }
String batchFlag = baseBarcodeInfo.getBatchFlag();
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
if (applyQty.compareTo(BigDecimal.ONE) > 0) {
throw new ServiceException("出库数量需等于1");
}
}
WmsBaseLocation oriLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); WmsBaseLocation oriLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (oriLocation == null) { if (oriLocation == null) {
throw new ServiceException("库位编码有误"); throw new ServiceException("库位编码有误");
@ -362,74 +401,109 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
String userName = SecurityUtils.getUsername(); String userName = SecurityUtils.getUsername();
Date currentDate = new Date(); Date currentDate = new Date();
String batchCode = baseBarcodeInfo.getBatchCode();
String barcodeType = baseBarcodeInfo.getBarcodeType();
if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料 WmsMove queryMove = new WmsMove();
moveOutUpdateRawStock(locationCode, baseBarcodeInfo.getBatchCode(), applyQty, userName, currentDate); queryMove.setTaskCode(taskCode);
} else {//如果是成品 // queryMove.setInstockBatch(batchCode);
moveOutUpdateProductStock(locationCode, baseBarcodeInfo.getBatchCode(), applyQty, userName, currentDate); queryMove.setOriLocationCode(locationCode);
} List<WmsMove> wmsMoveList = wmsMoveMapper.selectWmsMoveList(queryMove);
if (wmsMoveList == null || wmsMoveList.isEmpty()) {
WmsMoveDetail queryMoveDetail = new WmsMoveDetail();
queryMoveDetail.setMoveId(moveId);
List<WmsMoveDetail> wmsMoveDetailList = wmsMoveDetailMapper.selectWmsMoveDetailList(queryMoveDetail);
if (wmsMoveDetailList == null || wmsMoveDetailList.isEmpty()) {
throw new ServiceException("没有此移库信息"); throw new ServiceException("没有此移库信息");
} }
Map<String, WmsMoveDetail> moveDetailMap = wmsMoveDetailList.stream(). WmsMove wmsMove = wmsMoveList.stream().filter(move ->
collect(Collectors.toMap(WmsMoveDetail::getInstockBatch, wmsMoveDetail -> wmsMoveDetail)); move.getInstockBatch().equals(batchCode)).findFirst().get();
if (wmsMove == null) {
WmsMoveDetail moveDetail = moveDetailMap.get(baseBarcodeInfo.getBatchCode());
if (moveDetail == null) {
throw new ServiceException("没有此移库信息"); throw new ServiceException("没有此移库信息");
} }
String executeStatus = moveDetail.getExecuteStatus(); String executeStatus = wmsMove.getExecuteStatus();
BigDecimal planAmount = moveDetail.getPlanAmount();
BigDecimal realAmount = moveDetail.getRealAmount() == null ? BigDecimal.ZERO : moveDetail.getRealAmount();
BigDecimal remainingAmount = planAmount.subtract(realAmount);
if (executeStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH)) { if (executeStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH)) {
throw new ServiceException("已经移库出库完成,无需再出库"); throw new ServiceException("此批次已移库出库完成,不能再出库");
} }
if (executeStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) { if (executeStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) {
throw new ServiceException("已经移库入库完成,无需再出库"); throw new ServiceException("此批次已移库入库完成,不能再出库");
} }
if (applyQty.compareTo(remainingAmount) > 0) { BigDecimal planAmount = wmsMove.getPlanAmount();
throw new ServiceException("数量不能大于" + remainingAmount); BigDecimal realOutstockAmount = wmsMove.getRealOutstockAmount();
BigDecimal updateRealOutstockAmount = realOutstockAmount.add(applyQty);
if (updateRealOutstockAmount.compareTo(planAmount) > 0) {
throw new ServiceException("数量不能大于" + planAmount.subtract(realOutstockAmount));
} }
WmsMove wmsMove = wmsMoveMapper.selectWmsMoveByMoveId(moveId); WmsMoveDetail existedMoveDetail = wmsMoveDetailMapper.selectWmsMoveDetailByMoveIdAndBarCode(wmsMove.getMoveId(), materialBarcode);
if(!locationCode.equals(wmsMove.getOriLocationCode())){ if (existedMoveDetail != null) {
throw new ServiceException("库位错误"); throw new ServiceException("此物料条码已经出库,不能重复出库");
} }
String moveExecuteStatus = WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH; String barcodeType = baseBarcodeInfo.getBarcodeType();
if(moveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE)){ if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料
moveDetail.setExecuteTime(currentDate); moveOutUpdateRawStock(locationCode, batchCode, applyQty, userName, currentDate);
moveDetail.setExecutePerson(userName); } else {//如果是成品
moveOutUpdateProductStock(locationCode, batchCode, applyQty, userName, currentDate);
} }
if (applyQty.compareTo(remainingAmount) < 0) {
moveDetail.setRealAmount(applyQty.subtract(realAmount));
moveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING);
} else { //插入移库合库明细记录
moveDetail.setRealAmount(applyQty.subtract(realAmount)); insertMoveDetail(wmsMove.getMoveId(), baseBarcodeInfo, applyQty, userName, currentDate);
moveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH);
for (WmsMoveDetail wmsMoveDetail : wmsMoveDetailList) { //更新移库合库记录,并判断是否解锁库位
if (!wmsMoveDetail.getMoveDetailId().equals(moveDetail.getMoveDetailId())) { outstockUpdateWmsMove(wmsMove, wmsMoveList, oriLocation, applyQty, userName, currentDate);
if (wmsMoveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE)
|| wmsMoveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING)) { return 1;
moveExecuteStatus = WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING; }
public void insertMoveDetail(Long moveId, MesBaseBarcodeInfo baseBarcodeInfo, BigDecimal applyQty,
String userName, Date currentDate) {
WmsMoveDetail toInsertedWmsMoveDetail = new WmsMoveDetail();
toInsertedWmsMoveDetail.setMoveId(moveId);
toInsertedWmsMoveDetail.setMaterialBarcode(baseBarcodeInfo.getBarcodeInfo());
toInsertedWmsMoveDetail.setInstockBatch(baseBarcodeInfo.getBatchCode());
toInsertedWmsMoveDetail.setMaterialId(baseBarcodeInfo.getMaterialId());
toInsertedWmsMoveDetail.setPlanAmount(applyQty);
toInsertedWmsMoveDetail.setRealAmount(applyQty);
toInsertedWmsMoveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH);
toInsertedWmsMoveDetail.setExecutePerson(userName);
toInsertedWmsMoveDetail.setExecuteTime(currentDate);
wmsMoveDetailMapper.insertWmsMoveDetail(toInsertedWmsMoveDetail);
}
/**
*
*
* @param wmsMove
* @param wmsMoveList
* @param oriLocation
* @param applyQty
* @param userName
* @param currentDate
*/
public void outstockUpdateWmsMove(WmsMove wmsMove, List<WmsMove> wmsMoveList, WmsBaseLocation oriLocation,
BigDecimal applyQty, String userName, Date currentDate) {
BigDecimal planAmount = wmsMove.getPlanAmount();
BigDecimal realOutstockAmount = wmsMove.getRealOutstockAmount();
BigDecimal remainingAmount = planAmount.subtract(realOutstockAmount);
if (applyQty.compareTo(remainingAmount) < 0) {
wmsMove.setRealOutstockAmount(realOutstockAmount.add(applyQty));
wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING);
} else {
wmsMove.setRealOutstockAmount(planAmount);
wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH);
boolean allOustocked = true;//用来判断原库位是否都已出库完成
for (WmsMove move : wmsMoveList) {
if (!move.getMoveId().equals(wmsMove.getMoveId())) {
if (move.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE)
|| move.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING)) {
allOustocked = false;
} }
} }
} }
//解锁库位 //如果都已出库完成,解锁库位
if (moveExecuteStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH)){ if (allOustocked) {
oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL); oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL);
oriLocation.setUpdateBy(userName); oriLocation.setUpdateBy(userName);
oriLocation.setUpdateTime(currentDate); oriLocation.setUpdateTime(currentDate);
@ -437,21 +511,15 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
} }
} }
if (wmsMove.getBeginTime() == null) {
wmsMoveDetailMapper.updateWmsMoveDetail(moveDetail);
if (!wmsMove.getExecuteStatus().equals(moveExecuteStatus)) {
if (wmsMove.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE)) {
wmsMove.setBeginTime(currentDate); wmsMove.setBeginTime(currentDate);
} }
wmsMove.setExecuteStatus(moveExecuteStatus);
wmsMoveMapper.updateWmsMove(wmsMove);
}
return 1; wmsMove.setUpdateDate(currentDate);
wmsMove.setUpdateBy(userName);
wmsMoveMapper.updateWmsMove(wmsMove);
} }
public void moveOutUpdateRawStock(String locationCode, String batchCode, BigDecimal applyQty, public void moveOutUpdateRawStock(String locationCode, String batchCode, BigDecimal applyQty,
String userName, Date currentDate) { String userName, Date currentDate) {
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, batchCode); WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, batchCode);
@ -505,7 +573,6 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
wmsProductStock.setUpdateDate(currentDate); wmsProductStock.setUpdateDate(currentDate);
wmsProductStockMapper.updateWmsProductStock(wmsProductStock); wmsProductStockMapper.updateWmsProductStock(wmsProductStock);
} }
} }
@ -516,7 +583,7 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
* @return * @return
*/ */
public int moveInstock(WmsMoveVo wmsMoveVo) { public int moveInstock(WmsMoveVo wmsMoveVo) {
Long moveId = wmsMoveVo.getMoveId(); String taskCode = wmsMoveVo.getTaskCode();
String materialBarcode = wmsMoveVo.getMaterialBarcode(); String materialBarcode = wmsMoveVo.getMaterialBarcode();
String locationCode = wmsMoveVo.getLocationCode(); String locationCode = wmsMoveVo.getLocationCode();
BigDecimal applyQty = wmsMoveVo.getApplyQty(); BigDecimal applyQty = wmsMoveVo.getApplyQty();
@ -530,228 +597,178 @@ public class WmsMoveServiceImpl implements IWmsMoveService {
throw new ServiceException("物料编码有误"); throw new ServiceException("物料编码有误");
} }
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); WmsBaseLocation targetLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
if (location == null) { if (targetLocation == null) {
throw new ServiceException("库位编码有误"); throw new ServiceException("库位编码有误");
} }
String userName = SecurityUtils.getUsername(); String userName = SecurityUtils.getUsername();
Date currentDate = new Date(); Date currentDate = new Date();
String barcodeType = baseBarcodeInfo.getBarcodeType(); String batchCode = baseBarcodeInfo.getBatchCode();
String moveExecuteStatus = "";
WmsMoveDetail queryMoveDetail = new WmsMoveDetail(); WmsMove queryMove = new WmsMove();
queryMoveDetail.setMoveId(moveId); queryMove.setTaskCode(taskCode);
List<WmsMoveDetail> moveDetails = wmsMoveDetailMapper.selectWmsMoveDetailList(queryMoveDetail); // queryMove.setInstockBatch(batchCode);
if (moveDetails == null || moveDetails.isEmpty()) { queryMove.setTargetLocationCode(locationCode);
throw new ServiceException("没有移库出库记录"); List<WmsMove> wmsMoveList = wmsMoveMapper.selectWmsMoveList(queryMove);
if (wmsMoveList == null || wmsMoveList.isEmpty()) {
throw new ServiceException("没有此移库信息");
} }
Map<String, WmsMoveDetail> moveDetailMap = moveDetails.stream(). WmsMove wmsMove = wmsMoveList.stream().filter(move ->
collect(Collectors.toMap(WmsMoveDetail::getMaterialBarcode, wmsMoveDetail -> wmsMoveDetail)); move.getInstockBatch().equals(batchCode)).findFirst().get();
if (wmsMove == null) {
throw new ServiceException("没有此移库信息");
}
WmsMoveDetail wmsMoveDetail = moveDetailMap.get(materialBarcode); String executeStatus = wmsMove.getExecuteStatus();
if (wmsMoveDetail == null) { if (executeStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) {
throw new ServiceException("没有移库出库记录"); throw new ServiceException("此批次已移库入库完成,不能再入库");
} }
moveDetailMap.remove(wmsMoveDetail); BigDecimal planAmount = wmsMove.getPlanAmount();
BigDecimal realInstockAmount = wmsMove.getRealInstockAmount();
BigDecimal updateRealInstockAmount = realInstockAmount.add(applyQty);
if (wmsMoveDetail.getPlanAmount().compareTo(applyQty) != 0) { if (updateRealInstockAmount.compareTo(planAmount) > 0) {
throw new ServiceException("入库数量需等于" + wmsMoveDetail.getPlanAmount()); throw new ServiceException("数量不能大于" + planAmount.subtract(realInstockAmount));
} }
if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料 WmsMoveDetail existedMoveDetail = wmsMoveDetailMapper.selectWmsMoveDetailByMoveIdAndBarCode(wmsMove.getMoveId(), materialBarcode);
// moveExecuteStatus = moveInUpdateRawStock(Map < String, WmsMoveDetail > moveDetailMap); if (existedMoveDetail == null) {
} else {//如果是成品 throw new ServiceException("此物料条码还未移库出库,不能移库入库");
// moveExecuteStatus = updateProductStock(locationCode, baseBarcodeInfo.getBatchCode(), applyQty, userName, currentDate, location);
} }
if (existedMoveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) {
if (moveExecuteStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) { throw new ServiceException("此物料条码已移库入库,不能重复入库");
WmsMove wmsMove = wmsMoveMapper.selectWmsMoveByMoveId(moveId); }
wmsMove.setEndTime(currentDate); if (!existedMoveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH)) {
wmsMove.setExecuteStatus(moveExecuteStatus); throw new ServiceException("此物料条码还未移库出库,不能移库入库");
wmsMoveMapper.updateWmsMove(wmsMove); }
if (existedMoveDetail.getRealAmount().compareTo(applyQty) != 0) {
throw new ServiceException("数量需等于" + existedMoveDetail.getRealAmount());
} }
wmsMoveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH); String barcodeType = baseBarcodeInfo.getBarcodeType();
wmsMoveDetail.setExecuteEndTime(currentDate); //更新库存
wmsMoveDetail.setUpdateBy(userName); if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料
wmsMoveDetail.setUpdateDate(currentDate); moveInUpdateRawStock(targetLocation, baseBarcodeInfo, applyQty, userName, currentDate);
} else {//如果是成品
return wmsMoveDetailMapper.updateWmsMoveDetail(wmsMoveDetail); moveInUpdateProductStock(targetLocation, baseBarcodeInfo, applyQty, userName, currentDate);
} }
//更新移库合库明细记录
existedMoveDetail.setRealInstockAmount(applyQty);
existedMoveDetail.setExecuteEndTime(currentDate);
existedMoveDetail.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH);
existedMoveDetail.setUpdateDate(currentDate);
existedMoveDetail.setUpdateBy(userName);
existedMoveDetail.setRealInstockAmount(applyQty);
wmsMoveDetailMapper.updateWmsMoveDetail(existedMoveDetail);
public String moveInUpdateRawStock(Map<String, WmsMoveDetail> moveDetailMap, String locationCode, //更新移库合库记录,并判断是否解锁库位
MesBaseBarcodeInfo mesBaseBarcodeInfo) { instockUpdateWmsMove(wmsMove, wmsMoveList, targetLocation, applyQty, userName, currentDate);
String moveExecuteStatus = WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH;
//先判断是否已全部出库完成 return 1;
if (moveDetailMap != null || !moveDetailMap.isEmpty()) {
for (Map.Entry<String, WmsMoveDetail> wmsMoveDetailEntry : moveDetailMap.entrySet()) {
WmsMoveDetail wmsMoveDetail = wmsMoveDetailEntry.getValue();
if (!wmsMoveDetail.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) {
// moveExecuteStatus = WmsConstants.
}
}
} }
public void moveInUpdateRawStock(WmsBaseLocation location, MesBaseBarcodeInfo mesBaseBarcodeInfo,
BigDecimal applyQty, String userName, Date currentDate) {
String batchCode = mesBaseBarcodeInfo.getBatchCode(); String batchCode = mesBaseBarcodeInfo.getBatchCode();
String locationCode = location.getLocationCode();
WmsRawStock rawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, batchCode); WmsRawStock rawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, batchCode);
if (rawStock != null) { if (rawStock != null) {
// rawStock.setTotalAmount(); rawStock.setTotalAmount(rawStock.getTotalAmount().add(applyQty));
// rawStock.setUpdateDate(); rawStock.setUpdateDate(currentDate);
// rawStock.setUpdateBy(); rawStock.setUpdateBy(userName);
wmsRawStockMapper.updateWmsRawStock(rawStock); wmsRawStockMapper.updateWmsRawStock(rawStock);
} else { } else {
rawStock = new WmsRawStock(); rawStock = new WmsRawStock();
// rawStock.setTotalAmount(); rawStock.setTotalAmount(applyQty);
// rawStock.setLocationCode(); rawStock.setLocationCode(locationCode);
// rawStock.setInstockBatch(); rawStock.setInstockBatch(mesBaseBarcodeInfo.getBatchCode());
// rawStock.setWarehouseId(); rawStock.setWarehouseId(location.getWarehouseId());
// rawStock.setWarehouseFloor(); rawStock.setWarehouseFloor(location.getWarehouseFloor());
// rawStock.setStockType(); rawStock.setStockType(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW);
// rawStock.setMaterialId(); rawStock.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
// rawStock.setInstockDate();//条码中的入库时间 rawStock.setInstockDate(mesBaseBarcodeInfo.getAcceptedDate());//条码中的入库时间
// rawStock.setLastOutstockTime(); rawStock.setLastOutstockTime(mesBaseBarcodeInfo.getLastOutstockDate());
// rawStock.setQualityStatus(); // rawStock.setQualityStatus();
// rawStock.setCompleteFlag(); rawStock.setCompleteFlag(WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAG_YES);
// rawStock.setCreateDate(); rawStock.setCreateDate(currentDate);
// rawStock.setCreateBy(); rawStock.setCreateBy(userName);
wmsRawStockMapper.insertWmsRawStock(rawStock); wmsRawStockMapper.insertWmsRawStock(rawStock);
} }
return moveExecuteStatus;
} }
/** public void moveInUpdateProductStock(WmsBaseLocation location, MesBaseBarcodeInfo mesBaseBarcodeInfo,
* BigDecimal applyQty, String userName, Date currentDate) {
* String materialBarcode = mesBaseBarcodeInfo.getBarcodeInfo();
* @param wmsMoveVo String locationCode = location.getLocationCode();
* @return
*/
/* @Override
@Transactional(rollbackFor = Exception.class)
public int moveOutstock(WmsMoveVo wmsMoveVo) {
String materialBarcode = wmsMoveVo.getMaterialBarcode();
String locationCode = wmsMoveVo.getLocationCode();
BigDecimal applyQty = wmsMoveVo.getApplyQty();
if (applyQty.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("出库数量需大于0");
}
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
String batchFlag = baseBarcodeInfo.getBatchFlag(); WmsProductStock productStock = new WmsProductStock();
if (!batchFlag.equals(MesConstants.IS_BATCH)) { productStock.setTotalAmount(applyQty);
if (applyQty.compareTo(BigDecimal.ONE) > 0) { productStock.setLocationCode(locationCode);
throw new ServiceException("出库数量需等于1"); productStock.setProductBatch(materialBarcode);
} productStock.setWarehouseId(location.getWarehouseId());
} productStock.setWarehouseFloor(location.getWarehouseFloor());
productStock.setStockType(mesBaseBarcodeInfo.getBarcodeType());
WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); productStock.setProductId(mesBaseBarcodeInfo.getMaterialId());
if (location == null) { productStock.setInstockDate(mesBaseBarcodeInfo.getAcceptedDate());//条码中的入库时间
throw new ServiceException("库位编码有误"); productStock.setPlanCode(mesBaseBarcodeInfo.getPlanCode());
productStock.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode());
productStock.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId());
productStock.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode());
// rawStock.setQualityStatus();
productStock.setCreateDate(currentDate);
productStock.setCreateBy(userName);
wmsProductStockMapper.insertWmsProductStock(productStock);
} }
String userName = SecurityUtils.getUsername(); /**
Date currentDate = new Date(); *
*
String barcodeType = baseBarcodeInfo.getBarcodeType(); * @param wmsMove
if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {//如果是原材料 * @param wmsMoveList
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, baseBarcodeInfo.getBatchCode()); * @param oriLocation
if (wmsRawStock == null) { * @param applyQty
throw new ServiceException("无库存信息"); * @param userName
} * @param currentDate
BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount(); */
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); public void instockUpdateWmsMove(WmsMove wmsMove, List<WmsMove> wmsMoveList, WmsBaseLocation targetLocation,
BigDecimal frozenAmount = wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount(); BigDecimal applyQty, String userName, Date currentDate) {
BigDecimal availableAmount = totalAmount.subtract(occupyAmount).subtract(frozenAmount); BigDecimal planAmount = wmsMove.getPlanAmount();
if (applyQty.compareTo(availableAmount) > 0) { BigDecimal realInstockAmount = wmsMove.getRealInstockAmount();
throw new ServiceException("移库出库数量不能大于" + availableAmount); BigDecimal remainingAmount = planAmount.subtract(realInstockAmount);
} if (applyQty.compareTo(remainingAmount) < 0) {
wmsMove.setRealInstockAmount(realInstockAmount.add(applyQty));
totalAmount = totalAmount.subtract(applyQty);
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
wmsRawStockMapper.deleteWmsRawStockByRawStockId(wmsRawStock.getRawStockId());
} else { } else {
wmsRawStock.setTotalAmount(totalAmount); wmsMove.setRealInstockAmount(planAmount);
wmsRawStock.setUpdateBy(userName); wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH);
wmsRawStock.setUpdateDate(currentDate); wmsMove.setEndTime(currentDate);
wmsRawStockMapper.updateWmsRawStock(wmsRawStock); boolean allInstocked = true;//用来判断原库位是否都已入库完成
for (WmsMove move : wmsMoveList) {
if (!move.getMoveId().equals(wmsMove.getMoveId())) {
if (!move.getExecuteStatus().equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) {
allInstocked = false;
} }
} else {//如果是成品
WmsProductStock wmsProductStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
if (wmsProductStock == null || !wmsProductStock.getLocationCode().equals(locationCode)) {
throw new ServiceException("无此库存信息");
} }
BigDecimal totalAmount = wmsProductStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsProductStock.getTotalAmount();
BigDecimal occupyAmount = wmsProductStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsProductStock.getOccupyAmount();
BigDecimal frozenAmount = wmsProductStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsProductStock.getFrozenAmount();
BigDecimal availableAmount = totalAmount.subtract(occupyAmount).subtract(frozenAmount);
if (applyQty.compareTo(availableAmount) > 0) {
throw new ServiceException("移库出库数量不能大于" + availableAmount);
} }
totalAmount = totalAmount.subtract(applyQty);
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { //如果都已入库完成,解锁库位
wmsProductStockMapper.deleteWmsProductStockByProductStockId(wmsProductStock.getProductStockId()); if (allInstocked) {
} else { targetLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL);
wmsProductStock.setTotalAmount(totalAmount); targetLocation.setUpdateBy(userName);
wmsProductStock.setUpdateBy(userName); targetLocation.setUpdateTime(currentDate);
wmsProductStock.setUpdateDate(currentDate); wmsBaseLocationMapper.updateWmsBaseLocation(targetLocation);
wmsProductStockMapper.updateWmsProductStock(wmsProductStock);
} }
} }
WmsMoveDetail queryMoveDetail = new WmsMoveDetail(); wmsMove.setUpdateDate(currentDate);
queryMoveDetail.setMaterialBarcode(materialBarcode); wmsMove.setUpdateBy(userName);
queryMoveDetail.setMoveExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);//移库合库记录执行状态正在执行中的,对于已完成的可以重复移库合库 wmsMoveMapper.updateWmsMove(wmsMove);
List<WmsMoveDetail> wmsMoveDetails = wmsMoveDetailMapper.selectWmsMoveDetailList(queryMoveDetail);
if (wmsMoveDetails != null && !wmsMoveDetails.isEmpty()) {
throw new ServiceException("已经有此物料信息的移库记录");
} }
WmsMove wmsMove = new WmsMove();
wmsMove.setTaskCode(Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode));
wmsMove.setWarehouseId(location.getWarehouseId());
wmsMove.setOriLocationCode(locationCode);
wmsMove.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL);
wmsMove.setMoveType(WmsConstants.WMS_MOVEMERGE_TYPE_MOVE);
wmsMove.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsMove.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
wmsMove.setApplyBy(userName);
wmsMove.setApplyDate(currentDate);
wmsMove.setBeginTime(currentDate);
wmsMoveMapper.insertWmsMove(wmsMove);
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail();
wmsMoveDetail.setMoveId(wmsMove.getMoveId());
wmsMoveDetail.setLocationCode(locationCode);
wmsMoveDetail.setMaterialBarcode(materialBarcode);
wmsMoveDetail.setInstockBatch(baseBarcodeInfo.getBatchCode());
wmsMoveDetail.setMaterialId(baseBarcodeInfo.getMaterialId());
wmsMoveDetail.setPlanAmount(applyQty);
wmsMoveDetail.setRealAmount(applyQty);
wmsMoveDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsMoveDetail.setExecutePerson(userName);
wmsMoveDetail.setExecuteTime(currentDate);
wmsMoveDetail.setMoveDetailType(WmsConstants.WMS_MOVE_DETAIL_TYPE_OUT);
wmsMoveDetail.setCreateBy(userName);
wmsMoveDetail.setCreateDate(currentDate);
wmsMoveDetailMapper.insertWmsMoveDetail(wmsMoveDetail);
return 1;
}*/
} }

@ -105,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialId != null">material_id = #{materialId},</if> <if test="materialId != null">material_id = #{materialId},</if>
<if test="planAmount != null">plan_amount = #{planAmount},</if> <if test="planAmount != null">plan_amount = #{planAmount},</if>
<if test="realAmount != null">real_amount = #{realAmount},</if> <if test="realAmount != null">real_amount = #{realAmount},</if>
<if test="realInstockAmount != null">real_instock_amount = #{realInstockAmount},</if>
<if test="executeStatus != null and executeStatus != ''">execute_status = #{executeStatus},</if> <if test="executeStatus != null and executeStatus != ''">execute_status = #{executeStatus},</if>
<if test="executePerson != null">execute_person = #{executePerson},</if> <if test="executePerson != null">execute_person = #{executePerson},</if>
<if test="executeTime != null">execute_time = #{executeTime},</if> <if test="executeTime != null">execute_time = #{executeTime},</if>
@ -135,9 +136,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWmsMoveDetailByMoveIdAndBatchCode" resultMap="WmsMoveDetailResult"> <select id="selectWmsMoveDetailByMoveIdAndBarCode" resultMap="WmsMoveDetailResult">
<include refid="selectWmsMoveDetailVo"/> <include refid="selectWmsMoveDetailVo"/>
where move_id = #{moveId} and instock_batch = #{instockBatch} where move_id = #{moveId} and material_barcode = #{materialBarcode}
</select> </select>
<sql id="selectWmsMoveDetailJoinVo"> <sql id="selectWmsMoveDetailJoinVo">
@ -167,4 +168,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
</mapper> </mapper>

@ -10,6 +10,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="warehouseId" column="warehouse_id" /> <result property="warehouseId" column="warehouse_id" />
<result property="oriLocationCode" column="ori_location_code" /> <result property="oriLocationCode" column="ori_location_code" />
<result property="targetLocationCode" column="target_location_code" /> <result property="targetLocationCode" column="target_location_code" />
<result property="instockBatch" column="instock_batch" />
<result property="materialId" column="material_id" />
<result property="planAmount" column="plan_amount" />
<result property="realOutstockAmount" column="real_outstock_amount" />
<result property="realInstockAmount" column="real_instock_amount" />
<result property="operationType" column="operation_type" /> <result property="operationType" column="operation_type" />
<result property="moveWay" column="move_way" /> <result property="moveWay" column="move_way" />
<result property="moveType" column="move_type" /> <result property="moveType" column="move_type" />
@ -25,7 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateDate" column="update_date" /> <result property="updateDate" column="update_date" />
<result property="beginTime" column="begin_time" /> <result property="beginTime" column="begin_time" />
<result property="endTime" column="end_time" /> <result property="endTime" column="end_time" />
<result property="warehouseName" column="warehouse_name" /> <result property="warehouseName" column="warehouse_name" />
<result property="materialName" column="material_name" />
</resultMap> </resultMap>
<resultMap id="WmsMoveWmsMoveDetailResult" type="WmsMove" extends="WmsMoveResult"> <resultMap id="WmsMoveWmsMoveDetailResult" type="WmsMove" extends="WmsMoveResult">
@ -54,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectWmsMoveVo"> <sql id="selectWmsMoveVo">
select move_id, task_code, warehouse_id, ori_location_code, target_location_code, operation_type, move_way, move_type, apply_reason, audit_reason, audit_status, execute_status, apply_by, apply_date, audit_by, audit_date, update_by, update_date, begin_time, end_time from wms_move select move_id, task_code, warehouse_id, ori_location_code, target_location_code, instock_batch, material_id, plan_amount, real_outstock_amount, real_instock_amount, operation_type, move_way, move_type, apply_reason, audit_reason, audit_status, execute_status, apply_by, apply_date, audit_by, audit_date, update_by, update_date, begin_time, end_time from wms_move
</sql> </sql>
<select id="selectWmsMoveList" parameterType="WmsMove" resultMap="WmsMoveResult"> <select id="selectWmsMoveList" parameterType="WmsMove" resultMap="WmsMoveResult">
@ -82,8 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectWmsMoveByMoveId" parameterType="Long" resultMap="WmsMoveWmsMoveDetailResult"> <select id="selectWmsMoveByMoveId" parameterType="Long" resultMap="WmsMoveWmsMoveDetailResult">
select a.move_id, a.task_code, a.warehouse_id, a.ori_location_code, a.target_location_code, a.operation_type, a.move_way, a.move_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, select a.move_id, a.task_code, a.warehouse_id, a.ori_location_code, a.target_location_code, a.instock_batch, a.material_id, a.plan_amount, a.real_outstock_amount, a.real_instock_amount, a.operation_type, a.move_way, a.move_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,
b.move_detail_id as sub_move_detail_id, b.move_id as sub_move_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.instock_batch as sub_instock_batch, b.material_id as sub_material_id, b.plan_amount as sub_plan_amount, b.real_amount as sub_real_amount, b.execute_status as sub_execute_status, b.execute_person as sub_execute_person, b.execute_time as sub_execute_time, b.execute_end_time as sub_execute_end_time, b.machine_name as sub_machine_name, 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.active_flag as sub_active_flag b.move_detail_id as sub_move_detail_id, b.move_id as sub_move_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.instock_batch as sub_instock_batch, b.material_id as sub_material_id, b.plan_amount as sub_plan_amount, b.real_amount as sub_real_amount, b.execute_status as sub_execute_status, b.execute_person as sub_execute_person, b.execute_time as sub_execute_time, b.move_detail_type as sub_move_detail_type, b.machine_name as sub_machine_name, 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.active_flag as sub_active_flag
from wms_move a from wms_move a
left join wms_move_detail b on b.move_id = a.move_id left join wms_move_detail b on b.move_id = a.move_id
where a.move_id = #{moveId} where a.move_id = #{moveId}
@ -96,6 +103,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null">warehouse_id,</if> <if test="warehouseId != null">warehouse_id,</if>
<if test="oriLocationCode != null and oriLocationCode != ''">ori_location_code,</if> <if test="oriLocationCode != null and oriLocationCode != ''">ori_location_code,</if>
<if test="targetLocationCode != null and targetLocationCode != ''">target_location_code,</if> <if test="targetLocationCode != null and targetLocationCode != ''">target_location_code,</if>
<if test="instockBatch != null">instock_batch,</if>
<if test="materialId != null">material_id,</if>
<if test="planAmount != null">plan_amount,</if>
<if test="realOutstockAmount != null">real_outstock_amount,</if>
<if test="realInstockAmount != null">real_instock_amount,</if>
<if test="operationType != null and operationType != ''">operation_type,</if> <if test="operationType != null and operationType != ''">operation_type,</if>
<if test="moveWay != null and moveWay != ''">move_way,</if> <if test="moveWay != null and moveWay != ''">move_way,</if>
<if test="moveType != null and moveType != ''">move_type,</if> <if test="moveType != null and moveType != ''">move_type,</if>
@ -117,6 +129,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null">#{warehouseId},</if> <if test="warehouseId != null">#{warehouseId},</if>
<if test="oriLocationCode != null and oriLocationCode != ''">#{oriLocationCode},</if> <if test="oriLocationCode != null and oriLocationCode != ''">#{oriLocationCode},</if>
<if test="targetLocationCode != null and targetLocationCode != ''">#{targetLocationCode},</if> <if test="targetLocationCode != null and targetLocationCode != ''">#{targetLocationCode},</if>
<if test="instockBatch != null">#{instockBatch},</if>
<if test="materialId != null">#{materialId},</if>
<if test="planAmount != null">#{planAmount},</if>
<if test="realOutstockAmount != null">#{realOutstockAmount},</if>
<if test="realInstockAmount != null">#{realInstockAmount},</if>
<if test="operationType != null and operationType != ''">#{operationType},</if> <if test="operationType != null and operationType != ''">#{operationType},</if>
<if test="moveWay != null and moveWay != ''">#{moveWay},</if> <if test="moveWay != null and moveWay != ''">#{moveWay},</if>
<if test="moveType != null and moveType != ''">#{moveType},</if> <if test="moveType != null and moveType != ''">#{moveType},</if>
@ -142,6 +159,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if> <if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="oriLocationCode != null and oriLocationCode != ''">ori_location_code = #{oriLocationCode},</if> <if test="oriLocationCode != null and oriLocationCode != ''">ori_location_code = #{oriLocationCode},</if>
<if test="targetLocationCode != null and targetLocationCode != ''">target_location_code = #{targetLocationCode},</if> <if test="targetLocationCode != null and targetLocationCode != ''">target_location_code = #{targetLocationCode},</if>
<if test="instockBatch != null">instock_batch = #{instockBatch},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="planAmount != null">plan_amount = #{planAmount},</if>
<if test="realOutstockAmount != null">real_outstock_amount = #{realOutstockAmount},</if>
<if test="realInstockAmount != null">real_instock_amount = #{realInstockAmount},</if>
<if test="operationType != null and operationType != ''">operation_type = #{operationType},</if> <if test="operationType != null and operationType != ''">operation_type = #{operationType},</if>
<if test="moveWay != null and moveWay != ''">move_way = #{moveWay},</if> <if test="moveWay != null and moveWay != ''">move_way = #{moveWay},</if>
<if test="moveType != null and moveType != ''">move_type = #{moveType},</if> <if test="moveType != null and moveType != ''">move_type = #{moveType},</if>
@ -199,18 +221,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectWmsMoveJoinVo"> <sql id="selectWmsMoveJoinVo">
select wm.move_id, wm.task_code, wm.warehouse_id, wm.ori_location_code, wm.target_location_code, wm.operation_type, wm.move_way, wm.move_type, select wm.move_id, wm.task_code, wm.warehouse_id, wm.ori_location_code, wm.target_location_code,
wm.execute_status, wm.apply_by, wm.apply_date, wm.begin_time, wm.end_time, wm.move_type,wm.instock_batch,wm.plan_amount,wm.real_outstock_amount,wm.real_instock_amount,wm.execute_status,
wbw.warehouse_name mbmi.material_name,wbw.warehouse_name
from wms_move wm left join wms_base_warehouse wbw on wm.warehouse_id = wbw.warehouse_id from wms_move wm left join mes_base_material_info mbmi on wm.material_id = mbmi.material_id
left join wms_base_warehouse wbw on wm.warehouse_id = wbw.warehouse_id
</sql> </sql>
<select id="selectWmsMoveJoinList" parameterType="WmsMove" resultMap="WmsMoveResult"> <select id="selectWmsMoveJoinList" parameterType="WmsMove" resultMap="WmsMoveResult">
<include refid="selectWmsMoveJoinVo"/> <include refid="selectWmsMoveJoinVo"/>
<where> <where>
<if test="taskCode != null and taskCode != ''"> and task_code = #{taskCode}</if>
<if test="executeStatusStr != null and executeStatusStr != ''"> and execute_status in (${executeStatusStr})</if>
</where>
</select>
<select id="selectWmsMoveGroupJoinList" parameterType="WmsMove" resultMap="WmsMoveResult">
select wm.task_code,wm.warehouse_id,wm.ori_location_code,wm.target_location_code,
wbw.warehouse_name
from wms_move wm left join wms_base_warehouse wbw on wm.warehouse_id=wbw.warehouse_id
<where>
<if test="executeStatusStr != null and executeStatusStr != ''"> and wm.execute_status in (${executeStatusStr})</if>
<if test="moveType != null and moveType != ''"> and wm.move_type = #{moveType}</if>
</where> </where>
order by wm.move_id desc group by wm.task_code,wm.warehouse_id,wm.ori_location_code,wm.target_location_code
</select> </select>
<insert id="batchWmsMove">
insert into wms_move(move_id, task_code, warehouse_id,ori_location_code,target_location_code, instock_batch, material_id, plan_amount,operation_type,move_way,move_type,audit_status, execute_status, apply_by, apply_date) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.moveId}, #{item.taskCode}, #{item.warehouseId}, #{item.oriLocationCode}, #{item.targetLocationCode}, #{item.instockBatch}, #{item.materialId}, #{item.planAmount}, #{item.operationType}, #{item.moveWay}, #{item.moveType}, #{item.auditStatus}, #{item.executeStatus}, #{item.applyBy}, #{item.applyDate})
</foreach>
</insert>
</mapper> </mapper>

Loading…
Cancel
Save