|
|
@@ -185,28 +185,28 @@ class HandInStorageService
|
|
|
*/
|
|
|
public function selectAsn($asn)
|
|
|
{
|
|
|
- if (!$asn) return OracleDOCASNHeader::query()
|
|
|
+ if (!$asn) return OracleDOCASNHeader::query() //空扫
|
|
|
->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype'])
|
|
|
->where('asnstatus', '00')
|
|
|
->orderByDesc('addtime')
|
|
|
->limit(50)
|
|
|
->get();
|
|
|
|
|
|
- if (strpos(strtoupper($asn), 'ASN') !== false) {
|
|
|
+ if (strpos(strtoupper($asn), 'ASN') !== false) { //asn 单号
|
|
|
return OracleDOCASNHeader::query()
|
|
|
->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype'])
|
|
|
->where('asnno', $asn)
|
|
|
->whereIn('asnstatus', ['00', '30'])
|
|
|
->get();
|
|
|
} else {
|
|
|
- $asns = OracleDOCASNHeader::query()
|
|
|
+ $asns = OracleDOCASNHeader::query() //货主
|
|
|
->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype'])
|
|
|
->where('customerid', strtoupper($asn))
|
|
|
->whereIn('asnstatus', ['00', '30'])
|
|
|
->get();
|
|
|
if ($asns->count() > 0) {
|
|
|
return $asns;
|
|
|
- } else {
|
|
|
+ } else { //商品条码
|
|
|
$sql = <<<SQL
|
|
|
SELECT DOC_ASN_HEADER.ASNNO,DOC_ASN_HEADER.addtime,DOC_ASN_HEADER.asnreference1,DOC_ASN_HEADER.customerid,DOC_ASN_HEADER.asnstatus,DOC_ASN_HEADER.asntype FROM DOC_ASN_HEADER
|
|
|
LEFT JOIN DOC_ASN_DETAILS ON DOC_ASN_HEADER.ASNNO = DOC_ASN_DETAILS.ASNNO
|
|
|
@@ -309,14 +309,34 @@ sql;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param string $barCode
|
|
|
+ * @param $barcode
|
|
|
* @return array
|
|
|
+ * 根据条码获取 库存
|
|
|
+ */
|
|
|
+ public function getInvotlocid($barcode): array
|
|
|
+ {
|
|
|
+ $sql=<<<sql
|
|
|
+select INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08,
|
|
|
+ sum(INV_LOT_LOC_ID.QTY) AS QTY from INV_LOT_LOC_ID
|
|
|
+ left join BAS_SKU on INV_LOT_LOC_ID.CUSTOMERID=BAS_SKU.CUSTOMERID and INV_LOT_LOC_ID.SKU =BAS_SKU.SKU
|
|
|
+ left join INV_LOT_ATT on INV_LOT_ATT.LOTNUM=INV_LOT_LOC_ID.LOTNUM
|
|
|
+ where (BAS_SKU.ALTERNATE_SKU1 = ? OR BAS_SKU.ALTERNATE_SKU2 = ? OR BAS_SKU.ALTERNATE_SKU3 = ?)
|
|
|
+group by INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08
|
|
|
+sql;
|
|
|
+ $invLots = DB::connection("oracle")->select(DB::raw($sql), [$barcode, $barcode, $barcode]);
|
|
|
+ if (!$invLots)return [];
|
|
|
+ else return $invLots;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $barCode
|
|
|
+ * @return array|int
|
|
|
* 根据商品条码 获取完全收货状态 部分收货状态的 PA任务
|
|
|
*/
|
|
|
- public function getTsk(string $trackNumber, string $barCode): array
|
|
|
+ public function getTsk($trackNumber, string $barCode): array
|
|
|
{
|
|
|
$sql = <<<sql
|
|
|
-SELECT TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC,sum(TSK_TASKLISTS.PlanToQty) AS QTY
|
|
|
+SELECT TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.DOCNO,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC,sum(TSK_TASKLISTS.PlanToQty) AS QTY
|
|
|
FROM DOC_ASN_DETAILS
|
|
|
LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND
|
|
|
DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
|
|
|
@@ -326,14 +346,54 @@ WHERE
|
|
|
WHERE LINESTATUS in ('30','40') and (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?))
|
|
|
AND TSK_TASKLISTS.TASKPROCESS = '00'
|
|
|
AND TSK_TASKLISTS.TASKTYPE = 'PA'
|
|
|
- AND TSK_TASKLISTS.PlanToID= ?
|
|
|
- group by TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC
|
|
|
sql;
|
|
|
- $tasks = DB::connection("oracle")->select(DB::raw($sql), [$barCode, $barCode, $barCode, $trackNumber]);
|
|
|
+ if (!$trackNumber){ //没有输入条件 空扫
|
|
|
+ $owner_codes = app('OwnerService')->getIntersectPermitting(['code']);
|
|
|
+ if (count($owner_codes)>0){
|
|
|
+ $sql.=' AND TSK_TASKLISTS.CustomerID IN (';
|
|
|
+ foreach ($owner_codes as $index => $no){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$no->code."'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.=",'".$no->code."'";
|
|
|
+ }
|
|
|
+ $sql.=')';
|
|
|
+ }else{
|
|
|
+ $sql .= 'AND TSK_TASKLISTS.CustomerID IS NULL ';
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if (strpos(strtoupper($trackNumber), 'ASN') !== false) $sql.='AND TSK_TASKLISTS.DOCNO= ?'; //输入条件为asn单号
|
|
|
+ if ($this->checkUserOwnerAuth($trackNumber)){ //输入条件为货主
|
|
|
+ $sql.='AND TSK_TASKLISTS.CustomerID= ?';
|
|
|
+ }else{
|
|
|
+ $sql.='AND TSK_TASKLISTS.PlanToID= ?'; //不是货主 判断是否为跟踪号
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $sql.=' group by TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.DOCNO,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC';
|
|
|
+ if ($trackNumber){
|
|
|
+ if ($this->checkUserOwnerAuth($trackNumber))$tasks = DB::connection("oracle")->select(DB::raw($sql), [$barCode, $barCode, $barCode, strtoupper($trackNumber)]);
|
|
|
+ else $tasks = DB::connection("oracle")->select(DB::raw($sql), [$barCode, $barCode, $barCode, $trackNumber]);
|
|
|
+ }else {$tasks = DB::connection("oracle")->select(DB::raw($sql), [$barCode, $barCode, $barCode]);}
|
|
|
if (!$tasks) return [];
|
|
|
else return $tasks;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param $owner_code
|
|
|
+ * @return bool
|
|
|
+ * 判断当前用户货主权限
|
|
|
+ */
|
|
|
+ public function checkUserOwnerAuth($owner_code): bool
|
|
|
+ {
|
|
|
+ $owner_codes = app('OwnerService')->getIntersectPermitting(['code']);
|
|
|
+ $owner=$owner_codes->where('code','=',strtoupper($owner_code));
|
|
|
+ if ($owner->count()>0)return true;
|
|
|
+ else return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @throws \Throwable
|
|
|
* flux手持端 上架
|