diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java index b1aa5c46..526ea6c8 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java @@ -192,4 +192,13 @@ public interface RemoteMesService { + /** + * 通过条码查询条码信息 + * + * @param dateStr 时间字符串(yyyy-MM-dd) + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/saleOrder/getRelateProductsBySaleOrderId/{saleOrderId}") + public R> getRelateProductsBySaleOrderId(@PathVariable("saleOrderId") Long saleOrderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java index eaf4659e..b560bcbf 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java @@ -105,6 +105,12 @@ public class RemoteMesFallbackFactory implements FallbackFactory autoOutstockLastPurchaseOrders(String dateStr, String source) { return R.fail("自动出库之前采购订单的物料信息失败:" + throwable.getMessage()); } + + @Override + public R> getRelateProductsBySaleOrderId(Long saleOrderId, String source) { + return R.fail("根据销售订单ID获取关联成品信息失败:" + throwable.getMessage()); + + } }; } } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java index 693df5ed..4540518a 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/WmsConstants.java @@ -153,6 +153,8 @@ public class WmsConstants { public static final String WMS_BASE_LOCATION_STATUS_MOVE_LOCK = "4";//移库锁定 public static final String WMS_BASE_LOCATION_STATUS_MERGE_LOCK = "5";//合库锁定 public static final String WMS_BASE_LOCATION_STATUS_OUT_STOCK = "6";//出库锁定 + + public static final String WMS_BASE_LOCATION_STATUS_RETURN_LOCK = "7";//退货锁定 public static final String WMS_BASE_LOCATION_STATUS_DEEP_ABNORMAL = "8";//深库位异常 public static final String WMS_BASE_LOCATION_STATUS_ABNORMAL = "9";//异常 @@ -267,4 +269,17 @@ public class WmsConstants { public static final String WMS_SAFE_FLAG_YES = "1";//安全库存,是 public static final String WMS_SAFE_FLAG_NO = "0";//安全库存,否 + + /** + * 库位深浅库位标识 + */ + public static final Long WMS_BASE_LOCATION_LOC_DEEP_BACK = 1L;//深库位 + public static final Long WMS_BASE_LOCATION_LOC_DEEP_FRONT = 2L;//浅库位 + + /** + * 库存盘点盘点类型 + */ + public static final String WMS_INVENTORY_CHECK_TYPE_MANUAL = "1";//人工 + public static final String WMS_INVENTORY_CHECK_TYPE_WCS = "2";//WCS调度 + public static final String WMS_INVENTORY_CHECK_TYPE_CTU = "3";//CTU } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesSaleOrderController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesSaleOrderController.java index af7321cf..65f07c22 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesSaleOrderController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesSaleOrderController.java @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse; import com.hw.common.core.domain.R; import com.hw.common.security.annotation.InnerAuth; import com.hw.mes.api.domain.MesBaseBarcodeInfo; +import com.hw.mes.api.domain.MesSaleOrderRelate; import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -116,4 +117,14 @@ public class MesSaleOrderController extends BaseController { } } + + /** + * 获取销售订单信息详细信息 + */ + @InnerAuth + @GetMapping(value = "/getRelateProductsBySaleOrderId/{saleOrderId}") + public R> getRelateProductsBySaleOrderId(@PathVariable("saleOrderId") Long saleOrderId) { + List list = mesSaleOrderService.getRelateProductsBySaleOrderId(saleOrderId); + return R.ok(list); + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesSaleOrderRelateMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesSaleOrderRelateMapper.java index 1ef3910b..7da2499a 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesSaleOrderRelateMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesSaleOrderRelateMapper.java @@ -85,4 +85,14 @@ public interface MesSaleOrderRelateMapper * @return 销售订单关联信息 */ public MesSaleOrderRelate selectMesSaleOrderRelateByBindBarcode(String bindBarcode); + + + /** + * 查询销售订单关联信息列表,Join product + * + * @param mesSaleOrderRelate 销售订单关联信息 + * @return 销售订单关联信息集合 + */ + public List selectMesSaleOrderRelateJoinProductList(MesSaleOrderRelate mesSaleOrderRelate); + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesSaleOrderService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesSaleOrderService.java index c7763999..cd504a35 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesSaleOrderService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesSaleOrderService.java @@ -3,6 +3,7 @@ package com.hw.mes.service; import java.util.List; import com.hw.mes.api.domain.MesBaseBarcodeInfo; +import com.hw.mes.api.domain.MesSaleOrderRelate; import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo; import com.hw.mes.domain.MesSaleOrder; @@ -76,4 +77,11 @@ public interface IMesSaleOrderService * @return */ public boolean transferSaleOrders(MesSaleOrderTransferVo mesSaleOrderTransferVo); + + /** + * 根据relatesaleorderId查询关联的成品信息 + * @param saleOrderId + * @return + */ + public List getRelateProductsBySaleOrderId(Long saleOrderId); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java index e9351163..ae909f63 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java @@ -8,9 +8,11 @@ import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; +import com.hw.mes.api.domain.MesSaleOrderRelate; import com.hw.mes.api.domain.vo.MesBaseBarcodeInfoTransferVo; import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo; import com.hw.mes.mapper.MesBaseBarcodeInfoMapper; +import com.hw.mes.mapper.MesSaleOrderRelateMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.mapper.MesSaleOrderMapper; @@ -32,6 +34,9 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService { @Autowired private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper; + @Autowired + private MesSaleOrderRelateMapper mesSaleOrderRelateMapper; + /** * 查询销售订单信息 * @@ -165,4 +170,16 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService { return updateSize > 0; } + + /** + * 根据relatesaleorderId查询关联的成品信息 + * @param saleOrderId + * @return + */ + @Override + public List getRelateProductsBySaleOrderId(Long saleOrderId){ + MesSaleOrderRelate querySaleOrderRelate = new MesSaleOrderRelate(); + querySaleOrderRelate.setSaleOrderId(saleOrderId); + return mesSaleOrderRelateMapper.selectMesSaleOrderRelateJoinProductList(querySaleOrderRelate); + } } diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderRelateMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderRelateMapper.xml index 6fafcdef..d0790d32 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderRelateMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderRelateMapper.xml @@ -21,6 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -127,4 +131,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where bind_barcode= #{bindBarcode} limit 1 + + + + \ No newline at end of file diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java index 2f6e9cf9..9b417b3c 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java @@ -205,6 +205,7 @@ public class WmsMobileController extends BaseController { WmsRawReturn wmsRawReturn = new WmsRawReturn(); wmsRawReturn.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); wmsRawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_NOT_FINISH); + wmsRawReturn.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); List list = wmsRawReturnService.selectWmsRawReturnJoinList(wmsRawReturn); return getDataTable(list); } @@ -429,8 +430,6 @@ public class WmsMobileController extends BaseController { } - //todo:入库时校验warehousematerial,入库出库需要校验库位状态,是否是移库合库锁定等 - /** * 人工申请移库 @@ -492,6 +491,7 @@ public class WmsMobileController extends BaseController { @GetMapping(value = "/getInventoryChecks") public TableDataInfo getInventoryChecks(WmsInventoryCheck queryInventoryCheck) { startPage(); + queryInventoryCheck.setCheckType(WmsConstants.WMS_INVENTORY_CHECK_TYPE_MANUAL); List inventoryChecks = wmsInventoryCheckService.selectWmsInventoryCheckJoinList(queryInventoryCheck); return getDataTable(inventoryChecks); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java index 82f8fafe..8e39f6c3 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsInventoryCheck.java @@ -33,6 +33,9 @@ public class WmsInventoryCheck extends BaseEntity @Excel(name = "盘点状态(0待盘点", readConverterExp = "暂=无此状态") private String checkStatus; + /**盘点类型(1人工,2调度,3,CTU)*/ + private String checkType; + /** 盘点开始时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "盘点开始时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -106,6 +109,15 @@ public class WmsInventoryCheck extends BaseEntity { return checkStatus; } + + public String getCheckType() { + return checkType; + } + + public void setCheckType(String checkType) { + this.checkType = checkType; + } + public void setBeginTime(Date beginTime) { this.beginTime = beginTime; diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java index be0e3320..6986f546 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsInventoryCheckServiceImpl.java @@ -78,7 +78,7 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { * @param wmsInventoryCheckVo 进行盘点VO对象 * @return 结果 */ - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public Long insertWmsInventoryCheck(WmsInventoryCheckVo wmsInventoryCheckVo) { Long inventoryCheckId = wmsInventoryCheckVo.getInventoryCheckId(); @@ -89,6 +89,18 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); + WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId); + String warehouseInstockType = baseWarehouse.getWarehouseInstockType(); + String warehouseType = baseWarehouse.getWarehouseType(); + String inventoryCheckType = ""; + if(warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)){ + inventoryCheckType = WmsConstants.WMS_INVENTORY_CHECK_TYPE_MANUAL; + }else if(warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_AGV)){ + inventoryCheckType = WmsConstants.WMS_INVENTORY_CHECK_TYPE_WCS; + }else{ + throw new ServiceException("请选择人工仓库或agv仓库盘库"); + } + if (inventoryCheckId == null || inventoryCheckId.equals(0L) || inventoryCheckId.equals(-1L)) { WmsInventoryCheck queryInventoryCheck = new WmsInventoryCheck(); queryInventoryCheck.setWarehouseId(warehouseId); @@ -105,6 +117,7 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { WmsInventoryCheck wmsInventoryCheck = new WmsInventoryCheck(); wmsInventoryCheck.setInventoryCheckCode(Seq.getId(Seq.wmsInventoryCheckSeqType, Seq.wmsInventoryCheckSeqCode)); wmsInventoryCheck.setWarehouseId(warehouseId); + wmsInventoryCheck.setCheckType(inventoryCheckType); wmsInventoryCheck.setLocationAmount((long) locationAmount); wmsInventoryCheck.setInventoryingAmount((long) locationCodes.size()); wmsInventoryCheck.setBeginTime(currentDate); @@ -122,8 +135,7 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService { wmsInventoryCheckMapper.updateWmsInventoryCheck(toUpdatedInventoryCheck); } - WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId); - String warehouseInstockType = baseWarehouse.getWarehouseInstockType(); + List wmsInventoryCheckDetails = new ArrayList<>(); for (String locationCode : locationCodes) { diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java index 14ff7ec0..4f4fba85 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsMoveServiceImpl.java @@ -184,15 +184,41 @@ public class WmsMoveServiceImpl implements IWmsMoveService { WmsBaseWarehouse baseWareHouse = wmsBaseWarehouseMapper. selectWmsBaseWarehouseByWarehouseId(oriLocation.getWarehouseId()); - if (!baseWareHouse.getWarehouseType().equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { - throw new ServiceException("请选择人工仓库的库位进行移库"); - } - - //todo:判断有没有还没有完成从此原库位到目标库位的移库任务(预防还没修改库位状态生成此数据,连续点击问题,或者已经移库出库完成的情况不能将原库位再设置移库记录) - String warehouseInstockType = baseWareHouse.getWarehouseInstockType(); - + String warehouseType = baseWareHouse.getWarehouseType(); Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); + String warehouseInstockType = baseWareHouse.getWarehouseInstockType(); + String moveWay = "", operationType = ""; + if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_WORKBIN_AGV)) { + throw new ServiceException("立库库位移库请在调度页面进行移库"); + } else if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_AGV)) { + moveWay = WmsConstants.WMS_MOVEMERGE_WAY_AGV; + operationType = WmsConstants.MWS_OPERATION_TYPE_DISPATCHD; + + WmsMove queryMove = new WmsMove(); + queryMove.setWarehouseId(oriLocation.getWarehouseId()); + queryMove.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_EXECUTING + "," + WmsConstants.WMS_MOVE_EXECUTE_STATUS_OUTSTOCK_FINISH); + + List wmsMoveList = wmsMoveMapper.selectWmsMoveList(queryMove); + if (wmsMoveList != null && !wmsMoveList.isEmpty()) { + throw new ServiceException("有正在执行的移库任务"); + } + + } else { + moveWay = WmsConstants.WMS_MOVEMERGE_WAY_MANUAL; + operationType = WmsConstants.WMS_OPERATION_TYPE_MANUAL; + + oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK); + oriLocation.setUpdateTime(currentDate); + oriLocation.setUpdateBy(userName); + wmsBaseLocationMapper.updateWmsBaseLocation(oriLocation); + + targetLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK); + targetLocation.setUpdateTime(currentDate); + targetLocation.setUpdateBy(userName); + wmsBaseLocationMapper.updateWmsBaseLocation(targetLocation); + } + WmsMove wmsMove = new WmsMove(); String taskCode = Seq.getId(Seq.wmsMoveSeqType, Seq.wmsMoveSeqCode); @@ -201,8 +227,8 @@ public class WmsMoveServiceImpl implements IWmsMoveService { wmsMove.setOriLocationCode(wmsMoveApplyVo.getOriLocationCode()); wmsMove.setTargetLocationCode(wmsMoveApplyVo.getTargetLocationCode()); wmsMove.setExecuteStatus(WmsConstants.WMS_MOVE_EXECUTE_STATUS_TOEXECUTE); - wmsMove.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); - wmsMove.setMoveWay(WmsConstants.WMS_MOVEMERGE_WAY_MANUAL); + wmsMove.setOperationType(operationType); + wmsMove.setMoveWay(moveWay); wmsMove.setMoveType(wmsMoveApplyVo.getMoveType()); wmsMove.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); wmsMove.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE); @@ -213,6 +239,8 @@ public class WmsMoveServiceImpl implements IWmsMoveService { List toInsertedMoveDetails = new ArrayList<>(); + //判断库位状态,如果原库位和目标库位是深库位,需要判断浅库位状态,需要判断对应的浅库位有没有库存 + if (warehouseInstockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) {//如果是原材料 WmsRawStock queryRawStock = new WmsRawStock(); queryRawStock.setLocationCode(oriLocationCode); @@ -268,21 +296,70 @@ public class WmsMoveServiceImpl implements IWmsMoveService { toInsertedMoveDetails = getMoveDetailsByProductStocks(productStocks, wmsMove, userName, currentDate); } - oriLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK); - oriLocation.setUpdateTime(currentDate); - oriLocation.setUpdateBy(userName); - wmsBaseLocationMapper.updateWmsBaseLocation(oriLocation); + if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { + wmsMoveMapper.batchWmsMoveDetail(toInsertedMoveDetails); + } else if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_AGV)) { + this.checkFrontLocationStock(oriLocation, warehouseInstockType, "1"); + this.checkFrontLocationStock(targetLocation, warehouseInstockType, "2"); + } - targetLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_MOVE_LOCK); - targetLocation.setUpdateTime(currentDate); - targetLocation.setUpdateBy(userName); - wmsBaseLocationMapper.updateWmsBaseLocation(targetLocation); - int rows = wmsMoveMapper.batchWmsMoveDetail(toInsertedMoveDetails); - - return rows; + return 1; } + private void checkFrontLocationStock(WmsBaseLocation baseLocation, String warehouseInstockType, String moveType) { + if (baseLocation.getLocDeep() != null && baseLocation.getLocDeep().equals(WmsConstants.WMS_BASE_LOCATION_LOC_DEEP_BACK)) { + WmsBaseLocation queryBaseLocation = new WmsBaseLocation(); + Long locRow = baseLocation.getLocRow(); + Long frontRow; + if (locRow % 2 == 0) { + frontRow = locRow - 1; + } else { + frontRow = locRow + 1; + } + + queryBaseLocation.setWarehouseId(baseLocation.getWarehouseId()); + queryBaseLocation.setLocColumn(baseLocation.getLocColumn()); + queryBaseLocation.setLayerNum(baseLocation.getLayerNum()); + queryBaseLocation.setLocRow(frontRow); + queryBaseLocation.setLocDeep(WmsConstants.WMS_BASE_LOCATION_LOC_DEEP_FRONT); + List baseLocationList = wmsBaseLocationMapper.selectWmsBaseLocationList(queryBaseLocation); + String locationName = ""; + if (moveType.equals("1")) { + locationName = "原库位"; + } else { + locationName = "目标库位"; + } + if (baseLocationList == null || baseLocationList.isEmpty()) { + throw new ServiceException(locationName + "的浅库位未找到"); + } + WmsBaseLocation frontLocation = baseLocationList.get(0); + + if (!frontLocation.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL)) { + throw new ServiceException(locationName + "的浅库位状态为" + WmsConstants.LOCATION_STATUS_PROMPT_MAP.get(frontLocation.getLocationStatus())); + } + + if (warehouseInstockType.equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) {//如果是原材料 + WmsRawStock queryRawStock = new WmsRawStock(); + queryRawStock.setLocationCode(frontLocation.getLocationCode()); + List wmsRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryRawStock); + if (wmsRawStocks != null && !wmsRawStocks.isEmpty()) { + throw new ServiceException(locationName + "的浅库位有库存,无法申请移库"); + + } + } else { + WmsProductStock queryProductStock = new WmsProductStock(); + queryProductStock.setLocationCode(frontLocation.getLocationCode()); + List productStocks = wmsProductStockMapper.selectWmsProductStockInList(queryProductStock); + if (productStocks != null && !productStocks.isEmpty()) { + throw new ServiceException(locationName + "的浅库位有库存,无法申请移库"); + } + } + + } + } + + private List getMoveDetailsByRawStocks(List wmsRawStocks, WmsMove wmsMove, String userName, Date currentDate) { List wmsMoveDetailList = new ArrayList<>(); @@ -718,12 +795,31 @@ public class WmsMoveServiceImpl implements IWmsMoveService { throw new ServiceException("没有此移库信息"); } + //根据物料ID找移库明细(主要原因是移库入库的库位的物料条码跟之前的条码不一定一样,物料条码都是贴在料框上的) WmsMoveDetail existedMoveDetail = wmsMoveDetailList.stream().filter(moveDetail -> - moveDetail.getMaterialBarcode().equals(materialBarcode)).findFirst().get(); + moveDetail.getMaterialId().equals(baseBarcodeInfo.getMaterialId())).findFirst().get(); if (existedMoveDetail == null) { throw new ServiceException("没有此移库信息"); } + + String oriBarcodeInfoStr = existedMoveDetail.getMaterialBarcode(); + R oriBarcodeInfoR = remoteMesService.getBarcode(oriBarcodeInfoStr, SecurityConstants.INNER); + MesBaseBarcodeInfo oriBarcodeInfo = oriBarcodeInfoR.getData(); + if (oriBarcodeInfo == null) { + throw new ServiceException("原物料条码有误"); + } + + Long targetPurchaseOrderId = baseBarcodeInfo.getPurchaseOrderId() == null ? 0L : baseBarcodeInfo.getPurchaseOrderId(); + Long oriPurchaseOrderId = oriBarcodeInfo.getPurchaseOrderId() == null ? 0L : oriBarcodeInfo.getPurchaseOrderId(); + + if (!targetPurchaseOrderId.equals(oriPurchaseOrderId)) { + String targetPoNo = baseBarcodeInfo.getPoNo() == null ? "" : baseBarcodeInfo.getPoNo(); + String oriPoNo = oriBarcodeInfo.getPoNo() == null ? "" : oriBarcodeInfo.getPoNo(); + throw new ServiceException("原物料条码(" + oriPoNo + ")和此条码采购订单(" + targetPoNo + ")不一致"); + } + + String detailExecuteStatus = existedMoveDetail.getExecuteStatus(); if (detailExecuteStatus.equals(WmsConstants.WMS_MOVE_EXECUTE_STATUS_INSTOCK_FINISH)) { @@ -856,7 +952,6 @@ public class WmsMoveServiceImpl implements IWmsMoveService { } - /** * 查询移库合库记录,Join material * diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java index bebdff60..490abcd0 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawInstockServiceImpl.java @@ -163,6 +163,10 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService { throw new ServiceException("库位编码有误"); } + if(!baseLocation.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL)){ + throw new ServiceException("不能入库,库位状态为:"+WmsConstants.LOCATION_STATUS_PROMPT_MAP.get(baseLocation.getLocationStatus())); + } + BigDecimal instockAmount = wmsRawInstockVo.getInstockAmount(); if (baseBarcodeInfo.getBatchFlag().equals(MesConstants.IS_BATCH)) { if (instockAmount.compareTo(BigDecimal.ONE) < 0) { diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java index b4186c88..9c6e3a9c 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java @@ -328,10 +328,25 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("库位码有误"); } + if (!baseLocation.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL)) { + throw new ServiceException("不能出库,库位状态为:" + WmsConstants.LOCATION_STATUS_PROMPT_MAP.get(baseLocation.getLocationStatus())); + } + //判断是否有此出库任务,人工出库的同一个出库记录,同一个库位、同一个物料对应一个明细(agv的有可能是多个) WmsRawOutstock wmsRawOutstock; if (rawOutstockId != null) { wmsRawOutstock = wmsRawOutstockMapper.selectWmsRawOutstockByRawOutstockId(rawOutstockId); + if (!wmsRawOutstock.getWarehouseId().equals(baseLocation.getWarehouseId())) { + throw new ServiceException("扫描库位所在仓库与选择出库单不符合"); + } + if (!wmsRawOutstock.getMaterialId().equals(baseBarcodeInfo.getMaterialId())) { + throw new ServiceException("扫描物料与选择出库单不符合"); + } + + if (wmsRawOutstock.getExecuteStatus().equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) { + throw new ServiceException("此出库单已出库完成,不需要再出"); + } + } else { wmsRawOutstock = this.getWmsRawOutstock(baseLocation, baseBarcodeInfo); } @@ -346,7 +361,6 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("此物料已经出库,不能重复出库"); } - //todo 判断质检状态 // if (wmsRawOutstockDetail.getQualityStatus() != null // && !wmsRawOutstockDetail.getQualityStatus().equals(WmsConstants.WMS_QUALITY_STATUS_PASS)) { // throw new ServiceException("质检通过才能出库"); @@ -466,6 +480,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { @Override public List selectAuditPassRawOutstocks(WmsRawOutstock wmsRawOutstock) { wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS); + wmsRawOutstock.setExecuteStatusStr(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); + wmsRawOutstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); List wmsRawOutstocks = wmsRawOutstockMapper.selectWmsRawOutstockJoinMaterialList(wmsRawOutstock); return wmsRawOutstocks; } @@ -1317,6 +1333,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { /** * 退货出库 + * * @param wmsReturnOutstockVo * @return */ @@ -1329,9 +1346,14 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("库位编码错误"); } + Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(baseLocation.getWarehouseId()); + if (!baseWarehouse.getWarehouseInstockType().equals(WmsConstants.WMS_WAREHOUSE_INSTOCK_TYPE_RAW)) { + throw new ServiceException("原材料仓库才能退货出库"); + } + String warehouseType = baseWarehouse.getWarehouseType(); String executeStatus = ""; BigDecimal outstockAmount = BigDecimal.ZERO; @@ -1347,6 +1369,15 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { throw new ServiceException("此库位无库存信息"); } + if (baseLocation.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_RETURN_LOCK)) { + throw new ServiceException("此库位已经申请退货出库"); + } + + baseLocation.setLocationStatus(WmsConstants.WMS_BASE_LOCATION_STATUS_RETURN_LOCK); + baseLocation.setUpdateBy(userName); + baseLocation.setUpdateTime(currentDate); + wmsBaseLocationMapper.updateWmsBaseLocation(baseLocation); + wmsRawStock = wmsRawStocks.get(0); } else if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) { diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java index c2cf5e1f..404d0537 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java @@ -276,7 +276,6 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { BigDecimal returnAmount = wmsRawReturnConfirmVo.getReturnAmount(); String locationCode = wmsRawReturnConfirmVo.getLocationCode(); - //todo: 判断质检状态,超出库位数量限制,超期判断 // if (wmsRawReturnDetail.getQualityStatus() != null // && !wmsRawReturnDetail.getQualityStatus().equals(WmsConstants.RAW_RETURN_DETAIL_QUALITY_STATUS_PASS)) { // throw new ServiceException("质检通过才能出库"); @@ -288,11 +287,11 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { R mesBaseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); if (mesBaseBarcodeInfoR == null) { - throw new ServiceException("物料编码错误"); + throw new ServiceException("物料条码错误"); } MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoR.getData(); if (mesBaseBarcodeInfo == null) { - throw new ServiceException("物料编码错误"); + throw new ServiceException("物料条码错误"); } WmsRawReturn wmsRawReturn = wmsRawReturnMapper.selectOnlyWmsRawReturnByRawReturnId(rawReturnId); if (!wmsRawReturn.getAuditStatus().equals(WmsConstants.WMS_AUDIT_STATUS_PASS)) { @@ -311,13 +310,10 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { // } // } - if (!wmsRawReturn.getMaterialBarcode().equals(materialBarcode)) { - throw new ServiceException("物料编码错误"); - } WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); if (baseLocation == null) { - throw new ServiceException("库位编码有误"); + throw new ServiceException("库位编码有误!"); } if (!baseLocation.getWarehouseId().equals(wmsRawReturn.getWarehouseId())) { @@ -397,7 +393,6 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { wmsRawStock.setLastOutstockTime(mesBaseBarcodeInfo.getLastOutstockDate()); wmsRawStock.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); wmsRawStock.setSafeFlag(mesBaseBarcodeInfo.getSafeFlag()); -// wmsRawStock.setQualityStatus();//TODO:质检状态 wmsRawStock.setCompleteFlag(WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAG_YES); wmsRawStock.setTotalAmount(wmsRawReturnConfirmVo.getReturnAmount()); wmsRawStock.setCreateBy(userName); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java index 25b541ff..8c9e7ce7 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsStockTotalServiceImpl.java @@ -17,6 +17,7 @@ import com.hw.mes.api.RemoteMesService; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseMaterialInfo; import com.hw.mes.api.domain.MesBaseStationInfo; +import com.hw.mes.api.domain.MesSaleOrderRelate; import com.hw.mes.api.domain.vo.MesBaseBarcodeInfoTransferVo; import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo; import com.hw.wms.config.WmsConfig; @@ -225,9 +226,32 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService { } for (WmsStockTotal stockTotal : stockTotalList) { - if (stockTotal.getProductId().equals(0L)) { - stockTotal.setMaterialCode("1111|222"); + if (stockTotal.getMaterialClassfication() != null && + stockTotal.getMaterialClassfication().equals(MesConstants.MES_MATERIAL_CLASSFICATION_VIRTUAL)) { + R> saleOrderRelatesData = remoteMesService.getRelateProductsBySaleOrderId(stockTotal.getSaleOrderId(), SecurityConstants.INNER); + if (saleOrderRelatesData != null) { + StringBuilder productCodes = new StringBuilder(); + StringBuilder productNames = new StringBuilder(); + StringBuilder productSpecs = new StringBuilder(); + List saleOrderRelates = saleOrderRelatesData.getData(); + if (saleOrderRelates != null) { + for (MesSaleOrderRelate mesSaleOrderRelate : saleOrderRelates) { + productCodes.append("|").append(mesSaleOrderRelate.getProductCode()); + productNames.append("|").append(mesSaleOrderRelate.getProductName()); + productSpecs.append("|").append(mesSaleOrderRelate.getProductSpec()); + } + + productCodes.replace(0,1,""); + productNames.replace(0, 1, ""); + productSpecs.replace(0, 1, ""); + + stockTotal.setMaterialCode(productCodes.toString()); + stockTotal.setMaterialName(productNames.toString()); + stockTotal.setMaterialSpec(productSpecs.toString()); + } + } } + } return stockTotalList; diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml index 66399dac..b5d1f1fb 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsBaseLocationMapper.xml @@ -45,7 +45,7 @@ - select location_id, warehouse_id, location_code,container_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 + select location_id, warehouse_id, location_code,container_code,agv_position_code, warehouse_floor,loc_row, layer_num, loc_column, active_flag, manual_flag, qty_limit, instock_flag, outstock_flag, location_status,loc_deep, 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 diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml index 4de6b75e..b66a0ce6 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsStockTotalMapper.xml @@ -55,6 +55,7 @@ + @@ -288,6 +289,7 @@ mbmi.material_code, mbmi.material_name, mbmi.material_spec, + mbmi.material_classfication, wst.total_amount, wst.frozen_amount, wst.occupy_amount,