|
@@ -4,6 +4,8 @@ namespace App\Services;
|
|
|
|
|
|
|
|
use App\CommodityBarcode;
|
|
use App\CommodityBarcode;
|
|
|
use App\OracleBasCode;
|
|
use App\OracleBasCode;
|
|
|
|
|
+use App\OracleBasCustomer;
|
|
|
|
|
+use App\OracleBasForwardingLoc;
|
|
|
use App\OracleBasLocation;
|
|
use App\OracleBasLocation;
|
|
|
use App\OracleBasLotId;
|
|
use App\OracleBasLotId;
|
|
|
use App\OracleBasSKU;
|
|
use App\OracleBasSKU;
|
|
@@ -21,11 +23,63 @@ use Illuminate\Database\Eloquent\Model;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
+use Monolog\Handler\IFTTTHandler;
|
|
|
|
|
|
|
|
class HandInStorageService
|
|
class HandInStorageService
|
|
|
{
|
|
{
|
|
|
use ServiceAppAop;
|
|
use ServiceAppAop;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $info
|
|
|
|
|
+ * @return bool|int
|
|
|
|
|
+ * 校验货主拣货位
|
|
|
|
|
+ */
|
|
|
|
|
+ public function checkForwardingLoc(array $info)
|
|
|
|
|
+ {
|
|
|
|
|
+ $res=OracleBasCustomer::query()
|
|
|
|
|
+ ->where('customerid',$info['customerid'])
|
|
|
|
|
+ ->where('customer_type','OW')
|
|
|
|
|
+ ->where('udf1','Y')->count(); //查询此货主是否必须有拣货位
|
|
|
|
|
+ if ($res>0) {
|
|
|
|
|
+ $amount=OracleBasForwardingLoc::query()
|
|
|
|
|
+ ->where('customerid',$info['customerid'])
|
|
|
|
|
+ ->where('sku',$info['sku'])
|
|
|
|
|
+ ->count();
|
|
|
|
|
+ if ($amount==0)return 1;//请维护拣货位!
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $info
|
|
|
|
|
+ * @return bool|int
|
|
|
|
|
+ * 校验产品档案长宽高
|
|
|
|
|
+ */
|
|
|
|
|
+ public function checkWidthHeight(array $info)
|
|
|
|
|
+ {
|
|
|
|
|
+ $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
|
|
|
|
|
+ if (!$basSku)return 1;//需要维护产品档案
|
|
|
|
|
+ if ($basSku->skulength<=0||$basSku->skuwidth<=0||$basSku->skuhigh<=0)return 2;//需要维护该产品档案中的长宽高
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $info
|
|
|
|
|
+ * @return bool|int
|
|
|
|
|
+ * 校验产品档案重量体积
|
|
|
|
|
+ */
|
|
|
|
|
+ public function checkCubicWeight(array $info)
|
|
|
|
|
+ {
|
|
|
|
|
+ $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
|
|
|
|
|
+ if (!$basSku)return 1;//需要维护产品档案
|
|
|
|
|
+ if ($basSku->grossweight<=0||$basSku->cube<=0)return 2;//需要维护该产品档案中的重量体积
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $info
|
|
|
|
|
+ * @param array $param
|
|
|
|
|
+ * @return bool|int
|
|
|
|
|
+ * 校验库位
|
|
|
|
|
+ */
|
|
|
public function checkLocation(array $info, array $param)
|
|
public function checkLocation(array $info, array $param)
|
|
|
{
|
|
{
|
|
|
$location = OracleBasLocation::query()
|
|
$location = OracleBasLocation::query()
|
|
@@ -174,6 +228,8 @@ sql;
|
|
|
{
|
|
{
|
|
|
$sql = <<<sql
|
|
$sql = <<<sql
|
|
|
SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
|
|
SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
|
|
|
|
|
+ DOC_ASN_DETAILS.lotatt01, DOC_ASN_DETAILS.lotatt02, DOC_ASN_DETAILS.lotatt03, DOC_ASN_DETAILS.lotatt04,
|
|
|
|
|
+ DOC_ASN_DETAILS.lotatt05, DOC_ASN_DETAILS.lotatt06, DOC_ASN_DETAILS.lotatt07, DOC_ASN_DETAILS.lotatt08,
|
|
|
DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty FROM DOC_ASN_DETAILS
|
|
DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty FROM DOC_ASN_DETAILS
|
|
|
LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
|
|
LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
|
|
|
WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?)
|
|
WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?)
|
|
@@ -181,7 +237,8 @@ sql;
|
|
|
$asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql), [$asnno, $skuOrBarcode, $skuOrBarcode, $skuOrBarcode]);
|
|
$asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql), [$asnno, $skuOrBarcode, $skuOrBarcode, $skuOrBarcode]);
|
|
|
if ($asn_detail) return $asn_detail;
|
|
if ($asn_detail) return $asn_detail;
|
|
|
else return OracleDOCASNDetail::query()
|
|
else return OracleDOCASNDetail::query()
|
|
|
- ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty'])
|
|
|
|
|
|
|
+ ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty',
|
|
|
|
|
+ 'lotatt01','lotatt02','lotatt03','lotatt04','lotatt05','lotatt06','lotatt07','lotatt08'])
|
|
|
->where('asnno', $asnno)
|
|
->where('asnno', $asnno)
|
|
|
->where('sku', $skuOrBarcode)
|
|
->where('sku', $skuOrBarcode)
|
|
|
->whereIn('linestatus', ['00', '30'])
|
|
->whereIn('linestatus', ['00', '30'])
|
|
@@ -267,6 +324,8 @@ sql;
|
|
|
if (!$tasks) return false; //获取任务失败
|
|
if (!$tasks) return false; //获取任务失败
|
|
|
return DB::connection("oracle")->transaction(function () use ($tasks, $info) { //单体嵌套事务 回滚FLUX失败任务
|
|
return DB::connection("oracle")->transaction(function () use ($tasks, $info) { //单体嵌套事务 回滚FLUX失败任务
|
|
|
foreach ($tasks as $task) {
|
|
foreach ($tasks as $task) {
|
|
|
|
|
+ $res=$this->checkExpiryPa($task,$info['location']);
|
|
|
|
|
+ if ($res!==true)return $res;
|
|
|
if (!app("StorageService")->fluxPA($task, $info['location'])) {
|
|
if (!app("StorageService")->fluxPA($task, $info['location'])) {
|
|
|
DB::connection("oracle")->rollBack();
|
|
DB::connection("oracle")->rollBack();
|
|
|
return false; //上架失败
|
|
return false; //上架失败
|
|
@@ -276,6 +335,43 @@ sql;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param $task
|
|
|
|
|
+ * @param $location
|
|
|
|
|
+ * @return bool|int
|
|
|
|
|
+ * 上架校验效期
|
|
|
|
|
+ */
|
|
|
|
|
+ public function checkExpiryPa($task,$location)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$task->taskid)return 0;//任务id不存在
|
|
|
|
|
+ if (strpos($task->taskid,'MIX') !== false)return true;//合并拣货,不校验
|
|
|
|
|
+
|
|
|
|
|
+ $sql = <<<sql
|
|
|
|
|
+select instr(DESCR,'拣货') as var_IsPickingArea from BAS_Zone where ZONE=(select PutawayZone from BAS_Location where LocationID = ?)
|
|
|
|
|
+sql;
|
|
|
|
|
+ $basZone = DB::connection("oracle")->selectOne(DB::raw($sql), [$location]);
|
|
|
|
|
+ if ($basZone&&$basZone->var_ispickingarea>0) return true; //不是存储区,不校验
|
|
|
|
|
+
|
|
|
|
|
+ $sql1 = <<<sql
|
|
|
|
|
+select SKU,LotAtt02,CustomerID from INV_LOT_ATT WHERE LOTNUM=?
|
|
|
|
|
+sql;
|
|
|
|
|
+ $invLotAtt = DB::connection("oracle")->selectOne(DB::raw($sql1), [$task->fmlotnum]);
|
|
|
|
|
+ $sql2 = <<<sql
|
|
|
|
|
+ select count(*) as var_amountOfDecaying from INV_LOT_LOC_ID store
|
|
|
|
|
+ left join BAS_Location location on store.LocationID=location.locationId
|
|
|
|
|
+ left join BAS_Zone zone on zone.zone=location.PickZone
|
|
|
|
|
+ left join INV_LOT_ATT attres on store.LOTNUM=attres.LOTNUM
|
|
|
|
|
+ where store.SKU=?
|
|
|
|
|
+ and store.CustomerID=?
|
|
|
|
|
+ and store.LOTNUM!=?
|
|
|
|
|
+ and attres.LotAtt02 > ?
|
|
|
|
|
+ and zone.DESCR like '%拣货%'
|
|
|
|
|
+sql;
|
|
|
|
|
+ $invLotLocId=DB::connection("oracle")->selectOne(DB::raw($sql2), [$invLotAtt->sku,$invLotAtt->customerid,$task->fmlotnum,$invLotAtt->lotatt02]);
|
|
|
|
|
+ if ($invLotLocId&&$invLotLocId->var_amountofdecaying>0)return 1;//拣货区找到效期更新的同样货品,不能上架至存储区
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param $taskParam
|
|
* @param $taskParam
|
|
|
* @param $amount
|
|
* @param $amount
|