|
|
@@ -138,7 +138,7 @@ class StoreController extends Controller
|
|
|
if ($addwho == "WCS"){
|
|
|
//判断单据状态
|
|
|
$cus_bs_asnheader = DB::connection('oracle')->select(
|
|
|
- DB::raw("SELECT COUNT(1) FROM CUS_BS_ASNHEADER t INNER JOIN DOC_ASN_HEADER a ON a.asnno = t.asnno WHERE t.asnreference1 = '".$docno."' AND a.asnstatus < '40'"));
|
|
|
+ DB::raw("SELECT 1 FROM CUS_BS_ASNHEADER t INNER JOIN DOC_ASN_HEADER a ON a.asnno = t.asnno WHERE t.asnreference1 = '".$docno."' AND a.asnstatus < '40'"));
|
|
|
if (!$cus_bs_asnheader) return ['success'=>false, 'data'=>"该单据已完成收货"];
|
|
|
|
|
|
$sql = "select a.warehouseid,a.asnno as docno,a1.asnlineno,a.customerid,t1.sku,a1.packid,t1.receivedqty_each,t1.lotatt01,t1.lotatt02,";
|
|
|
@@ -192,6 +192,10 @@ class StoreController extends Controller
|
|
|
In_LotAtt02 In_LotAtt03 In_LotAtt04 In_LotAtt05 In_LotAtt06 In_LotAtt07 In_LotAtt08 In_LotAtt09 In_LotAtt10
|
|
|
In_LotAtt11 In_LotAtt12 In_HoldRejectCode In_HoldRejectReason
|
|
|
*/
|
|
|
+ /** IS */
|
|
|
+ $r_OutboundLifeDays = 0;
|
|
|
+ $r_InboundLifeDays = 0;
|
|
|
+
|
|
|
if ($OUT_Return_Code == "NO_COMMIT" || $OUT_Return_Code == "*_*"){
|
|
|
$r_NO_COMMIT = 'N';
|
|
|
}else{
|
|
|
@@ -266,7 +270,7 @@ class StoreController extends Controller
|
|
|
//TODO 盲收逻辑 SPASN_Receiving_Process:536行 $In_Process_Action = 2
|
|
|
|
|
|
//如果订单已经关闭或者取消,则报错
|
|
|
- $doc_asn_header = DB::connection('oracle')->select(DB::raw("Select count(1) from DOC_ASN_Header where ASNNO='".$In_ASNNo."' and (ASNStatus='90' or ASNStatus='99')"));
|
|
|
+ $doc_asn_header = DB::connection('oracle')->select(DB::raw("Select 1 from DOC_ASN_Header where ASNNO='".$In_ASNNo."' and (ASNStatus='90' or ASNStatus='99')"));
|
|
|
if ($doc_asn_header) return '201';
|
|
|
|
|
|
//收货数量必须大于0
|
|
|
@@ -331,7 +335,7 @@ class StoreController extends Controller
|
|
|
|
|
|
//入库生产日期不能小于在库库存生产日期
|
|
|
if ($r_ASN_MDT_CHK == 'Y' && trim($In_LotAtt01)){
|
|
|
- $data = DB::connection('oracle')->select(DB::raw("SELECT count(*) c FROM INV_LOT_LOC_ID a,INV_LOT_ATT b, bas_location c WHERE a.CUSTOMERID='".$In_CustomerID.
|
|
|
+ $data = DB::connection('oracle')->select(DB::raw("SELECT 1 c FROM INV_LOT_LOC_ID a,INV_LOT_ATT b, bas_location c WHERE a.CUSTOMERID='".$In_CustomerID.
|
|
|
"' AND a.sku='".$In_SKU."' AND a.LotNum=b.LotNum AND a.LocationID=c.LocationID AND c.LocationUsage<>'ST' AND b.LotAtt01>'".$In_LotAtt01."'"));
|
|
|
if ($data) return '266INV_LOT_LOC_ID';
|
|
|
}
|
|
|
@@ -497,21 +501,21 @@ class StoreController extends Controller
|
|
|
if ($In_New_TraceID != '*' && trim($In_New_TraceID)){
|
|
|
if ($R_LoseID_Flag == 'N'){
|
|
|
if ($r_RCV_MIX_TID == 'N'){ //跟踪号是否可以多次收货
|
|
|
- $INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT COUNT(*) FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.LOCATIONID = b.LOCATIONID WHERE b.WAREHOUSEID = '".
|
|
|
+ $INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.LOCATIONID = b.LOCATIONID WHERE b.WAREHOUSEID = '".
|
|
|
$IN_Warehouse."' AND TraceID='".$In_New_TraceID."' AND qty>0"));
|
|
|
if ($INV_LOT_LOC_ID) return '218跟踪号重复错误ID='.$In_New_TraceID;
|
|
|
}else{
|
|
|
if ($r_RCV_MIX_SKU == 'N'){
|
|
|
- $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT COUNT(*) FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID WHERE b.WarehouseID = '".
|
|
|
+ $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID WHERE b.WarehouseID = '".
|
|
|
$IN_Warehouse."' AND TraceID = '".$In_New_TraceID."' AND sku <> '".$In_SKU."' AND qty>0"));
|
|
|
if ($TABLE_INV_LOT_LOC_ID) return '273';
|
|
|
}elseif ($r_RCV_MIX_GR1 == 'N'){
|
|
|
- $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT count(1) FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID INNER JOIN Bas_Sku C ON A.CUSTOMERID = C.CUSTOMERID AND A.SKU = C.SKU WHERE b.WarehouseID = '".
|
|
|
+ $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID INNER JOIN Bas_Sku C ON A.CUSTOMERID = C.CUSTOMERID AND A.SKU = C.SKU WHERE b.WarehouseID = '".
|
|
|
$IN_Warehouse."' AND TraceID='".$In_New_TraceID."' AND C.SKU_GROUP1 <> '".$r_SKU_Group1."' AND qty>0"));
|
|
|
if ($TABLE_INV_LOT_LOC_ID)return '273';
|
|
|
}
|
|
|
//ID是否重复
|
|
|
- $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT COUNT(*) FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b on a.locationid = b.LocationID where b.WarehouseID ='".
|
|
|
+ $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b on a.locationid = b.LocationID where b.WarehouseID ='".
|
|
|
$IN_Warehouse."' AND a.LocationID<>'".$In_TOLocation."' AND a.TraceID='".$In_New_TraceID."' AND a.QTY>0"));
|
|
|
if ($TABLE_INV_LOT_LOC_ID)return '218'.$In_New_TraceID;
|
|
|
}
|
|
|
@@ -520,6 +524,273 @@ class StoreController extends Controller
|
|
|
|
|
|
//r_QtyOnHold:=0
|
|
|
if (!trim($In_HoldRejectCode)) $In_HoldRejectCode = 'OK'; //TODO 1098行
|
|
|
+
|
|
|
+ //ID合法性校验 禁止收货到封存库位
|
|
|
+ if (in_array($r_LocationAttribute,["HD","FI"]))return '228';
|
|
|
+
|
|
|
+ //混放产品校验
|
|
|
+ if (($R_Mix_Flag == 'N' || $r_SKUCount > 0) && $R_LocationUsage != 'ST'){
|
|
|
+ $TABLE_inv_lot_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT COUNT(distinct SKU) c FROM inv_lot_LOC_ID WHERE LocationID='".$In_TOLocation."' AND sku <> '".$In_SKU.
|
|
|
+ "' AND Qty > 0"));
|
|
|
+ if ($TABLE_inv_lot_LOC_ID){
|
|
|
+ if ($TABLE_inv_lot_LOC_ID[0]->c >= 1 && $R_Mix_Flag == 'N')return '205'.rtrim($In_TOLocation);
|
|
|
+ elseif ($R_Mix_Flag == 'Y' && $r_SKUCount > 0 && $TABLE_inv_lot_LOC_ID[0]->c >= $r_SKUCount) return '367'.$r_SKUCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //码盘后才能收货
|
|
|
+ if (!rtrim($In_FMTraceID))$In_FMTraceID = '*';
|
|
|
+ if ($r_PLT_RCV == 'Y' && $In_FMTraceID == '*')return '217';
|
|
|
+ if ($In_FMTraceID != '*'){
|
|
|
+ //无论是ASn收货还是码盘收货, 交易里的FMUOM/QTY/Packid都取收货的数据
|
|
|
+ $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT PlanToLoc, UOM, LineStatus, Reserve_Flag,Lotnum, ExpectedQty_Each - ReceivedQty_Each from DOC_Trace_Details ".
|
|
|
+ "WHERE TraceID=In_FMTraceID AND ASNNO='".$In_ASNNo."' AND ASNLineNO='".$In_ASNLineNo."'"));
|
|
|
+ if (!$TABLE_DOC_Trace_Details) return '104'.$In_ASNNo.":".$In_ASNLineNo;
|
|
|
+ $r_PlanToLoc_Trace = $TABLE_DOC_Trace_Details[0]->plantoloc;
|
|
|
+ $r_TraceUOM = $TABLE_DOC_Trace_Details[0]->uom;
|
|
|
+ $r_LineStatus_Trace = $TABLE_DOC_Trace_Details[0]->linestatus;
|
|
|
+ $R_Reserve_Flag = $TABLE_DOC_Trace_Details[0]->reserve_flag;
|
|
|
+ $r_Lotnum_Trace = $TABLE_DOC_Trace_Details[0]->lotnum;
|
|
|
+ $r_CancelQty_Trace = $TABLE_DOC_Trace_Details[0]->expectedqty_each - $TABLE_DOC_Trace_Details[0]->receivedqty_each;
|
|
|
+
|
|
|
+ if ($R_Reserve_Flag == 'Y' && $R_LocationUsage != 'ST'){
|
|
|
+ $OUT_Return_Code = '*_*';
|
|
|
+ $OUT_Return_Code = $this->spasn_reserve_cancel($IN_Warehouse, 'TRACEID', $In_ASNNo, $In_ASNLineNo, $In_FMTraceID, $In_Language, $In_UserID, $OUT_Return_Code);
|
|
|
+ if (substr($OUT_Return_Code,1,3) != '000'){
|
|
|
+ DB::rollBack();
|
|
|
+ return $OUT_Return_Code;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //没有码盘
|
|
|
+ $r_FMUOM = $In_UOM;
|
|
|
+ $r_FMPackID = $In_PackID;
|
|
|
+ $r_FMQty_Each = '';
|
|
|
+ $r_FMQty = $In_ReceivedQty;
|
|
|
+ }
|
|
|
+
|
|
|
+ //收货时使用的包装数量转换
|
|
|
+ $TABLE_bas_Package = DB::connection('oracle')->select(DB::raw("SELECT QTY1,QTY2,QTY3,QTY4,QTY5,IN_Label1,IN_Label3,IN_Label4 FROM bas_Package where PackID='".$In_PackID."'"));
|
|
|
+ if (!$TABLE_bas_Package)return '104'.$In_PackID;
|
|
|
+ $r_QTY1_P = $TABLE_bas_Package[0]->qty1;
|
|
|
+ $r_QTY2_P = $TABLE_bas_Package[0]->qty2;
|
|
|
+ $r_QTY3_P = $TABLE_bas_Package[0]->qty3;
|
|
|
+ $r_QTY4_P = $TABLE_bas_Package[0]->qty4;
|
|
|
+ $r_QTY5_P = $TABLE_bas_Package[0]->qty5;
|
|
|
+ $r_IN_Label1 = $TABLE_bas_Package[0]->in_label1;
|
|
|
+ $r_IN_Label3 = $TABLE_bas_Package[0]->in_label3;
|
|
|
+ $r_IN_Label4 = $TABLE_bas_Package[0]->in_label4;
|
|
|
+
|
|
|
+ if ($r_CopyPackIDToLotAtt12 == 'Y')$In_LotAtt12 = $r_QTY3_P;
|
|
|
+ if ($R_LOT_12_PKG == 'Y' && $In_UOM == 'CS')$R_UOMQty_Read = $In_LotAtt12;
|
|
|
+ else{
|
|
|
+ switch ($In_UOM){
|
|
|
+ case 'EA':
|
|
|
+ $R_UOMQty_Read = $r_QTY1_P;
|
|
|
+ break;
|
|
|
+ case 'IP':
|
|
|
+ $R_UOMQty_Read = $r_QTY2_P;
|
|
|
+ break;
|
|
|
+ case 'CS':
|
|
|
+ $R_UOMQty_Read = $r_QTY3_P;
|
|
|
+ break;
|
|
|
+ case 'PL':
|
|
|
+ $R_UOMQty_Read = $r_QTY4_P;
|
|
|
+ break;
|
|
|
+ case 'OT':
|
|
|
+ $R_UOMQty_Read = $r_QTY5_P;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $r_FMQty_Each = ($r_FMQty ?? 0) * ($R_UOMQty_Read ?? 0);
|
|
|
+ $r_ReceivedQty_Each = $In_ReceivedQty * ($R_UOMQty_Read ?? 0);
|
|
|
+
|
|
|
+ if (!$r_TotalCubic) $r_TotalCubic = ($r_SKU_Cube ?? 0) * $r_ReceivedQty_Each;
|
|
|
+
|
|
|
+ if ($In_Process_Action != 2){
|
|
|
+ if ($R_OverRCVPercentage_ASN ?? false)$r_OverRCVPercentage = $R_OverRCVPercentage_ASN;
|
|
|
+ //质检控制
|
|
|
+ if ($r_QC_RCV_CTL == 'C'){ //校验合格数
|
|
|
+ $TABLE_ACT_QC_Transaction = DB::connection('oracle')->select(DB::raw("SELECT SUM(QCQty_PASS) pass FROM ACT_QC_Transaction a INNER JOIN DOC_QC_Header b ON A.QCNo = b.QcNo WHERE B.ASNNo = '".$In_ASNNo."' AND A.AsnLineNo = '".$In_ASNLineNo."' AND B.QCStatus < '90'"));
|
|
|
+ if ($TABLE_ACT_QC_Transaction)$r_QCQTY_Pass = $TABLE_ACT_QC_Transaction[0]->pass;
|
|
|
+ if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > ($r_QCQTY_Pass ?? 0)) return '225';
|
|
|
+ }else{
|
|
|
+ $TABLE_doc_QC_Details = DB::connection('oracle')->select(DB::raw("SELECT C.UDF1 from doc_QC_Details a INNER JOIN doc_QC_Header b ON a.QcNo = b.QcNo INNER JOIN BAS_Codes C ON a.QCResult = C.Code and codeid = 'QC_RST' WHERE B.ASNNo = '".$In_ASNNo."' and A.AsnLineNo = '".$In_ASNLineNo."' and B.QCStatus < '90' and rownum = 1"));
|
|
|
+ if ($TABLE_doc_QC_Details) $r_UDF1 = $TABLE_doc_QC_Details[0]->udf1;
|
|
|
+ if ($r_UDF1 ?? false){
|
|
|
+ if ($r_UDF1 == 'NOPASS')return '229'; //拒收,原因:质检不合格'
|
|
|
+ if ($r_UDF1 == 'CONTROL'){
|
|
|
+ $TABLE_ACT_QC_Transaction = DB::connection('oracle')->select(DB::raw("Select SUM(QcQty_Reject) QcQty_Reject from ACT_QC_Transaction a inner join DOC_QC_Header b ON A.QCNo = b.QcNo Where B.ASNNo = '".$In_ASNNo."' and A.AsnLineNo = '".$In_ASNLineNo."' and B.QCStatus <> '90'"));
|
|
|
+ if ($TABLE_ACT_QC_Transaction) $r_QCQTY_Reject = $TABLE_ACT_QC_Transaction[0]->qcqty_reject;
|
|
|
+ if (($r_ReceivedQty_Each_ASN ?? 0 + $r_ReceivedQty_Each) > ($r_ExpectedQty_Each_ASN ?? 0 - ($r_QCQTY_Reject ?? 0)))return '225'; //超出质检合格数
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //超量收货校验
|
|
|
+ if ($R_OverReceiving != 'Y' && ($r_ExpectedQty_Each_ASN ?? false) && ($In_Process_Action != 2)){
|
|
|
+ if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > $r_ExpectedQty_Each_ASN)return '215';
|
|
|
+ if (($r_PONO ?? false) && $r_PONO != '*' && ($r_POLineNO ?? false)){
|
|
|
+ $TABLE_DOC_PO_DETAiLS = DB::connection('oracle')->select(DB::raw("SELECT OrderedQty_Each, ReceivedQty_Each From DOC_PO_DETAiLS where PONO='".$r_PONO."' AND POLineNo='".$r_POLineNO."'"));
|
|
|
+ if ($TABLE_DOC_PO_DETAiLS){
|
|
|
+ $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
|
|
|
+ $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
|
|
|
+ }
|
|
|
+ if ((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each > ($r_OrderedQty_PO ?? 0)))return '215'.$In_CustomerID.",PONo=".$r_PONO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($R_OverReceiving == 'Y' && $r_OverRCVPercentage && ($r_ExpectedQty_Each_ASN ?? false) && $In_Process_Action != 2){//有百分比限制
|
|
|
+ $r_OVR_RCV_BY = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'OVR_RCV_BY','BOTH');
|
|
|
+ if (in_array($r_OVR_RCV_BY,["ASN","BOTH"])){
|
|
|
+ if (((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) / $r_ExpectedQty_Each_ASN) > (1+$r_OverRCVPercentage))return '215'.$In_CustomerID;
|
|
|
+ }elseif (in_array($r_OVR_RCV_BY,["PO","BOTH"])){
|
|
|
+ if (($r_PONO ?? false) && $r_PONO!='*' && ($r_POLineNO ?? false)){
|
|
|
+ $TABLE_DOC_PO_DETAiLS = DB::connection('oracle')->select(DB::raw("Select OrderedQty_Each, ReceivedQty_Each From DOC_PO_DETAiLS where PONO=r_PONO AND POLineNo=r_POLineNo"));
|
|
|
+ if ($TABLE_DOC_PO_DETAiLS){
|
|
|
+ $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
|
|
|
+ $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
|
|
|
+ }
|
|
|
+ if (((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each) / ($r_OrderedQty_PO ?? 0)) > (1+$r_OverRCVPercentage)) return '215'.$In_CustomerID.',PONo='.$r_PONO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($In_ASNNo == '*') $r_DocType = '*';
|
|
|
+ else $r_DocType = 'ASN';
|
|
|
+
|
|
|
+ //RF收货产生新的ID [In_New_TraceID],自动打印上架标签
|
|
|
+ if ($In_New_TraceID == '*' && ($R_PRT_PTA_LBL == 'Y' || $r_ASN_GEN_TID == 'Y')){
|
|
|
+ if ($R_LoseID_Flag != 'Y'){
|
|
|
+ // $OUT_Return_Code = $this->spcom_getidsequence(); //1331 此SP调用 恒定返回000 无意义调用
|
|
|
+ $OUT_Return_Code = '000';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //判断目标库位是否冻结 @LocationHold
|
|
|
+ $TABLE_ACT_InventoryHold = DB::connection('oracle')->select(DB::raw("Select count(1) c From ACT_InventoryHold Where HoldBy='2' and HoldFlag='Y' and LocationID='".$In_TOLocation."'"));
|
|
|
+ if ($TABLE_ACT_InventoryHold)$r_nrow = $TABLE_ACT_InventoryHold[0]->c;
|
|
|
+ if ($r_nrow >= 1) $r_LocationHold = 'Y';
|
|
|
+ $r_LogicalFMSequence = null;
|
|
|
+ $r_LogicalToSequence = null;
|
|
|
+ $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID= '".$In_PlanToLoc."'"));
|
|
|
+ if (!$TABLE_BAS_Location) $r_LogicalToSequence = 0;
|
|
|
+ else $r_LogicalToSequence = $TABLE_BAS_Location[0]->logicalsequence;
|
|
|
+ $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID='".$In_TOLocation."'"));
|
|
|
+ if (!$TABLE_BAS_Location) $r_LogicalFMSequence = 0;
|
|
|
+ else $r_LogicalFMSequence = $TABLE_BAS_Location[0]->logicalsequence;
|
|
|
+ $r_MaxPATaskID_Sequence = 0;
|
|
|
+ $r_MaxQCTaskID_Sequence = 0;
|
|
|
+
|
|
|
+ // <<Loop1>>
|
|
|
+ //批号处理
|
|
|
+ if ($In_Process_Action != '2'){
|
|
|
+ $r_nrow = 1;
|
|
|
+ $query = DB::raw("SELECT LotNum from INV_LOT_ATT where CustomerID='".$In_CustomerID."' and SKU=in_SKU".
|
|
|
+ " and nvl(LotAtt01,'*')=nvl(rtrim('".$In_LotAtt01."'),'*') and nvl(LotAtt02,'*')=nvl(rtrim('".$In_LotAtt02."'),'*') and nvl(LotAtt03,'*')=nvl(rtrim('".$In_LotAtt03."'),'*')".
|
|
|
+ " and nvl(LotAtt04,'*')=nvl(rtrim('".$In_LotAtt04."'),'*') and nvl(LotAtt05,'*')=nvl(rtrim('".$In_LotAtt05."'),'*') and nvl(LotAtt06,'*')=nvl(rtrim('".$In_LotAtt06."'),'*')".
|
|
|
+ " and nvl(LotAtt07,'*')=nvl(rtrim('".$In_LotAtt07."'),'*') and nvl(LotAtt08,'*')=nvl(rtrim('".$In_LotAtt08."'),'*') and nvl(LotAtt09,'*')=nvl(rtrim('".$In_LotAtt09."'),'*')".
|
|
|
+ " and nvl(LotAtt10,'*')=nvl(rtrim('".$In_LotAtt10."'),'*') and nvl(LotAtt11,'*')=nvl(rtrim('".$In_LotAtt11."'),'*') and nvl(LotAtt12,'*')=nvl(rtrim('".$In_LotAtt12."'),'*') and rownum=1");
|
|
|
+ $data = DB::connection('oracle')->select($query);
|
|
|
+ if (!$data) $r_nrow = 0;
|
|
|
+ else $r_Return_LotNum = $data[0]->lotnum;
|
|
|
+
|
|
|
+ //产生新的批号
|
|
|
+ if($r_nrow <= 0){
|
|
|
+ //SP: SPCOM_GetIDSequence(IN_Warehouse,IN_Language,'LOTNumber',r_Return_LotNum,OUT_Return_Code);
|
|
|
+ $r_Return_LotNum = '0';
|
|
|
+ $OUT_Return_Code = '000';
|
|
|
+
|
|
|
+ //TODO CREATE INV_LOT_ATT
|
|
|
+ DB::connection('oracle')->insert(DB::raw("INSERT INTO INV_LOT_ATT (CustomerID,SKU,LotNum,LotAtt01,LotAtt02,LotAtt03,LotAtt04,LotAtt05,LotAtt06,LotAtt07,LotAtt08,LotAtt09,LotAtt10,LotAtt11,LotAtt12,AddTime,AddWho,EditTime,EditWho,ReceivingTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"),
|
|
|
+ [$In_CustomerID,$In_SKU,$r_Return_LotNum,rtrim($In_LotAtt01),rtrim($In_LotAtt02),rtrim($In_LotAtt03),rtrim($In_LotAtt04),rtrim($In_LotAtt05),rtrim($In_LotAtt06)
|
|
|
+ ,rtrim($In_LotAtt07),rtrim($In_LotAtt08),rtrim($In_LotAtt09),rtrim($In_LotAtt10),rtrim($In_LotAtt11),rtrim($In_LotAtt12)
|
|
|
+ ,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString()]);
|
|
|
+ }
|
|
|
+ //预约库存的数量处理
|
|
|
+ $r_Lotnum_Trace = $r_Lotnum_Trace ?? '';
|
|
|
+ $r_PlanToLoc_Trace = $r_PlanToLoc_Trace ?? '';
|
|
|
+ $r_Return_LotNum = $r_Return_LotNum ?? '';
|
|
|
+
|
|
|
+ if ($R_Reserve_Flag == 'Y' && $R_LocationUsage == 'ST' && ($r_Lotnum_Trace ?? '') != $r_Return_LotNum){ //有预约,并且是收到ST库位,批次发生变化
|
|
|
+ //TODO UPDATE
|
|
|
+ DB::connection('oracle')->update(DB::raw('UPDATE INV_LOT_LOC_ID SET QTYPA = QTYPA - ? WHERE lotnum = ? and LocationID = ? and traceid = ?'),
|
|
|
+ [(int)($r_CancelQty_Trace ?? 0),$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
|
|
|
+ //TODO DELETE
|
|
|
+ DB::connection('oracle')->delete(DB::raw('DELETE FROM INV_LOT_LOC_ID where lotnum = ? and LocationID = ? and traceid = ? and QTYPA = 0 and qty = 0 and qtyMvin = 0'),
|
|
|
+ [$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
|
|
|
+
|
|
|
+ DB::connection('oracle')->select(DB::raw('Select * from INV_LOT_LOC_ID Where LotNum=? and LocationID=? and TraceID=? for update'),[
|
|
|
+ $r_Return_LotNum, $r_PlanToLoc_Trace, $In_FMTraceID
|
|
|
+ ]);
|
|
|
+ $TABLE_inv_lot_loc_id = DB::connection('oracle')->select(DB::raw(' select count(*) c from inv_lot_loc_id where lotnum = ? and LocationID = ? and traceid = ?'),[
|
|
|
+ $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
|
|
|
+ ]);
|
|
|
+ if ($TABLE_inv_lot_loc_id[0]->c > 0){
|
|
|
+ //TODO UPDATE
|
|
|
+ DB::connection('oracle')->update(DB::raw('update inv_lot_loc_id set QTYPA = QTYPA + ? where lotnum = ? and LocationID = ? and traceid = ?'),[
|
|
|
+ (int)$r_ReceivedQty_Each,$r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ //TODO CREATE INV_LOT_LOC_ID
|
|
|
+ DB::connection('oracle')->insert(DB::raw('Insert Into INV_LOT_LOC_ID (LotNum, LocationID, TraceID, CustomerID, SKU, Qty, QtyAllocated, QtyRPIn, QtyRPOut, QtyMVIN, QtyMVOut, QtyOnHold, OnHoldLocker,GrossWeight, NetWeight, Cubic, Price, AddTime, AddWho, EditTime, EditWho, LPN, QTYPA) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'),[
|
|
|
+ $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID,$In_CustomerID,$In_SKU,0,0,0,0,0,
|
|
|
+ 0,0,0,0,0,0,0,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),
|
|
|
+ $In_UserID,null,$r_ReceivedQty_Each
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //混放批次校验
|
|
|
+ if ($R_Mix_LotFlag == 'N' && $R_LocationUsage != 'ST'){
|
|
|
+ $TABLE_inv_lot_LOC_ID = DB::connection('oracle')->selectOne(DB::raw('select count(distinct LotNUM) c from inv_lot_LOC_ID where LocationID=? and LotNum<>? and Qty>0 and CustomerID=? and SKU=?'),[
|
|
|
+ $In_TOLocation,$r_Return_LotNum,$In_CustomerID,$In_SKU
|
|
|
+ ]);
|
|
|
+ if ($TABLE_inv_lot_LOC_ID->c >= 1){
|
|
|
+ DB::rollBack();
|
|
|
+ return '206'.rtrim($In_TOLocation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //货架生命周期,失效日期,自动冻结
|
|
|
+ $r_Flag = '0';
|
|
|
+ if (trim($In_LotAtt02)){
|
|
|
+ if ((strtotime($In_LotAtt02) ? true : false)){
|
|
|
+ $r_nrow = 1;
|
|
|
+ $TABLE_BAS_SKU = DB::connection('oracle')->selectOne(DB::raw("SELECT c.OutboundLifeDays,c.InboundLifeDays from BAS_SKU c where c.CustomerID=? and c.SKU=? and c.ShelfLifeFlag='Y' and c.ShelfLifeType='E'"),[
|
|
|
+ $In_CustomerID,$In_SKU
|
|
|
+ ]);
|
|
|
+ if (!$TABLE_BAS_SKU)$r_nrow=0;
|
|
|
+ else {
|
|
|
+ $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
|
|
|
+ $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($r_nrow > 0)$r_Flag = '1';
|
|
|
+ else $r_Flag = '0';
|
|
|
+ if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_OutboundLifeDays)) ||
|
|
|
+ ($r_InboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_InboundLifeDays)))){
|
|
|
+ if ($r_EXP_CTL == 'Y')return '222'; //过期 拒收
|
|
|
+ if ($r_EXP_CTL != 'N')$r_Hold_EP = 'Y';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //货架生命周期,生产日期,自动冻结
|
|
|
+ if ($In_LotAtt01 && !(strtotime($In_LotAtt01) ? true : false) && (!$r_Flag || $r_Flag = '0')){
|
|
|
+ $r_nrow = 1;
|
|
|
+ $TABLE_BAS_SKU = DB::connection('oracle')->selectOne(DB::raw('select c.OutboundLifeDays,c.InboundLifeDays from BAS_SKU c where c.CustomerID=? and c.SKU=? and c.ShelfLifeFlag=? and c.ShelfLifeType=?') ,[
|
|
|
+ $In_CustomerID,$In_SKU,'Y','M'
|
|
|
+ ]);
|
|
|
+ if (!$TABLE_BAS_SKU)$r_nrow = 0;
|
|
|
+ else {
|
|
|
+ $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
|
|
|
+ $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
|
|
|
+ }
|
|
|
+ if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_OutboundLifeDays)) ||
|
|
|
+ ($r_InboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_InboundLifeDays)))){
|
|
|
+ if ($r_EXP_CTL == 'Y')return '222'; //有效期受控 拒收
|
|
|
+ if ($r_EXP_CTL != 'N') $r_Hold_EP ='Y';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //1533行
|
|
|
+ }
|
|
|
return $OUT_Return_Code;
|
|
|
}
|
|
|
|
|
|
@@ -593,4 +864,65 @@ class StoreController extends Controller
|
|
|
}
|
|
|
return trim($sys_configuration[0]->value_string);
|
|
|
}
|
|
|
+
|
|
|
+ /** 码盘调用SP,大概率不会被使用,内部 为游标,UPDATE操作 */
|
|
|
+ private function spasn_reserve_cancel($in_warehouse, $in_by, $in_asnno, $in_asnlineno, $in_traceid, $in_language, $in_userid, $out_return_code){
|
|
|
+ $query = DB::raw('Select TraceID,ASNLineNO,CustomerID,SKU,PackID,UOM,LotNUM,PlanToLoc,ExpectedQty,ExpectedQty_Each,TotalGrossWeight,TotalCubic from DOC_Trace_DETAILS '.
|
|
|
+ "Where (ASNNO='".$in_asnno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and '".$in_by."'='ASNNO') OR".
|
|
|
+ " (ASNNO='".$in_asnno."' and ASNLineNO='".$in_asnlineno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and upper('".$in_by."')=upper('ASNLineNO')) OR".
|
|
|
+ " (ASNNO='".$in_asnno."' and TraceID='".$in_traceid."' and ASNLineNO='".$in_asnlineno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and upper('".$in_by."')=upper('TraceID'))");
|
|
|
+
|
|
|
+ if ($out_return_code == 'NO_COMMIT')$r_no_commit = 'N';
|
|
|
+ else $r_no_commit = 'Y';
|
|
|
+ $sp_sql_r = "''".$in_by."'',''".$in_asnno."'',''".$in_asnlineno."'',''".$in_traceid."'',''".$in_language."'',''".$in_userid."''";
|
|
|
+ $R_CurrentTime = Carbon::now();
|
|
|
+
|
|
|
+ if ($in_by != 'ASNNO' && strtoupper($in_by) != 'ASNLINENO' && strtoupper($in_by) != 'TRACEID')return '887SPASN_Reserve_Cancel';
|
|
|
+
|
|
|
+ $ccur_asns = DB::connection('oracle')->select($query);
|
|
|
+ foreach ($ccur_asns as $crow_asn){
|
|
|
+ $sp_sql_r = 'Fetch cCur_ASN';
|
|
|
+ $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 c from DOC_Trace_Details Where ASNNO='".$in_asnno."' and TraceID='".$crow_asn->traceid."'"));
|
|
|
+ if ($TABLE_DOC_Trace_Details && $TABLE_DOC_Trace_Details[0]->c == 1){
|
|
|
+ // TODO UPDATE
|
|
|
+ $rowcount = DB::connection('oracle')->update(DB::raw("UPDATE INV_LOT_LOC_ID SET QTYPA=(QTYPA-".$crow_asn->expectedqty_each."),EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss'),EditWho='".$in_userid.
|
|
|
+ "' WHERE LotNum='".$crow_asn->lotnum."' and LocationID='".$crow_asn->plantoloc."' and TraceID='".$crow_asn->traceid."'"));
|
|
|
+ if ($rowcount == 0) return 'INV_LOT_LOC_ID,UPDATE';
|
|
|
+ // TODO UPDATE
|
|
|
+ DB::connection('oracle')->update(DB::raw("UPDATE DOC_Trace_Details set PlanToLoc='' ,Reserve_Flag='N',EditTime= TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss'), EditWho='".$in_userid.
|
|
|
+ "' where ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."' and TraceID='".$crow_asn->traceid."'"));
|
|
|
+ $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM DOC_Trace_Details WHERE ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."' and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*'"));
|
|
|
+ if (!$TABLE_DOC_Trace_Details){
|
|
|
+ //TODO UPDATE
|
|
|
+ DB::connection('oracle')->update(DB::raw("Update DOC_ASN_Details set Reserve_Flag='N' ,EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss') , EditWho='".$in_userid."' where ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."'"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //TODO COMMIT
|
|
|
+ if ($r_no_commit == 'Y')DB::commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ $TABLE_DOC_ASN_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM DOC_ASN_Details Where ASNNO='".$in_asnno."' and Reserve_Flag='Y'"));
|
|
|
+ if (!$TABLE_DOC_ASN_Details){
|
|
|
+ $sp_sql_r = 'Update DOC_ASN_Header';
|
|
|
+ //TODO UPDATE
|
|
|
+ DB::connection('oracle')->update(DB::raw("Update DOC_ASN_Header set Reserve_Flag='N' ,EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss') , EditWho='".$in_userid."' where ASNNO='".$in_asnno."'"));
|
|
|
+ }
|
|
|
+ //TODO COMMIT
|
|
|
+ if ($r_no_commit == 'Y')DB::commit();
|
|
|
+
|
|
|
+ return '000';
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取数据表的ID(PO, ASN, SO...) $in_sequence_name_c = TraceID LOTNumber TEMPID Traceid TransactionID TaskID QCNO TransactionID
|
|
|
+ private function spcom_getidsequence($in_warehouse, $in_language, $in_sequence_name_c, $out_returnno, $out_return_code){
|
|
|
+ $out_return_code = '000';
|
|
|
+ $out_returnno = '0';
|
|
|
+ $in_sequence_name = $in_sequence_name_c;
|
|
|
+ $r_id_sequence = -1;
|
|
|
+ $r_length = 0;
|
|
|
+ //TODO $IN_Parameter1 = 'IDSEQUENCE' 单多包裹逻辑校验 应该调用SPUDF_ProcessA 但其中单多部分逻辑已被注释 恒定返回000 此处同理恒定返回000 不会下行执行其他逻辑
|
|
|
+ return;
|
|
|
+ //DB::connection('oracle')->select(DB::raw("Select ID_Sequence,Max_ID_Sequence,Length,PreFix,to_CHar(EditTime,'YYMMDD') ,Date_Format ,Date_max From SYS_IDSequence where IDName=upper('".$IN_Sequence_Name."') and WareHouseID = upper('".$in_warehouse."') For Update;"));
|
|
|
+ //return [$out_returnno,$out_return_code];
|
|
|
+ }
|
|
|
}
|