StoreService.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <?php
  2. namespace App\Services;
  3. use App\Feature;
  4. use App\Jobs\StoreCreateInstantBill;
  5. use App\Order;
  6. use App\OwnerFeeDetail;
  7. use App\Services\common\BatchUpdateService;
  8. use App\Services\common\DataHandlerService;
  9. use App\Services\common\QueryService;
  10. use App\Store;
  11. use App\StoreRejected;
  12. use App\ValueStore;
  13. use App\Warehouse;
  14. use Carbon\Carbon;
  15. use Illuminate\Support\Facades\Cache;
  16. use App\Traits\ServiceAppAop;
  17. use Illuminate\Support\Facades\DB;
  18. class StoreService
  19. {
  20. use ServiceAppAop;
  21. protected $modelClass=Store::class;
  22. private function conditionQuery(array $params)
  23. {
  24. $stores = Store::query()->with(['storeItems.store', 'warehouse', 'owner'])->where('is_fast_stored', '无')->orderBy('id', 'DESC');
  25. $columnQueryRules = [
  26. 'asn_code' => ['batch' => ''],
  27. 'remark' => ['batch' => '','timeLimit' => 15],
  28. 'created_at_start' => ['alias' => 'created_at', 'startDate' => ' 00:00:00'],
  29. 'created_at_end' => ['alias' => 'created_at', 'endDate' => ' 23:59:59'],
  30. 'owner' => ['alias' => 'owner_id','multi' => ','],
  31. 'warehouse' => ['alias' => 'warehouse_id','multi' => ','],
  32. 'status' => ['multi' => ','],
  33. 'stored_method' => ['multi' => ','],
  34. 'id' => ['multi' => ',']
  35. ];
  36. $stores = app(QueryService::class)->query($params, $stores, $columnQueryRules, 'stores');
  37. return $stores;
  38. }
  39. public function paginate(array $params)
  40. {
  41. return $this->conditionQuery($params)->paginate($params['paginate'] ?? 50);
  42. }
  43. public function create(array $params)
  44. {
  45. return Store::query()->create($params);
  46. }
  47. public function storeCreateByWms()
  48. {
  49. $created_at = config('sync.asn_sync.created_at');
  50. $create_set = config('sync.asn_sync.cache_prefix.create_set');
  51. $create_keys = config('sync.asn_sync.cache_prefix.create_keys');
  52. $create_key = config('sync.asn_sync.cache_prefix.create');
  53. /** @var OracleDocAsnHerderService $oracleDocAsnHerderService */
  54. $oracleDocAsnHerderService = app(OracleDocAsnHerderService::class);
  55. $last_time = $this->getAsnLastSyncAt($created_at, 'create');
  56. $asnHerders = $oracleDocAsnHerderService->getWmsAsnOnStartDateCreate($last_time);
  57. if (count($asnHerders)<1) return;
  58. $last_time = $asnHerders->first()['addtime'];
  59. $last_records = $asnHerders->where('addtime', $last_time);
  60. $this->createStore($asnHerders);
  61. $this->createStoreRejected($asnHerders);
  62. $this->deleteCacheKey($create_set, $create_keys);
  63. $this->setLastRecordsByRedis($create_key, $create_set, $create_keys, $last_records);
  64. $this->setAsnLastSyncAt($created_at, $last_time);
  65. }
  66. public function storeUpdateByWms()
  67. {
  68. $updated_at = config('sync.asn_sync.updated_at');
  69. $update_set = config('sync.asn_sync.cache_prefix.update_set');
  70. $update_keys = config('sync.asn_sync.cache_prefix.update_keys');
  71. $update_key = config('sync.asn_sync.cache_prefix.update');
  72. /** @var OracleDocAsnHerderService $oracleDocAsnHerderService */
  73. $oracleDocAsnHerderService = app(OracleDocAsnHerderService::class);
  74. $last_time = $this->getAsnLastSyncAt($updated_at, 'update');
  75. $asnHerders = $oracleDocAsnHerderService->getWmsAsnOnStartDateEdit($last_time);
  76. if (count($asnHerders)<1) return;
  77. $last_time = $asnHerders->first()['edittime'];
  78. $last_records = $asnHerders->where('edittime', $last_time);
  79. $this->createStore($asnHerders,"update");
  80. $this->updateStore($asnHerders);
  81. $this->createStoreRejected($asnHerders);
  82. $this->deleteCacheKey($update_set, $update_keys);
  83. $this->setLastRecordsByRedis($update_key, $update_set, $update_keys, $last_records);
  84. $this->setAsnLastSyncAt($updated_at, $last_time);
  85. }
  86. public function createStore($asnHerders,$isUpdate=null)
  87. {
  88. if (!$asnHerders) return null;
  89. /** @var OwnerService $ownerService */
  90. $ownerService = app(OwnerService::class);
  91. $owner_codes = [];
  92. $warehouse_codes = [];
  93. foreach ($asnHerders as $asnHerder) {
  94. if (!empty($asnHerder['customerid']))
  95. $owner_codes[$asnHerder['customerid']] = $asnHerder['customerid'];
  96. if (!empty($asnHerder['warehouseid']))
  97. $warehouse_codes[$asnHerder['warehouseid']] = $asnHerder['warehouseid'];
  98. }
  99. $owners = $ownerService->getOwnerByCodes($owner_codes);
  100. $warehouses = Warehouse::query()->get();
  101. $owners_code_map=[];
  102. foreach ($owners as $owner) {
  103. $owners_code_map[$owner->code] = $owner;
  104. }
  105. $warehouses_code_map=[];
  106. foreach ($warehouses as $warehouse) {
  107. $warehouses_code_map[$warehouse->code] = $warehouse;
  108. }
  109. $params = $this->getParamsByAsnHeader($asnHerders, $owners_code_map, $warehouses_code_map);
  110. if (count($params) > 0) $this->insertStore($params);
  111. /** @var StoreItemService $storeItemService */
  112. $storeItemService = app(StoreItemService::class);
  113. $storeItemService->storeItemCreateByWms($asnHerders);
  114. /** @var RejectedBillService $rejectedBillService */
  115. $rejectedBillService = app(RejectedBillService::class);
  116. $rejectedBillService->syncLoadedStatusByAsnHerder($asnHerders);
  117. if (!$isUpdate)$this->pushJob($asnHerders);
  118. unset($asnHerders, $owners_code_map, $warehouses_code_map);
  119. }
  120. public function getParamsByAsnHeader($asnHerders, $owners_code_map, $warehouses_code_map)
  121. {
  122. $params = [];
  123. $stores = Store::query()->whereIn('asn_code', data_get($asnHerders, '*.asnno'))->get();
  124. $store_asn_code_map = [];
  125. foreach ($stores as $store) {
  126. $store_asn_code_map[$store->asn_code] = $store;
  127. }
  128. foreach ($asnHerders as $asnHerder) {
  129. if ($store_asn_code_map[$asnHerder->asnno] ?? false) continue;
  130. $owner = $owners_code_map[$asnHerder->customerid] ?? null;
  131. $warehouse = $warehouses_code_map[$asnHerder->warehouseid] ?? null;
  132. $status = null;
  133. if ($asnHerder->asnStatus && $asnHerder->asnStatus->codename_c == '完全收货') $status = '已入库';
  134. if ($asnHerder->asnStatus && $asnHerder->asnStatus->codename_c == '订单创建') $status = '未入库';
  135. $params[] = [
  136. 'asn_code' => $asnHerder->asnno,
  137. 'warehouse_id' => $warehouse->id ?? null,
  138. 'owner_id' => $owner->id ?? null,
  139. 'stored_method' => $asnHerder->asnType ? $asnHerder->asnType->codename_c : '',
  140. 'status' => $status ? $status : $asnHerder->asnStatus->codename_c,
  141. 'remark' => $asnHerder->notes ?? null,
  142. 'created_at' => $asnHerder->addtime ?? null,
  143. 'updated_at' => $asnHerder->edittime ?? null,
  144. ];
  145. }
  146. return $params;
  147. }
  148. public function insertStore(array $params)
  149. {
  150. if (count($params) === 0) return;
  151. foreach (array_chunk($params, 1000) as $item) {
  152. try {
  153. $bool = $this->insert($item);
  154. if ($bool) {
  155. app('LogService')->log(__METHOD__, __FUNCTION__, "批量创建 store success " . count($item) . ' || ' . json_encode($item));
  156. } else app('LogService')->log(__METHOD__, __FUNCTION__, "批量添加 store FAILED " . ' || ' . json_encode($item));
  157. } catch (\Exception $e) {
  158. app('LogService')->log(__METHOD__, __FUNCTION__, "批量添加 store ERROR " . ' || ' . json_encode($params) . ' || ' . json_encode($e->getMessage()) . ' || ' . json_encode($e->getTraceAsString()));
  159. }
  160. }
  161. }
  162. public function updateStore($asnHerders)
  163. {
  164. if (!$asnHerders || $asnHerders->count() == 0) return null;
  165. /**
  166. * @var DataHandlerService $dataHandlerService
  167. * @var OwnerService $ownerService
  168. */
  169. $ownerService = app(OwnerService::class);
  170. $dataHandlerService = app(DataHandlerService::class);
  171. $stores = $this->getByWms($asnHerders);
  172. $store_asn_code_map = $dataHandlerService->dataHeader(['asn_code'], $stores);
  173. $owners = $ownerService->getOwnerByCodes(array_unique(data_get($asnHerders,'*.customerid')));
  174. $warehouses = Warehouse::query()->get();
  175. $owner_code_map = $dataHandlerService->dataHeader(['code'], $owners);
  176. $warehouses_map = $dataHandlerService->dataHeader(['code'], $warehouses);
  177. $updateParams = [[
  178. 'id', 'asn_code', 'warehouse_id', 'owner_id', 'stored_method', 'status', 'remark', 'updated_at'
  179. ]];
  180. foreach ($asnHerders as $asnHerder) {
  181. $store = $dataHandlerService->getKeyValue(['asn_code' => $asnHerder->asnno], $store_asn_code_map);
  182. if (!$store) continue;
  183. $owner = $dataHandlerService->getKeyValue(['code' => $asnHerder->customerid], $owner_code_map);
  184. $warehouse = $dataHandlerService->getKeyValue(['code' => $asnHerder->warehouseid], $warehouses_map);
  185. $owner_id = $owner->id ?? null;
  186. $warehouse_id = $warehouse->id ?? null;
  187. $status = null;
  188. if ($asnHerder->asnStatus && $asnHerder->asnStatus->codename_c == '完全收货') $status = '已入库';
  189. if ($asnHerder->asnStatus && $asnHerder->asnStatus->codename_c == '订单创建') $status = '未入库';
  190. if ($store->asn_code != $asnHerder->asnno ||
  191. $store->warehouse_id != $warehouse_id ||
  192. $store->owner_id != $owner_id ||
  193. $store->stored_method != ($asnHerder->asnType->codename_c ??'')||
  194. $store->status != ($asnHerder->asnStatus->codename_c ?? '')||
  195. $store->remark != $asnHerder->notes ||
  196. $store->updated_at != $asnHerder->edittime) {
  197. $updateParams[] = [
  198. 'id' => $store->id,
  199. 'asn_code' => $asnHerder->asnno,
  200. 'warehouse_id' => $warehouse_id,
  201. 'owner_id' => $owner_id,
  202. 'stored_method' => $asnHerder->asnType ? $asnHerder->asnType->codename_c : '',
  203. 'status' => $status ? $status : $asnHerder->asnStatus->codename_c,
  204. 'remark' => $asnHerder->notes,
  205. 'updated_at' => $asnHerder->edittime,
  206. ];
  207. }
  208. }
  209. if (count($updateParams) > 1) {
  210. foreach (array_chunk($updateParams, 1000) as $item) {
  211. try {
  212. $bool=$this->batchUpdate($item);
  213. if ($bool) {
  214. app('LogService')->log(__METHOD__, __FUNCTION__, "批量修改 store success " . count($item) . ' || ' . json_encode($item));
  215. } else app('LogService')->log(__METHOD__, __FUNCTION__, "批量修改 store FAILED " . ' || ' . json_encode($item));
  216. } catch (\Exception $e) {
  217. app('LogService')->log(__METHOD__, __FUNCTION__, "批量修改 store ERROR " . ' || ' . json_encode($updateParams) . ' || ' . json_encode($e->getMessage()) . ' || ' . json_encode($e->getTraceAsString()));
  218. }
  219. }
  220. }
  221. /** @var StoreItemService $storeItemService */
  222. $storeItemService = app(StoreItemService::class);
  223. $storeItemService->storeItemUpdateByWms($asnHerders);
  224. /** @var RejectedBillService $rejectedBillService */
  225. $rejectedBillService = app(RejectedBillService::class);
  226. $rejectedBillService->syncLoadedStatusByAsnHerder($asnHerders);
  227. $this->pushJob($asnHerders);
  228. unset($updateParams, $asnHerders);
  229. }
  230. public function pushJob($asnHerders){
  231. dispatch(new StoreCreateInstantBill(Store::query()->with(["storeItems"])->where('status','已入库')->whereIn('asn_code', data_get($asnHerders,'*.asnno'))->get()));
  232. }
  233. public function insert($params)
  234. {
  235. return Store::query()->insert($params);
  236. }
  237. public function batchUpdate($params)
  238. {
  239. return app(BatchUpdateService::class)->batchUpdate('stores', $params);
  240. }
  241. public function getByWms($asnHerders)
  242. {
  243. if (!$asnHerders) {
  244. return null;
  245. }
  246. $asn_nos = array_unique(data_get($asnHerders, '*.asnno'));
  247. return Store::query()->whereIn('asn_code', $asn_nos)->get();
  248. }
  249. public function getAsnLastSyncAt($key, $type)
  250. {
  251. $last_time = ValueStore::query()->where('name', $key)->value('value');
  252. if ($last_time) return $last_time;
  253. if ($type == 'create') {
  254. $store = Store::query()->orderByDesc('created_at')->first();
  255. if ($store) return $store->created_at;
  256. } else {
  257. $store = Store::query()->orderByDesc('updated_at')->first();
  258. if ($store) return $store->updated_at;
  259. }
  260. return Carbon::now()->subSeconds(65);
  261. }
  262. public function setAsnLastSyncAt($key, $last_time)
  263. {
  264. $asnLastSyncAt = ValueStore::query()->updateOrCreate([
  265. 'name' => $key,
  266. ], [
  267. 'name' => $key,
  268. 'value' => $last_time,
  269. ]);
  270. LogService::log(__METHOD__, __FUNCTION__, '修改或更新' . $key . json_encode($asnLastSyncAt));
  271. return $asnLastSyncAt;
  272. }
  273. public function deleteCacheKey($set, $keys)
  274. {
  275. if (Cache::get($set)) {
  276. $cacheKeys = Cache::get($keys);
  277. if (!$cacheKeys) return;
  278. foreach ($cacheKeys as $cacheKey) {
  279. Cache::forget($cacheKey);
  280. }
  281. Cache::forget($keys);
  282. }
  283. }
  284. public function setLastRecordsByRedis($prefixKey, $set, $keys, $last_records)
  285. {
  286. $cacheKeys = [];
  287. foreach ($last_records as $last_record) {
  288. Cache::put($prefixKey . $last_record->customerid . '_' . $last_record->asnno, true);
  289. array_push($cacheKeys, $prefixKey . $last_record->customerid . '_' . $last_record->asnno);
  290. }
  291. Cache::put($keys, $cacheKeys);
  292. Cache::put($set, true);
  293. }
  294. public function createInstantBill(Store $store): bool
  295. {
  296. /** @var \stdClass $store */
  297. if (!$store || $store->status != "已入库") return false;
  298. if (Cache::has("owner_fee_details:stores_".$store->id))return true;
  299. $store->loadMissing(["storeItems.commodity","warehouse"]);
  300. /** @var OwnerPriceOperationService $service */
  301. $service = app("OwnerPriceOperationService");
  302. list($id,$money,$taxFee) = $service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库");
  303. if (app("OwnerFeeDetailService")->create([
  304. "owner_id" => $store->owner_id,
  305. "worked_at" => $store->updated_at,
  306. "type" => "收货",
  307. "operation_bill" => $store->asn_code,
  308. "commodity_amount" => array_sum(array_column($store->storeItems->toArray(), "amount")),
  309. "work_fee" => $money,
  310. "owner_price_operation_id" => $id,
  311. "created_at" => date('Y-m-d H:i:s'),
  312. "outer_id" => $store->id,
  313. "outer_table_name" => "stores",
  314. "work_tax_fee" => $taxFee,
  315. ])){
  316. $amount = 0;
  317. if ($store->storeItems)foreach ($store->storeItems as $item)$amount += $item->amount;
  318. $this->setStoreAmount($store->owner_id,$amount);
  319. Cache::put("owner_fee_details:stores_".$store->id,1,86400);
  320. return true;
  321. }
  322. return false;
  323. }
  324. public function createStoreRejected($asnHerders){
  325. if (!$asnHerders) return null;
  326. $stores = $this->getByWms($asnHerders);
  327. $orders = Order::query()->whereIn('client_code', data_get($asnHerders, '*.asnreference2'))->get();
  328. $store_rejecteds=StoreRejected::query()->whereIn('order_id',data_get($orders,'*.id'))->whereIn('store_id',data_get($stores,'*.id'))->get();
  329. /** @var DataHandlerService $dataHandlerService */
  330. $dataHandlerService = app(DataHandlerService::class);
  331. $order_map = $dataHandlerService->dataHeader(['client_code'], $orders);
  332. $store_map = $dataHandlerService->dataHeader(['asn_code'], $stores);
  333. $store_rejected_map=$dataHandlerService->dataHeader(['store_id','order_id','logistic_number_return'],$store_rejecteds);
  334. $insert_param=[];
  335. foreach ($asnHerders as $asnHerder){
  336. if (!$asnHerder->asnreference2) continue;
  337. $order=$dataHandlerService->getKeyValue(['client_code'=>$asnHerder->asnreference2],$order_map);
  338. $store=$dataHandlerService->getKeyValue(['asn_code'=>$asnHerder->asnno],$store_map);
  339. if (!$order || !$store)continue;
  340. $store_rejected=$dataHandlerService->getKeyValue(['store_id'=>$store->id,'order_id'=>$order->id,'logistic_number_return'=>$asnHerder->asnreference3],$store_rejected_map);
  341. if ($store_rejected) continue;
  342. $insert_param[]=[
  343. 'store_id'=>$store->id,
  344. 'order_id'=>$order->id,
  345. 'logistic_number_return'=>$asnHerder->asnreference3 ?? '',
  346. 'created_at'=>Carbon::now()->toDateTimeString(),
  347. ];
  348. }
  349. if (count($insert_param)>0) StoreRejected::query()->insert($insert_param);
  350. }
  351. /**
  352. * 入库件数丢失补偿逻辑
  353. *
  354. * @param int $owner
  355. */
  356. private function storeAmountCompensationLogic($owner)
  357. {
  358. $query = DB::raw(<<<sql
  359. SELECT sum(amount) total FROM `store_items` LEFT JOIN stores ON store_items.store_id=stores.id WHERE stores.owner_id = ? AND (stores.status='已入库' OR stores.status='ASN关闭') AND store_items.updated_at LIKE ?
  360. sql
  361. );
  362. $statistics = DB::selectOne($query,[$owner,date("Y-m")."%"]);
  363. Cache::put(date("Y-m")."|A|".$owner,$statistics->total ? $statistics->total : 0,2764800);
  364. }
  365. /**
  366. * 设置货主下的本月入库件数
  367. *
  368. * @param int $owner
  369. * @param int $amount
  370. */
  371. public function setStoreAmount($owner, $amount)
  372. {
  373. $date = date("Y-m");
  374. if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner);//补偿逻辑
  375. Cache::increment($date."|A|".$owner,$amount);
  376. }
  377. /**
  378. * 获取货主下的本月入库件数
  379. *
  380. * @param int $owner
  381. *
  382. * @return int
  383. */
  384. public function getStoreAmount($owner)
  385. {
  386. $date = date("Y-m");
  387. if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner);
  388. return Cache::get($date."|A|".$owner);
  389. }
  390. public function warehousing(array $params)
  391. {
  392. $conn = oci_connect(config('database.connections.oracle.username'),
  393. config('database.connections.oracle.password'),
  394. config('database.connections.oracle.host'). '/' . config('database.connections.oracle.service_name'),"utf8");
  395. $sp = "begin SPASN_Receiving_Process(:IN_Warehouse, :In_Process_Action, :In_ASNNo_C, :In_ASNLineNo_C, :In_FMTraceID_C, :In_New_TraceID_C, :In_ProductStatus," .
  396. ":In_ProductStatus_Descr, :In_HoldRejectCode_C, :In_HoldRejectReason_C, :In_PONo_C, :In_CustomerID, :In_SKU, :In_ReceivedQty, :In_RejectedQty,:In_UOM, :In_PackID," .
  397. " :In_ContainerID, :In_LotAtt01_C, :In_LotAtt02_C, :In_LotAtt03_C, :In_LotAtt04_C, :In_LotAtt05_C, :In_LotAtt06_C," .
  398. ":In_LotAtt07_C, :In_LotAtt08_C, :In_LotAtt09_C, :In_LotAtt10_C, :In_LotAtt11_C, :In_LotAtt12_C," .
  399. ":In_TotalCubic, :In_TotalGrossWeight, :In_TotalNetWeight, :In_TotalPrice, :In_UserDefine1, :In_UserDefine2,:In_UserDefine3, :In_UserDefine4, :In_UserDefine5, :In_FMLocation," .
  400. ":In_TOLocation_C,:In_QC_Type_C, :In_PlanToLoc_C,:In_ReceivingTime, :In_LPN, :In_Operator, :IN_RCVModule, :IN_RCVStation, :In_Language, :In_UserID, :OUT_Return_Code); end;";
  401. $inParams = array(
  402. "IN_Warehouse"=>"",
  403. "In_Process_Action"=>"",
  404. "In_ASNNo_C"=>"",
  405. "In_ASNLineNo_C"=>"",
  406. "In_FMTraceID_C"=>"",
  407. "In_New_TraceID_C"=>"",
  408. "In_ProductStatus"=>"00",
  409. "In_ProductStatus_Descr"=>"正常",
  410. "In_HoldRejectCode_C"=>"OK",
  411. "In_HoldRejectReason_C"=>"正常",
  412. "In_PONo_C"=>"",
  413. "In_CustomerID"=>"",
  414. "In_SKU"=>"",
  415. "In_ReceivedQty"=>"",
  416. "In_RejectedQty"=>"",
  417. "In_UOM"=>"EA",
  418. "In_PackID"=>"",
  419. "In_ContainerID"=>"",
  420. "In_LotAtt01_C"=>"",
  421. "In_LotAtt02_C"=>"",
  422. "In_LotAtt03_C"=>"",
  423. "In_LotAtt04_C"=>"",
  424. "In_LotAtt05_C"=>"",
  425. "In_LotAtt06_C"=>"",
  426. "In_LotAtt07_C"=>"",
  427. "In_LotAtt08_C"=>"",
  428. "In_LotAtt09_C"=>"",
  429. "In_LotAtt10_C"=>"",
  430. "In_LotAtt11_C"=>"",
  431. "In_LotAtt12_C"=>"",
  432. "In_TotalCubic"=>"0.00",
  433. "In_TotalGrossWeight"=>"0.00",
  434. "In_TotalNetWeight"=>"0.00",
  435. "In_TotalPrice"=>"0.00",
  436. "In_UserDefine1"=>"",
  437. "In_UserDefine2"=>"",
  438. "In_UserDefine3"=>"",
  439. "In_UserDefine4"=>"",
  440. "In_UserDefine5"=>"",
  441. "In_FMLocation"=>"",
  442. "In_TOLocation_C"=>"",
  443. "In_QC_Type_C"=>"OK",
  444. "In_PlanToLoc_C"=>"",
  445. "In_ReceivingTime"=>"",
  446. "In_LPN"=>"*",
  447. "In_Operator"=>"WCS",
  448. "IN_RCVModule"=>"",
  449. "IN_RCVStation"=>"",
  450. "In_Language"=>"cn",
  451. "In_UserID"=>"WCS",
  452. "result"=>""
  453. );
  454. foreach ($params as $key=>$val)$inParams[$key] = $val;
  455. list($IN_Warehouse,$In_Process_Action,$In_ASNNo_C,$In_ASNLineNo_C,$In_FMTraceID_C,$In_New_TraceID_C,$In_ProductStatus,
  456. $In_ProductStatus_Descr,$In_HoldRejectCode_C,$In_HoldRejectReason_C,$In_PONo_C,$In_CustomerID,$In_SKU,$In_ReceivedQty,
  457. $In_RejectedQty,$In_UOM,$In_PackID,$In_ContainerID,$In_LotAtt01_C,$In_LotAtt02_C,$In_LotAtt03_C,$In_LotAtt04_C,$In_LotAtt05_C,
  458. $In_LotAtt06_C,$In_LotAtt07_C,$In_LotAtt08_C,$In_LotAtt09_C,$In_LotAtt10_C,$In_LotAtt11_C,$In_LotAtt12_C,$In_TotalCubic,
  459. $In_TotalGrossWeight,$In_TotalNetWeight,$In_TotalPrice,$In_UserDefine1,$In_UserDefine2,$In_UserDefine3,$In_UserDefine4,
  460. $In_UserDefine5,$In_FMLocation,$In_TOLocation_C,$In_QC_Type_C,$In_PlanToLoc_C,$In_ReceivingTime,$In_LPN,$In_Operator,
  461. $IN_RCVModule,$IN_RCVStation,$In_Language,$In_UserID,$result) = array_values($inParams);
  462. $stmt = oci_parse($conn, $sp);
  463. oci_bind_by_name($stmt, ':IN_Warehouse', $IN_Warehouse);
  464. oci_bind_by_name($stmt, ':In_Process_Action', $In_Process_Action);
  465. oci_bind_by_name($stmt, ':In_ASNNo_C', $In_ASNNo_C);
  466. oci_bind_by_name($stmt, ':In_ASNLineNo_C', $In_ASNLineNo_C);
  467. oci_bind_by_name($stmt, ':In_FMTraceID_C', $In_FMTraceID_C);
  468. oci_bind_by_name($stmt, ':In_New_TraceID_C', $In_New_TraceID_C);
  469. oci_bind_by_name($stmt, ':In_ProductStatus', $In_ProductStatus);
  470. oci_bind_by_name($stmt, ':In_ProductStatus_Descr', $In_ProductStatus_Descr);
  471. oci_bind_by_name($stmt, ':In_HoldRejectCode_C', $In_HoldRejectCode_C);
  472. oci_bind_by_name($stmt, ':In_HoldRejectReason_C', $In_HoldRejectReason_C);
  473. oci_bind_by_name($stmt, ':In_PONo_C', $In_PONo_C);
  474. oci_bind_by_name($stmt, ':In_CustomerID', $In_CustomerID);
  475. oci_bind_by_name($stmt, ':In_SKU', $In_SKU);
  476. oci_bind_by_name($stmt, ':In_ReceivedQty', $In_ReceivedQty);
  477. oci_bind_by_name($stmt, ':In_RejectedQty', $In_RejectedQty);
  478. oci_bind_by_name($stmt, ':In_UOM', $In_UOM);
  479. oci_bind_by_name($stmt, ':In_PackID', $In_PackID);
  480. oci_bind_by_name($stmt, ':In_ContainerID', $In_ContainerID);
  481. oci_bind_by_name($stmt, ':In_LotAtt01_C', $In_LotAtt01_C);
  482. oci_bind_by_name($stmt, ':In_LotAtt02_C', $In_LotAtt02_C);
  483. oci_bind_by_name($stmt, ':In_LotAtt03_C', $In_LotAtt03_C);
  484. oci_bind_by_name($stmt, ':In_LotAtt04_C', $In_LotAtt04_C);
  485. oci_bind_by_name($stmt, ':In_LotAtt05_C', $In_LotAtt05_C);
  486. oci_bind_by_name($stmt, ':In_LotAtt06_C', $In_LotAtt06_C);
  487. oci_bind_by_name($stmt, ':In_LotAtt07_C', $In_LotAtt07_C);
  488. oci_bind_by_name($stmt, ':In_LotAtt08_C', $In_LotAtt08_C);
  489. oci_bind_by_name($stmt, ':In_LotAtt09_C', $In_LotAtt09_C);
  490. oci_bind_by_name($stmt, ':In_LotAtt10_C', $In_LotAtt10_C);
  491. oci_bind_by_name($stmt, ':In_LotAtt11_C', $In_LotAtt11_C);
  492. oci_bind_by_name($stmt, ':In_LotAtt12_C', $In_LotAtt12_C);
  493. oci_bind_by_name($stmt, ':In_TotalCubic', $In_TotalCubic);
  494. oci_bind_by_name($stmt, ':In_TotalGrossWeight', $In_TotalGrossWeight);
  495. oci_bind_by_name($stmt, ':In_TotalNetWeight', $In_TotalNetWeight);
  496. oci_bind_by_name($stmt, ':In_TotalPrice', $In_TotalPrice);
  497. oci_bind_by_name($stmt, ':In_UserDefine1', $In_UserDefine1);
  498. oci_bind_by_name($stmt, ':In_UserDefine2', $In_UserDefine2);
  499. oci_bind_by_name($stmt, ':In_UserDefine3', $In_UserDefine3);
  500. oci_bind_by_name($stmt, ':In_UserDefine4', $In_UserDefine4);
  501. oci_bind_by_name($stmt, ':In_UserDefine5', $In_UserDefine5);
  502. oci_bind_by_name($stmt, ':In_FMLocation', $In_FMLocation);
  503. oci_bind_by_name($stmt, ':In_TOLocation_C', $In_TOLocation_C);
  504. oci_bind_by_name($stmt, ':In_QC_Type_C', $In_QC_Type_C);
  505. oci_bind_by_name($stmt, ':In_PlanToLoc_C', $In_PlanToLoc_C);
  506. oci_bind_by_name($stmt, ':In_ReceivingTime', $In_ReceivingTime);
  507. oci_bind_by_name($stmt, ':In_LPN', $In_LPN);
  508. oci_bind_by_name($stmt, ':In_Operator', $In_Operator);
  509. oci_bind_by_name($stmt, ':IN_RCVModule', $IN_RCVModule);
  510. oci_bind_by_name($stmt, ':IN_RCVStation', $IN_RCVStation);
  511. oci_bind_by_name($stmt, ':In_Language', $In_Language);
  512. oci_bind_by_name($stmt, ':In_UserID', $In_UserID);
  513. oci_bind_by_name($stmt, ':OUT_Return_Code', $result,300);
  514. oci_execute($stmt);
  515. oci_close($conn);
  516. return $result;
  517. }
  518. }