@ -16,6 +16,7 @@ import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils ;
import com.hw.mes.api.domain.MesBaseMaterialInfo ;
import com.hw.mes.api.domain.MesOrderBind ;
import com.hw.mes.api.domain.MesSaleOrderRelate ;
import com.hw.mes.domain.MesSaleOrder ;
import com.hw.mes.mapper.* ;
import com.hw.wms.api.RemoteWmsService ;
@ -46,7 +47,7 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper ;
@Autowired
private MesSaleOrder Mapper mesSaleOrder Mapper;
private MesSaleOrder Relate Mapper mesSaleOrder Relate Mapper;
@Autowired
private MesOrderBindMapper mesOrderBindMapper ;
@ -161,7 +162,27 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
throw new ServiceException ( "此物料为常备物料,不需要绑定" ) ;
}
Long purchaseOrderId = mesPurchaseOrder . getPurchaseOrderId ( ) ;
MesPurchaseOrder dbPurchaseOrder = mesPurchaseOrderMapper . selectMesPurchaseOrderByPurchaseOrderId ( purchaseOrderId ) ;
if ( dbPurchaseOrder . getOrderStatus ( ) . equals ( MesConstants . MES_PURCHASE_ORDER_STATUS_PURCHASE_COMPLETE ) ) {
throw new ServiceException ( "此采购订单已经采购完成,无需再绑定" ) ;
}
if ( dbPurchaseOrder . getOrderStatus ( ) . equals ( MesConstants . MES_PURCHASE_ORDER_STATUS_AUTO_OUTSTOCK_COMPLETE ) ) {
throw new ServiceException ( "此采购订单已经自动出库完成,无需再绑定" ) ;
}
//校验此采购订单有没有合并过
MesSaleOrderRelate querySaleOrderRelate = new MesSaleOrderRelate ( ) ;
querySaleOrderRelate . setPurchaseOrderId ( purchaseOrderId ) ;
List < MesSaleOrderRelate > mesSaleOrderRelates = mesSaleOrderRelateMapper . selectMesSaleOrderRelateList ( querySaleOrderRelate ) ;
if ( mesSaleOrderRelates ! = null & & ! mesSaleOrderRelates . isEmpty ( ) ) {
throw new ServiceException ( "此采购订单已经合并过,不能绑定" ) ;
}
MesOrderBind queryOrderBind = new MesOrderBind ( ) ;
queryOrderBind . setPurchaseOrderId ( purchaseOrderId ) ;
List < MesOrderBind > dbMesOrderBinds = mesOrderBindMapper . selectMesOrderBindList ( queryOrderBind ) ;
@ -217,9 +238,18 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
if ( StringUtils . isEmpty ( orderBind . getSafeFlag ( ) ) ) {
throw new ServiceException ( "请全部选择安全标识" ) ;
}
if ( orderBind . getSafeFlag ( ) . equals ( MesConstants . MES_ORDER_BIND_SAFE_FLAG_NO )
& & orderBind . getSaleOrderId ( ) = = null ) {
throw new ServiceException ( "安全库存标识为否的请选择销售订单" ) ;
if ( orderBind . getSafeFlag ( ) . equals ( MesConstants . MES_ORDER_BIND_SAFE_FLAG_NO ) ) {
if ( orderBind . getSaleOrderId ( ) = = null ) {
throw new ServiceException ( "安全库存标识为否的请选择销售订单" ) ;
}
//校验选择的销售订单有没有合并过
MesSaleOrderRelate querySaleOrderRelateBySale = new MesSaleOrderRelate ( ) ;
querySaleOrderRelateBySale . setRelateSaleOrderId ( orderBind . getSaleOrderId ( ) ) ;
List < MesSaleOrderRelate > mesSaleOrderRelatesBySale = mesSaleOrderRelateMapper . selectMesSaleOrderRelateList ( querySaleOrderRelateBySale ) ;
if ( mesSaleOrderRelatesBySale ! = null & & ! mesSaleOrderRelatesBySale . isEmpty ( ) ) {
throw new ServiceException ( "选择的销售订单已经合并过,不能绑定" ) ;
}
}
if ( orderBind . getSafeFlag ( ) . equals ( MesConstants . MES_ORDER_BIND_SAFE_FLAG_YES )
@ -301,6 +331,15 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
@Override
@Transactional ( rollbackFor = ServiceException . class )
public int saveSalesBindPurchase ( MesSaleOrder mesSaleOrder ) {
Long saleOrderId = mesSaleOrder . getSaleOrderId ( ) ;
MesSaleOrderRelate querySaleOrderRelateBySale = new MesSaleOrderRelate ( ) ;
querySaleOrderRelateBySale . setRelateSaleOrderId ( saleOrderId ) ;
List < MesSaleOrderRelate > mesSaleOrderRelatesBySale = mesSaleOrderRelateMapper . selectMesSaleOrderRelateList ( querySaleOrderRelateBySale ) ;
if ( mesSaleOrderRelatesBySale ! = null & & ! mesSaleOrderRelatesBySale . isEmpty ( ) ) {
throw new ServiceException ( "此销售订单已经合并过,不能再绑定" ) ;
}
Date currentDate = new Date ( ) ;
String userName = SecurityUtils . getUsername ( ) ;
List < MesPurchaseOrder > mesPurchaseOrderList = mesSaleOrder . getMesPurchaseOrderList ( ) ;
@ -312,6 +351,22 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
throw new ServiceException ( "数据有变化,请重新更新" ) ;
}
if ( dbMesPurchaseOrder . getOrderStatus ( ) . equals ( MesConstants . MES_PURCHASE_ORDER_STATUS_PURCHASE_COMPLETE ) ) {
throw new ServiceException ( "此采购订单已经采购完成,无需再绑定" ) ;
}
if ( dbMesPurchaseOrder . getOrderStatus ( ) . equals ( MesConstants . MES_PURCHASE_ORDER_STATUS_AUTO_OUTSTOCK_COMPLETE ) ) {
throw new ServiceException ( "此采购订单已经自动出库完成,无需再绑定" ) ;
}
MesSaleOrderRelate querySaleOrderRelateByPurchase = new MesSaleOrderRelate ( ) ;
querySaleOrderRelateByPurchase . setPurchaseOrderId ( purchaseOrderId ) ;
List < MesSaleOrderRelate > mesSaleOrderRelatesByPurchase = mesSaleOrderRelateMapper . selectMesSaleOrderRelateList ( querySaleOrderRelateByPurchase ) ;
if ( mesSaleOrderRelatesByPurchase ! = null & & ! mesSaleOrderRelatesByPurchase . isEmpty ( ) ) {
throw new ServiceException ( "序号: " + mesPurchaseOrder . getSerialNumber ( ) + ",采购订单已经合并过,不能再绑定" ) ;
}
this . checkSaveSalesBindPurchase ( mesPurchaseOrder ) ;
this . updateOrderBind ( mesSaleOrder , mesPurchaseOrder , userName , currentDate ) ;
@ -477,7 +532,7 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
}
}
if ( ! autoStockPurchaseOrderList . isEmpty ( ) ) {
for ( MesPurchaseOrder mpo : autoStockPurchaseOrderList ) {
for ( MesPurchaseOrder mpo : autoStockPurchaseOrderList ) {
MesBaseMaterialInfo mesBaseMaterialInfo = mesBaseMaterialInfoMapper . selectMesBaseMaterialInfoByErpId ( mpo . getMaterialId ( ) ) ;
mpo . setOrderStatus ( MesConstants . MES_PURCHASE_ORDER_STATUS_AUTO_OUTSTOCK_COMPLETE ) ;