StoreController.php 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. <?php
  2. namespace App\Http\Controllers\Api\thirdPart\flux;
  3. use App\Http\Controllers\Controller;
  4. use App\Store;
  5. use App\WMSReflectReceive;
  6. use App\WMSReflectReceiveSku;
  7. use Carbon\Carbon;
  8. use Illuminate\Support\Facades\Auth;
  9. use Illuminate\Support\Facades\DB;
  10. use Zttp\Zttp;
  11. class StoreController extends Controller
  12. {
  13. /**
  14. * 入库回传给WMS
  15. * @param Store $store
  16. * @return bool
  17. */
  18. public function accomplishToWMS(Store $store,array $inputs)
  19. {
  20. $METHOD=__METHOD__;
  21. $FUNCTION=__FUNCTION__;
  22. Controller::logS(__METHOD__, __FUNCTION__, '快递入库进入WMS接口:' . $store['asn_code']);
  23. $wmsReceiveds=WMSReflectReceive::query()->where('ASNNO',$store['asn_code'])->get();
  24. if($wmsReceiveds->isEmpty()){
  25. (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,'没有本地WMS入库单');
  26. return false;
  27. }
  28. $success=true;
  29. $wmsReceiveds->each(function ($wmsReceived)use(&$store,&$amountsItem,&$success,&$inputs,$METHOD,$FUNCTION){
  30. $wmsSkus=$wmsReceived->skus()->get();
  31. $orderNumberCode=$wmsReceived['ASNREFERENCE1']??$store['order_number'];
  32. $amountsSku=(function()use($wmsSkus){
  33. $result=[];
  34. $wmsSkus->each(function($sku)use(&$result){
  35. $result[$sku['id']]= $sku['EXPECTEDQTY_EACH'];
  36. });
  37. return $result;
  38. })();
  39. $skuStrList=[];
  40. $customerCode=$store->owner()->first()['code'];
  41. $wmsSkus->each(function(WMSReflectReceiveSku $sku)use(&$skuList,&$amountsItem,&$amountsSku,&$skuStrList,$wmsReceived,$customerCode,&$inputs) {
  42. $STATUS = 'ZP';
  43. if(isset($inputs['quality'])&&$inputs['quality']
  44. &&$inputs['quality']!='正品') {
  45. $STATUS = 'CC';
  46. }
  47. $repositoryCode=$sku['LOTATT05'];
  48. if(isset($inputs['depository_code'])&&$inputs['depository_code']){
  49. $repositoryCode=$inputs['depository_code'];
  50. }
  51. $skuStr = "
  52. {
  53. \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
  54. \"ASNLINENO\": \"{$sku['ASNLINENO']}\",
  55. \"SKUCODE\": \"{$sku['SKU']}\",
  56. \"QUANTITY\": \"{$sku['EXPECTEDQTY_EACH']}\",
  57. \"LOTATT04\": \"{$sku['LOTATT04']}\",
  58. \"LOTATT05\": \"{$repositoryCode}\",
  59. \"STATUS\": \"{$STATUS}\",
  60. \"USERDEFINE1\": \"{$inputs['follow_code']}\",
  61. \"USERDEFINE2\": \"\",
  62. \"USERDEFINE3\": \"\",
  63. \"UNIQUE_CODE_LIST\": [" .
  64. "]
  65. }
  66. ";
  67. $skuStrList[] = $skuStr;
  68. });
  69. $skuStrList = implode(',',$skuStrList);
  70. $json="
  71. {
  72. \"request\": [
  73. {
  74. \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
  75. \"CUSTOMERID\": \"{$wmsReceived['CUSTOMERID']}\",
  76. \"ASNTYPE\": \"{$wmsReceived['ASNTYPE']}\",
  77. \"ASNREFERENCE1\": \"{$wmsReceived['ASNREFERENCE1']}\",
  78. \"ADDWHO\": \"WCS\",
  79. \"USERDEFINE1\": \"\",
  80. \"USERDEFINE2\": \"\",
  81. \"USERDEFINE3\": \"\",
  82. \"SKU_LIST\": [{$skuStrList}]
  83. }
  84. ]
  85. }
  86. ";
  87. $sendingJson = json_decode($json,true);
  88. $url=url(config('api.flux.receive.new'));
  89. // (new Controller())->log($METHOD,$FUNCTION,$store['asn_code'].'||' .json_encode($sendingJson));
  90. Controller::logS(__METHOD__, __FUNCTION__, '快递入库请求WMS接口开始:' . $store['asn_code']);
  91. $response = Zttp::post($url, $sendingJson);
  92. Controller::logS(__METHOD__, __FUNCTION__, '快递入库请求WMS接口结束:' . $store['asn_code'].'||'.$response->body());
  93. $noIssues=true;
  94. $json = $response->json();
  95. if(!$json||!isset($json['Response'])||!$json['Response']['return']['returnFlag']=='1'){
  96. $noIssues=false;
  97. }
  98. if($json&&isset($json['Response'])){
  99. if($json['Response']['return']['returnFlag']=='2'){
  100. (new Controller())->log($METHOD,'error_'.$FUNCTION,$store['asn_code'].'||' . $response->body());
  101. return true;
  102. }
  103. // if(isset($json['Response']['return']['returnDesc'])&&strpos($json['Response']['return']['returnDesc'],'唯一约束')!==false){
  104. // (new Controller())->log($METHOD,'error_'.$FUNCTION,$response->body());
  105. // return true;
  106. // }
  107. if(isset($json['Response']['return']['errordescr'])&&strpos($json['Response']['return']['errordescr'],'已完成')!==false){
  108. (new Controller())->log($METHOD,'error_'.$FUNCTION,$store['asn_code'].'||' . $response->body());
  109. return true;
  110. }
  111. }
  112. if($noIssues&&$json['Response']['return']['returnFlag']=='1'){
  113. $wmsReceived['is_uploaded']=1;
  114. $wmsReceived->save();
  115. (new Controller())->log($METHOD, 'success_' .$FUNCTION, $store['asn_code'].'||' .$response->body());
  116. return true;
  117. }else {
  118. $success = false;
  119. (new Controller())->log($METHOD, 'error_'.$FUNCTION, $store['asn_code'].'||' . $response->body());
  120. }
  121. });
  122. return $success;
  123. }
  124. public function quickStorage($docno){
  125. $db = DB::connection('oracle');
  126. //判断单据有效性
  127. $cus_bs_asnheader = $db->select(DB::raw("SELECT t.addwho FROM CUS_BS_ASNHEADER t WHERE t.ASNREFERENCE1 = '".$docno."'"));
  128. if (!$cus_bs_asnheader) return ['success'=>false, 'data'=>'单据不存在'];
  129. $addwho = $cus_bs_asnheader[0]->addwho;
  130. if ($addwho == "WCS"){
  131. //判断单据状态
  132. $cus_bs_asnheader = $db->select(
  133. 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'"));
  134. if (!$cus_bs_asnheader) return ['success'=>false, 'data'=>"该单据已完成收货"];
  135. $sql = "select a.warehouseid,a.asnno as docno,a1.asnlineno,a.customerid,t1.sku,a1.packid,t1.receivedqty_each,t1.lotatt01,t1.lotatt02,";
  136. $sql .= " t1.lotatt04,t1.lotatt05,t1.lotatt08,t1.userdefine1 as new_traceid,a.userdefine1,a.userdefine2,a.userdefine3,a.userdefine4,a.userdefine5,t.addwho";
  137. $sql .= " from doc_asn_details a1";
  138. $sql .= " inner join doc_asn_header a on a.asnno = a1.asnno";
  139. $sql .= " inner join cus_bs_asndetails t1 on t1.asnno = a.asnno and t1.asnlineno = a1.asnlineno";
  140. $sql .= " inner join cus_bs_asnheader t on t.asnno = a1.asnno";
  141. $sql .= " where t.asnreference1 = '".$docno."' and nvl(t1.rcvflag,'N') = 'N'";
  142. $doc_asn_details = $db->select(DB::raw($sql));
  143. $db->beginTransaction();
  144. try{
  145. $username=config('database.connections.oracle.username');
  146. $password=config('database.connections.oracle.password');
  147. $host=config('database.connections.oracle.host');
  148. $service_name=config('database.connections.oracle.service_name');
  149. $conn=oci_connect($username,$password,$host.'/'.$service_name);
  150. $sql_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,".
  151. ":In_ProductStatus_Descr, :In_HoldRejectCode_C, :In_HoldRejectReason_C, :In_PONo_C, :In_CustomerID, :In_SKU, :In_ReceivedQty, :In_RejectedQty,:In_UOM, :In_PackID,".
  152. " :In_ContainerID, :In_LotAtt01_C, :In_LotAtt02_C, :In_LotAtt03_C, :In_LotAtt04_C, :In_LotAtt05_C, :In_LotAtt06_C,".
  153. ":In_LotAtt07_C, :In_LotAtt08_C, :In_LotAtt09_C, :In_LotAtt10_C, :In_LotAtt11_C, :In_LotAtt12_C,".
  154. ":In_TotalCubic, :In_TotalGrossWeight, :In_TotalNetWeight, :In_TotalPrice, :In_UserDefine1, :In_UserDefine2,:In_UserDefine3, :In_UserDefine4, :In_UserDefine5, :In_FMLocation,".
  155. ":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;";
  156. foreach ($doc_asn_details as $doc_asn_detail){
  157. $IN_Warehouse = $doc_asn_detail->warehouseid ?? '';
  158. $In_Process_Action = '3';
  159. $In_ASNNo_C = $doc_asn_detail->docno ?? '';
  160. $In_ASNLineNo_C = $doc_asn_detail->asnlineno ?? '';
  161. $In_FMTraceID_C = '';
  162. $In_New_TraceID_C = $doc_asn_detail->new_traceid ?? '';
  163. $In_ProductStatus = '00';
  164. $In_ProductStatus_Descr = '正常';
  165. $In_HoldRejectCode_C = 'OK';
  166. $In_HoldRejectReason_C = '正常';
  167. $In_PONo_C = '';
  168. $In_CustomerID = $doc_asn_detail->customerid ?? '';
  169. $In_SKU = $doc_asn_detail->sku ?? '';
  170. $In_ReceivedQty = $doc_asn_detail->receivedqty_each ?? '';
  171. $In_RejectedQty = '';
  172. $In_UOM = 'EA';
  173. $In_PackID = $doc_asn_detail->packid ?? '';
  174. $In_ContainerID = '';
  175. $In_LotAtt01_C = $doc_asn_detail->lotatt01 ?? '';
  176. $In_LotAtt02_C = $doc_asn_detail->lotatt02 ?? '';
  177. $In_LotAtt03_C = '';
  178. $In_LotAtt04_C = $doc_asn_detail->lotatt04 ?? '';
  179. $In_LotAtt05_C = $doc_asn_detail->lotatt05 ?? '';
  180. $In_LotAtt06_C = '';
  181. $In_LotAtt07_C = '';
  182. $In_LotAtt08_C = $doc_asn_detail->lotatt08 ?? '';
  183. $In_LotAtt09_C = '';
  184. $In_LotAtt10_C = '';
  185. $In_LotAtt11_C = '';
  186. $In_LotAtt12_C = '';
  187. $In_TotalCubic = '0.00';
  188. $In_TotalGrossWeight = '0.00';
  189. $In_TotalNetWeight = '0.00';
  190. $In_TotalPrice = '0.00';
  191. $In_UserDefine1 = $doc_asn_detail->userdefine1 ?? '';
  192. $In_UserDefine2 = $doc_asn_detail->userdefine2 ?? '';
  193. $In_UserDefine3 = $doc_asn_detail->userdefine3 ?? '';
  194. $In_UserDefine4 = $doc_asn_detail->userdefine4 ?? '';
  195. $In_UserDefine5 = $doc_asn_detail->userdefine5 ?? '';
  196. $In_FMLocation = 'STAGE'.$doc_asn_detail->warehouseid;
  197. $In_TOLocation_C = 'STAGE'.$doc_asn_detail->warehouseid;
  198. $In_QC_Type_C = 'OK';
  199. $In_PlanToLoc_C = '';
  200. $In_ReceivingTime = '';
  201. $In_LPN = '*';
  202. $In_Operator = $doc_asn_detail->addwho ?? '';
  203. $IN_RCVModule = '';
  204. $IN_RCVStation = '';
  205. $In_Language = 'cn';
  206. $In_UserID = $doc_asn_detail->addwho ?? '';
  207. $result = '';
  208. $stmt = oci_parse($conn, $sql_sp);
  209. oci_bind_by_name($stmt,':IN_Warehouse',$IN_Warehouse);
  210. oci_bind_by_name($stmt,':In_Process_Action',$In_Process_Action);
  211. oci_bind_by_name($stmt,':In_ASNNo_C',$In_ASNNo_C);
  212. oci_bind_by_name($stmt,':In_ASNLineNo_C',$In_ASNLineNo_C);
  213. oci_bind_by_name($stmt,':In_FMTraceID_C',$In_FMTraceID_C);
  214. oci_bind_by_name($stmt,':In_New_TraceID_C',$In_New_TraceID_C);
  215. oci_bind_by_name($stmt,':In_ProductStatus',$In_ProductStatus);
  216. oci_bind_by_name($stmt,':In_ProductStatus_Descr',$In_ProductStatus_Descr);
  217. oci_bind_by_name($stmt,':In_HoldRejectCode_C',$In_HoldRejectCode_C);
  218. oci_bind_by_name($stmt,':In_HoldRejectReason_C',$In_HoldRejectReason_C);
  219. oci_bind_by_name($stmt,':In_PONo_C',$In_PONo_C);
  220. oci_bind_by_name($stmt,':In_CustomerID',$In_CustomerID);
  221. oci_bind_by_name($stmt,':In_SKU',$In_SKU);
  222. oci_bind_by_name($stmt,':In_ReceivedQty',$In_ReceivedQty);
  223. oci_bind_by_name($stmt,':In_RejectedQty',$In_RejectedQty);
  224. oci_bind_by_name($stmt,':In_UOM',$In_UOM);
  225. oci_bind_by_name($stmt,':In_PackID',$In_PackID);
  226. oci_bind_by_name($stmt,':In_ContainerID',$In_ContainerID);
  227. oci_bind_by_name($stmt,':In_LotAtt01_C',$In_LotAtt01_C);
  228. oci_bind_by_name($stmt,':In_LotAtt02_C',$In_LotAtt02_C);
  229. oci_bind_by_name($stmt,':In_LotAtt03_C',$In_LotAtt03_C);
  230. oci_bind_by_name($stmt,':In_LotAtt04_C',$In_LotAtt04_C);
  231. oci_bind_by_name($stmt,':In_LotAtt05_C',$In_LotAtt05_C);
  232. oci_bind_by_name($stmt,':In_LotAtt06_C',$In_LotAtt06_C);
  233. oci_bind_by_name($stmt,':In_LotAtt07_C',$In_LotAtt07_C);
  234. oci_bind_by_name($stmt,':In_LotAtt08_C',$In_LotAtt08_C);
  235. oci_bind_by_name($stmt,':In_LotAtt09_C',$In_LotAtt09_C);
  236. oci_bind_by_name($stmt,':In_LotAtt10_C',$In_LotAtt10_C);
  237. oci_bind_by_name($stmt,':In_LotAtt11_C',$In_LotAtt11_C);
  238. oci_bind_by_name($stmt,':In_LotAtt12_C',$In_LotAtt12_C);
  239. oci_bind_by_name($stmt,':In_TotalCubic',$In_TotalCubic);
  240. oci_bind_by_name($stmt,':In_TotalGrossWeight',$In_TotalGrossWeight);
  241. oci_bind_by_name($stmt,':In_TotalNetWeight',$In_TotalNetWeight);
  242. oci_bind_by_name($stmt,':In_TotalPrice',$In_TotalPrice);
  243. oci_bind_by_name($stmt,':In_UserDefine1',$In_UserDefine1);
  244. oci_bind_by_name($stmt,':In_UserDefine2',$In_UserDefine2);
  245. oci_bind_by_name($stmt,':In_UserDefine3',$In_UserDefine3);
  246. oci_bind_by_name($stmt,':In_UserDefine4',$In_UserDefine4);
  247. oci_bind_by_name($stmt,':In_UserDefine5',$In_UserDefine5);
  248. oci_bind_by_name($stmt,':In_FMLocation',$In_FMLocation);
  249. oci_bind_by_name($stmt,':In_TOLocation_C',$In_TOLocation_C);
  250. oci_bind_by_name($stmt,':In_QC_Type_C',$In_QC_Type_C);
  251. oci_bind_by_name($stmt,':In_PlanToLoc_C',$In_PlanToLoc_C);
  252. oci_bind_by_name($stmt,':In_ReceivingTime',$In_ReceivingTime);
  253. oci_bind_by_name($stmt,':In_LPN',$In_LPN);
  254. oci_bind_by_name($stmt,':In_Operator',$In_Operator);
  255. oci_bind_by_name($stmt,':IN_RCVModule',$IN_RCVModule);
  256. oci_bind_by_name($stmt,':IN_RCVStation',$IN_RCVStation);
  257. oci_bind_by_name($stmt,':In_Language',$In_Language);
  258. oci_bind_by_name($stmt,':In_UserID',$In_UserID);
  259. oci_bind_by_name($stmt,':OUT_Return_Code',$result);
  260. oci_execute($stmt);
  261. oci_close($conn);
  262. if (substr($result,0,3) == '000'){
  263. $query = DB::raw("update cus_bs_asndetails t set t.rcvflag = 'Y' where t.asnno = ? and t.asnlineno = ?");
  264. $db->update($query,[$doc_asn_detail->docno,$doc_asn_detail->asnlineno]);
  265. }else{
  266. $query = DB::raw("update cus_bs_asndetails t set t.rcvflag = 'W' where t.asnno = ? and t.asnlineno = ?");
  267. $db->update($query,[$doc_asn_detail->docno,$doc_asn_detail->asnlineno]);
  268. $db->rollBack();
  269. return ['success'=>false, 'data'=>'收货失败','code'=>$result];
  270. }
  271. }
  272. $db->commit();
  273. return ['success'=>true];
  274. }catch (\Exception $e){
  275. $db->rollBack();
  276. return ['success'=>false, 'data'=>$e->getMessage()];
  277. }
  278. }
  279. }
  280. /*$resule = $that->exe($doc_asn_detail->warehouseid,'3',$doc_asn_detail->docno,$doc_asn_detail->asnlineno,'',$doc_asn_detail->new_traceid,'00','正常','OK','正常',
  281. '',$doc_asn_detail->customerid,$doc_asn_detail->sku,$doc_asn_detail->receivedqty_each,'','EA',$doc_asn_detail->packid,'',$doc_asn_detail->lotatt01,$doc_asn_detail->lotatt02,
  282. '',$doc_asn_detail->lotatt04,$doc_asn_detail->lotatt05,'','',$doc_asn_detail->lotatt08,'','','','',
  283. '0.00','0.00','0.00','0.00',$doc_asn_detail->userdefine1,$doc_asn_detail->userdefine2,$doc_asn_detail->userdefine3,$doc_asn_detail->userdefine4,$doc_asn_detail->userdefine5,'STAGE'.$doc_asn_detail->warehouseid,
  284. 'STAGE'.$doc_asn_detail->warehouseid,'OK','','','*',$doc_asn_detail->addwho,'','','cn',$doc_asn_detail->addwho,'');*/
  285. /** $In_Process_Action为来源渠道,快速入库调用固定值 为 '3' */
  286. private function exe($IN_Warehouse, $In_Process_Action, $In_ASNNo_C, $In_ASNLineNo_C, $In_FMTraceID_C, $In_New_TraceID_C, $In_ProductStatus,
  287. $In_ProductStatus_Descr, $In_HoldRejectCode_C, $In_HoldRejectReason_C, $In_PONo_C, $In_CustomerID, $In_SKU, $In_ReceivedQty, $In_RejectedQty,
  288. $In_UOM, $In_PackID, $In_ContainerID, $In_LotAtt01_C, $In_LotAtt02_C, $In_LotAtt03_C, $In_LotAtt04_C, $In_LotAtt05_C, $In_LotAtt06_C,
  289. $In_LotAtt07_C, $In_LotAtt08_C, $In_LotAtt09_C, $In_LotAtt10_C, $In_LotAtt11_C, $In_LotAtt12_C,
  290. $In_TotalCubic, $In_TotalGrossWeight, $In_TotalNetWeight, $In_TotalPrice, $In_UserDefine1, $In_UserDefine2,
  291. $In_UserDefine3, $In_UserDefine4, $In_UserDefine5, $In_FMLocation, $In_TOLocation_C, $In_QC_Type_C, $In_PlanToLoc_C,
  292. $In_ReceivingTime, $In_LPN, $In_Operator, $IN_RCVModule, $IN_RCVStation, $In_Language, $In_UserID, $OUT_Return_Code)
  293. {
  294. /*$r_NO_COMMIT $R_CurrentTime $OUT_Return_Code $R_ReceivingTime $r_LPN $r_UDF2_AD $r_UDF2_IN
  295. $R_Qty_PlanPutaway $R_QCTaskID $R_HOLD_FLAG $R_PA_TaskID $R_PA_Flag $R_QC_Sequence $R_PA_Sequence
  296. $R_Reserve_Flag $R_QtyMVOut $r_TotalGrossWeight $r_TotalCubic r_TotalNetWeight r_TotalPrice In_LotAtt01
  297. In_LotAtt02 In_LotAtt03 In_LotAtt04 In_LotAtt05 In_LotAtt06 In_LotAtt07 In_LotAtt08 In_LotAtt09 In_LotAtt10
  298. In_LotAtt11 In_LotAtt12 In_HoldRejectCode In_HoldRejectReason
  299. */
  300. /** IS */
  301. $r_OutboundLifeDays = 0;
  302. $r_InboundLifeDays = 0;
  303. if ($OUT_Return_Code == "NO_COMMIT" || $OUT_Return_Code == "*_*"){
  304. $r_NO_COMMIT = 'N';
  305. }else{
  306. $r_NO_COMMIT = 'Y';
  307. }
  308. //初始化
  309. $R_CurrentTime = Carbon::now();
  310. $OUT_Return_Code ='000';
  311. if (!$In_ReceivingTime){
  312. $R_ReceivingTime = Carbon::now();
  313. }else{
  314. $R_ReceivingTime = $In_ReceivingTime;
  315. }
  316. //else R_ReceivingTime:=To_Date( IN_ReceivingTime,'YYYY/MM/DD hh24:mi:ss'); --2008-11-25 15:53:33
  317. if ($In_LPN && $In_LPN != "*"){
  318. $r_LPN = $In_LPN;
  319. }else $r_LPN = "*";
  320. $bascode = DB::select(DB::raw("SELECT udf2 FROM BAS_CODES WHERE codeid ='TRN_TYP' AND code='AD'"));
  321. $r_UDF2_AD = $bascode[0]->udf2 ?? 'N';
  322. $bascode = DB::select(DB::raw("SELECT udf2 FROM BAS_CODES WHERE codeid ='TRN_TYP' AND code='IN'"));
  323. $r_UDF2_IN = $bascode[0]->udf2 ?? 'N';
  324. $R_Qty_PlanPutaway = 0;
  325. $R_QCTaskID = '*';
  326. $R_HOLD_FLAG = 'N';
  327. $R_PA_TaskID = '*';
  328. $R_PA_Flag = 'N';
  329. $R_QC_Sequence = 0;
  330. $R_PA_Sequence = 0;
  331. $R_Reserve_Flag = 'N';
  332. $R_QtyMVOut = 0;
  333. $r_TotalGrossWeight = $In_TotalGrossWeight;
  334. $r_TotalCubic = $In_TotalCubic;
  335. $r_TotalNetWeight = $In_TotalNetWeight ?? 0;
  336. $r_TotalPrice = $In_TotalPrice;
  337. $In_LotAtt01 = $In_LotAtt01_C;
  338. $In_LotAtt02 = $In_LotAtt02_C;
  339. $In_LotAtt03 = $In_LotAtt03_C;
  340. $In_LotAtt04 = $In_LotAtt04_C;
  341. $In_LotAtt05 = $In_LotAtt05_C;
  342. $In_LotAtt06 = $In_LotAtt06_C;
  343. $In_LotAtt07 = $In_LotAtt07_C;
  344. $In_LotAtt08 = $In_LotAtt08_C;
  345. $In_LotAtt09 = $In_LotAtt09_C;
  346. $In_LotAtt10 = $In_LotAtt10_C;
  347. $In_LotAtt11 = $In_LotAtt11_C;
  348. $In_LotAtt12 = $In_LotAtt12_C;
  349. $In_HoldRejectCode = $In_HoldRejectCode_C;
  350. $In_HoldRejectReason = $In_HoldRejectReason_C;
  351. $In_TOLocation = $In_TOLocation_C;
  352. $In_New_TraceID = $In_New_TraceID_C ?? '*';
  353. $In_QC_Type = $In_QC_Type_C;
  354. $In_FMTraceID = $In_FMTraceID_C;
  355. $In_ASNNo = $In_ASNNo_C;
  356. $In_ASNLineNo = $In_ASNLineNo_C;
  357. $In_PONo = $In_PONo_C;
  358. $In_PlanToLoc = $In_PlanToLoc_C;
  359. $r_nrow = 0;
  360. $OUT_Return_Code = '*_*';
  361. //此处调用必然返回000,所以直接忽视判断进入下层逻辑
  362. $OUT_Return_Code = $this->SPUDF_ProcessA($IN_Warehouse,'RCV_BEFORE',$In_ASNNo,$In_ASNLineNo,$In_ReceivedQty,$In_Language,$In_UserID,$OUT_Return_Code);
  363. //TODO 盲收逻辑 SPASN_Receiving_Process:536行 $In_Process_Action = 2
  364. //如果订单已经关闭或者取消,则报错
  365. $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')"));
  366. if ($doc_asn_header) return '201';
  367. //收货数量必须大于0
  368. if ($In_ReceivedQty <= 0 && ((!$In_ProductStatus) || $In_ProductStatus == '00')) return '204';
  369. //批次属性自动复制 系统配置是否允许超量收货
  370. $customer = DB::connection('oracle')->select(DB::raw("SELECT OverReceiving,OverRCVPercentage,ASN_LNK_PO,AsnRef1ToLot4,AsnRef2ToLot5,AsnRef3ToLot6,AsnRef4ToLot7,AsnRef5ToLot8 FROM Bas_Customer WHERE CustomerID='".$In_CustomerID."' AND Customer_Type = 'OW'"));
  371. if (!$customer) return '888BAS_Customer,OPEN';
  372. $R_OverReceiving = $customer[0]->overreceiving ?? 'N';
  373. $R_OverRCVPercentage_Customer = $customer[0]->overrcvpercentage ?? 0;
  374. $r_ASN_LNK_PO = $customer[0]->asn_lnk_po ?? 'Y';
  375. $R_AsnRef1ToLot4 = $customer[0]->asnref1tolot4;
  376. $R_AsnRef2ToLot5 = $customer[0]->asnref2tolot5;
  377. $R_AsnRef3ToLot6 = $customer[0]->asnref3tolot6;
  378. $R_AsnRef4ToLot7 = $customer[0]->asnref4tolot7;
  379. $R_AsnRef5ToLot8 = $customer[0]->asnref5tolot8;
  380. $DOC_ASN_Header = DB::connection('oracle')->select(DB::raw("SELECT ASNReference1,ASNReference2,ASNReference3,ASNReference4,ASNReference5,ExpectedArriveTime1,ExpectedArriveTime2,QCStatus,ASNType,WarehouseID,ReleaseStatus,Priority FROM DOC_ASN_Header WHERE ASNNO='".$In_ASNNo."'"));
  381. if (!$DOC_ASN_Header) return '888DOC_ASN_Header,OPEN';
  382. $r_ASNReference1 = $DOC_ASN_Header[0]->asnreference1;
  383. $r_ASNReference2 = $DOC_ASN_Header[0]->asnreference2;
  384. $r_ASNReference3 = $DOC_ASN_Header[0]->asnreference3;
  385. $r_ASNReference4 = $DOC_ASN_Header[0]->asnreference4;
  386. $r_ASNReference5 = $DOC_ASN_Header[0]->asnreference5;
  387. $r_ExpectedArriveTime1 = $DOC_ASN_Header[0]->expectedarrivetime1 ?? "2000-01-01 00:00:00";
  388. $r_ExpectedArriveTime2 = $DOC_ASN_Header[0]->expectedarrivetime2 ?? "2099-12-31 00:00:00";
  389. $r_QCStatus = $DOC_ASN_Header[0]->qcstatus;
  390. $r_ASNType = $DOC_ASN_Header[0]->asntype;
  391. $r_WarehouseID = $DOC_ASN_Header[0]->warehouseid;
  392. $R_ReleaseStatus = $DOC_ASN_Header[0]->releasestatus;
  393. $r_Priority = $DOC_ASN_Header[0]->priority ?? '3';
  394. if ($R_AsnRef1ToLot4 == 'Y' && ($r_ASNReference1 && $r_ASNReference1 != "*") && ((!$In_LotAtt04) || $In_LotAtt04=='*')){
  395. $In_LotAtt04 = $r_ASNReference1;
  396. }
  397. if ($R_AsnRef2ToLot5 == 'Y' && ($r_ASNReference2 && $r_ASNReference2 != "*") && ((!$In_LotAtt05) || $In_LotAtt05=='*')){
  398. $In_LotAtt05 = $r_ASNReference2;
  399. }
  400. if ($R_AsnRef3ToLot6 == 'Y' && ($r_ASNReference3 && $r_ASNReference3 != "*") && ((!$In_LotAtt06) || $In_LotAtt06=='*')){
  401. $In_LotAtt06 = $r_ASNReference3;
  402. }
  403. if ($R_AsnRef4ToLot7 == 'Y' && ($r_ASNReference4 && $r_ASNReference4 != "*") && ((!$In_LotAtt07) || $In_LotAtt07=='*')){
  404. $In_LotAtt07 = $r_ASNReference4;
  405. }
  406. if ($R_AsnRef5ToLot8 == 'Y' && ($r_ASNReference5 && $r_ASNReference5 != "*") && ((!$In_LotAtt08) || $In_LotAtt08=='*')){
  407. $In_LotAtt08 = $r_ASNReference5;
  408. }
  409. if ($In_LotAtt01 == 'YYYY-MM-DD') $In_LotAtt01 = null;
  410. if ($In_LotAtt02 == 'YYYY-MM-DD') $In_LotAtt02 = null;
  411. if ($In_LotAtt03 == 'YYYY-MM-DD') $In_LotAtt03 = null;
  412. // TODO SPASN_Receiving_Process:643行 IN_ProductStatus固定值00 跳过
  413. //生产日期、入库日期、失效日期的逻辑校验
  414. if (($In_LotAtt01 && $In_LotAtt02 && Carbon::parse($In_LotAtt01)->gte(Carbon::parse($In_LotAtt02))) || ($In_LotAtt01 && Carbon::parse($In_LotAtt01)->gt(Carbon::parse($R_CurrentTime)))){
  415. return "260";
  416. }
  417. $r_ASN_MDT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_MDT_CHK');
  418. //入库生产日期不能小于在库库存生产日期
  419. if ($r_ASN_MDT_CHK == 'Y' && trim($In_LotAtt01)){
  420. $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.
  421. "' AND a.sku='".$In_SKU."' AND a.LotNum=b.LotNum AND a.LocationID=c.LocationID AND c.LocationUsage<>'ST' AND b.LotAtt01>'".$In_LotAtt01."'"));
  422. if ($data) return '266INV_LOT_LOC_ID';
  423. }
  424. //批次属性必输校验
  425. $BAS_lotID = DB::connection('oracle')->select(DB::raw("SELECT LotAtt01_Flag,LotAtt02_Flag,LotAtt03_Flag,LotAtt04_Flag,LotAtt05_Flag,LotAtt06_Flag,".
  426. "LotAtt07_Flag,LotAtt08_Flag,LotAtt09_Flag,LotAtt10_Flag,LotAtt11_Flag,LotAtt12_Flag,OverRCVPercentage,a.LotID,PackID,".
  427. "GrossWeight,Cube,CopyPackIDToLotAtt12,AllowReceiving,A.SKU_Group1 FROM Bas_SKU a, BAS_lotID b WHERE a.CustomerID='".$In_CustomerID."' AND a.sku='".$In_SKU."' AND a.LotID=b.LotID"));
  428. if (!$BAS_lotID)return "888From Bas_SKU*BAS_lotID,OPEN";
  429. $r_LotAtt01_Flag = $BAS_lotID[0]->lotatt01_flag;
  430. $r_LotAtt02_Flag = $BAS_lotID[0]->lotatt02_flag;
  431. $r_LotAtt03_Flag = $BAS_lotID[0]->lotatt03_flag;
  432. $r_LotAtt04_Flag = $BAS_lotID[0]->lotatt04_flag;
  433. $r_LotAtt05_Flag = $BAS_lotID[0]->lotatt05_flag;
  434. $r_LotAtt06_Flag = $BAS_lotID[0]->lotatt06_flag;
  435. $r_LotAtt07_Flag = $BAS_lotID[0]->lotatt07_flag;
  436. $r_LotAtt08_Flag = $BAS_lotID[0]->lotatt08_flag;
  437. $r_LotAtt09_Flag = $BAS_lotID[0]->lotatt09_flag;
  438. $r_LotAtt10_Flag = $BAS_lotID[0]->lotatt10_flag;
  439. $r_LotAtt11_Flag = $BAS_lotID[0]->lotatt11_flag;
  440. $r_LotAtt12_Flag = $BAS_lotID[0]->lotatt12_flag;
  441. $r_OverRCVPercentage_SKU = $BAS_lotID[0]->overrcvpercentage ?? 0;
  442. $r_SKU_LOTID = $BAS_lotID[0]->lotid;
  443. $r_SKU_PackID = $BAS_lotID[0]->packid;
  444. $r_SKU_GrossWeight = $BAS_lotID[0]->grossweight;
  445. $r_SKU_Cube = $BAS_lotID[0]->cube;
  446. $r_CopyPackIDToLotAtt12 = $BAS_lotID[0]->copypackidtolotatt12;
  447. $r_AllowReceiving = $BAS_lotID[0]->allowreceiving;
  448. $r_SKU_Group1 = $BAS_lotID[0]->sku_group1;
  449. //是否被设置禁止入库
  450. if ($r_AllowReceiving == 'N') return "117";
  451. if (($r_LotAtt01_Flag == '3' && !$In_LotAtt01) ||
  452. ($r_LotAtt02_Flag == "3" && !$In_LotAtt02) ||
  453. ($r_LotAtt03_Flag == "3" && !$In_LotAtt03) ||
  454. ($r_LotAtt04_Flag == "3" && !$In_LotAtt04) ||
  455. ($r_LotAtt05_Flag == "3" && !$In_LotAtt05) ||
  456. ($r_LotAtt06_Flag == "3" && !$In_LotAtt06) ||
  457. ($r_LotAtt07_Flag == "3" && !$In_LotAtt07) ||
  458. ($r_LotAtt08_Flag == "3" && !$In_LotAtt08) ||
  459. ($r_LotAtt09_Flag == "3" && !$In_LotAtt09) ||
  460. ($r_LotAtt10_Flag == "3" && !$In_LotAtt10) ||
  461. ($r_LotAtt11_Flag == "3" && !$In_LotAtt11) ||
  462. ($r_LotAtt12_Flag == "3" && !$In_LotAtt12))return "221".$In_ASNLineNo_C;
  463. if ($r_LotAtt01_Flag == '1' && $In_LotAtt01) $In_LotAtt01 = null;
  464. if ($r_LotAtt02_Flag == '1' && $In_LotAtt02) $In_LotAtt02 = null;
  465. if ($r_LotAtt03_Flag == '1' && $In_LotAtt03) $In_LotAtt03 = null;
  466. if ($r_LotAtt04_Flag == '1' && $In_LotAtt04) $In_LotAtt04 = null;
  467. if ($r_LotAtt05_Flag == '1' && $In_LotAtt05) $In_LotAtt05 = null;
  468. if ($r_LotAtt06_Flag == '1' && $In_LotAtt06) $In_LotAtt06 = null;
  469. if ($r_LotAtt07_Flag == '1' && $In_LotAtt07) $In_LotAtt07 = null;
  470. if ($r_LotAtt08_Flag == '1' && $In_LotAtt08) $In_LotAtt08 = null;
  471. if ($r_LotAtt09_Flag == '1' && $In_LotAtt09) $In_LotAtt09 = null;
  472. if ($r_LotAtt10_Flag == '1' && $In_LotAtt10) $In_LotAtt10 = null;
  473. //if ($r_LotAtt11_Flag == '1' && $In_LotAtt11) $In_LotAtt11 = null;
  474. if ($r_LotAtt12_Flag == '1' && $In_LotAtt12) $In_LotAtt12 = null;
  475. $R_LOT_12_PKG = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'LOT_#12_PKG');
  476. // 批次属性12被设置为跟踪包装数量,不允许输入非数字字符'
  477. if ($R_LOT_12_PKG == 'Y' && !is_numeric($In_LotAtt12)) return "232";
  478. if ($r_OverRCVPercentage_SKU != 0) $r_OverRCVPercentage = $r_OverRCVPercentage_SKU;
  479. else $r_OverRCVPercentage = $R_OverRCVPercentage_Customer;
  480. // TODO 药品相关逻辑 SPASN_Receiving_Process:817行 药品有效期 证书有效期 经营许可证有效期校验提示
  481. //基础设置是否维护完全校验
  482. $R_BAS_PAC_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_PAC_CHK');
  483. $R_BAS_LOT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_LOT_CHK');
  484. $R_BAS_GWT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_GWT_CHK');
  485. $R_BAS_CUB_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_CUB_CHK');
  486. if ($R_BAS_PAC_CHK == 'Y' && !$r_SKU_PackID)return '110'.$In_SKU;
  487. if ($R_BAS_LOT_CHK == 'Y' && !$r_SKU_LOTID)return '111';
  488. if ($R_BAS_GWT_CHK == 'Y' && $r_SKU_GrossWeight == 0)return '112';
  489. if ($R_BAS_CUB_CHK == 'Y' && $r_SKU_Cube == 0)return '113';
  490. //订单释放状态校验
  491. if($R_ReleaseStatus == 'N') return '226';
  492. /*参数准备 */
  493. //必须输入价格
  494. $R_UNT_PRI_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'UNT_PRI_CTL');
  495. //收货后打印上架标签
  496. $R_PRT_PTA_LBL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PRT_PTA_LBL');
  497. //ASN收货自动产生跟踪号
  498. $r_ASN_GEN_TID = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_GEN_TID');
  499. //收货后将收货结果更新ASN明细
  500. $r_ASN_RCV_UPD = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_RCV_UPD');
  501. //完全收货后自动关闭ASN
  502. $r_RCV_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_CTL');
  503. //超过产品有效期控制天数是否拒收
  504. $r_EXP_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'EXP_CTL');
  505. //码盘后才能收货
  506. $r_PLT_RCV = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PLT_RCV');
  507. //跨区域货物是否允许收到一个托盘上
  508. $r_RCV_CRS_ARA = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_CRS_ARA');
  509. //收货时必须指定跟踪号
  510. $r_RCV_TID_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_TID_CTL');
  511. //超额收货
  512. $R_OverReceiving = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'OVR_RCV');
  513. //收货时间必须在预期到货时间范围内
  514. $r_RCV_TIM_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_TIM_CTL');
  515. //同一跟踪号不允许在收货区重复收货
  516. $r_RCV_MIX_TID = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_TID');
  517. //只有上架确认后才能关闭ASN
  518. $r_PTA_CLS_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PTA_CLS_CHK');
  519. //收货数量拆分寻找目标库位
  520. $r_RCV_BRK_TSK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_BRK_TSK');
  521. //扫描收货时记录箱码和序列号
  522. $r_SN_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'SN#_CTL','0');
  523. //质检后才能收货
  524. $r_QC_RCV_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'QC_RCV_CTL');
  525. //目标库位为拆零拣货位拆箱时作废箱码
  526. $r_PCK_LOS_SN = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PCK_LOS_SN');
  527. //服装行业插件开关
  528. $r_IND_TEX = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'IND_TEX');
  529. if ($In_Process_Action != '2'){
  530. $DOC_ASN_DETAiLS = DB::connection('oracle')->select(DB::raw("SELECT ExpectedQty_Each,ReceivedQty_Each,POLineNO,PONO,OverRCVPercentage,ContainerID,QCStatus FROM DOC_ASN_DETAiLS WHERE ASNNO='".$In_ASNNo."' AND ASNLineNo='".$In_ASNLineNo."' FOR UPDATE"));
  531. if (!$DOC_ASN_DETAiLS)return '104'.$In_ASNNo.":".$In_ASNLineNo;
  532. $r_ExpectedQty_Each_ASN = $DOC_ASN_DETAiLS[0]->expectedqty_each;
  533. $r_ReceivedQty_Each_ASN = $DOC_ASN_DETAiLS[0]->receivedqty_each;
  534. $r_POLineNO = $DOC_ASN_DETAiLS[0]->polineno;
  535. $r_PONO = $DOC_ASN_DETAiLS[0]->pono;
  536. $R_OverRCVPercentage_ASN = $DOC_ASN_DETAiLS[0]->overrcvpercentage;
  537. $r_ASNContainerID = $DOC_ASN_DETAiLS[0]->containerid ?? '';
  538. $r_QCStatus = $DOC_ASN_DETAiLS[0]->qcstatus ?? '';
  539. }
  540. //目标库位属性
  541. if ($In_TOLocation == '*' || !trim($In_TOLocation))$In_TOLocation = $In_FMLocation;
  542. $BAS_Location = DB::connection('oracle')->select(DB::raw("SELECT LocationUsage,LoseID_Flag,Mix_Flag,Mix_LotFlag,LocationAttribute,SKUCount FROM BAS_Location WHERE LocationID='".$In_TOLocation."'"));
  543. if (!$BAS_Location)return '104'.$In_TOLocation;
  544. $R_LocationUsage = $BAS_Location[0]->locationusage;
  545. $R_LoseID_Flag = $BAS_Location[0]->loseid_flag ?? 'N';
  546. $R_Mix_Flag = $BAS_Location[0]->mix_flag ?? 'Y';
  547. $R_Mix_LotFlag = $BAS_Location[0]->mix_lotflag ?? 'Y';
  548. $r_LocationAttribute = $BAS_Location[0]->locationattribute;
  549. $r_SKUCount = $BAS_Location[0]->skucount;
  550. if($r_QC_RCV_CTL == 'Y' && $r_QCStatus != '20')return '272';
  551. //如果ASN中ContainerID有值,并且收货SP没有传递跟踪号,则以ContainerID作为跟踪号
  552. if ($r_ASNContainerID && (!$In_New_TraceID || $In_New_TraceID == '*'))$In_New_TraceID = $r_ASNContainerID;
  553. $IN_New_TraceID_OLD = $In_New_TraceID;
  554. if ($r_RCV_TID_CTL == 'Y' && (!$In_New_TraceID || $In_New_TraceID=='*'))return '270';
  555. //必须维护单价后才能收货
  556. if ($R_UNT_PRI_CTL == 'Y'){
  557. if (!$In_TotalPrice || $In_TotalPrice <= 0)return '050';
  558. }
  559. if($r_RCV_TIM_CTL == 'Y' && ($R_CurrentTime->lt(Carbon::parse($r_ExpectedArriveTime1)) || $R_CurrentTime->gt($r_ExpectedArriveTime2)))return '271';
  560. // 同一跟踪号不允许混收产品
  561. if (strtoupper($In_FMLocation) == 'SCANSTATION')$r_RCV_MIX_SKU = 'Y';
  562. else $r_RCV_MIX_SKU=$this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_SKU', 'Y');
  563. $r_RCV_MIX_GR1 = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_GR1', 'Y','C');
  564. //跟踪号的校验处理
  565. if ($In_New_TraceID != '*' && trim($In_New_TraceID)){
  566. if ($R_LoseID_Flag == 'N'){
  567. if ($r_RCV_MIX_TID == 'N'){ //跟踪号是否可以多次收货
  568. $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 = '".
  569. $IN_Warehouse."' AND TraceID='".$In_New_TraceID."' AND qty>0"));
  570. if ($INV_LOT_LOC_ID) return '218跟踪号重复错误ID='.$In_New_TraceID;
  571. }else{
  572. if ($r_RCV_MIX_SKU == 'N'){
  573. $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 = '".
  574. $IN_Warehouse."' AND TraceID = '".$In_New_TraceID."' AND sku <> '".$In_SKU."' AND qty>0"));
  575. if ($TABLE_INV_LOT_LOC_ID) return '273';
  576. }elseif ($r_RCV_MIX_GR1 == 'N'){
  577. $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 = '".
  578. $IN_Warehouse."' AND TraceID='".$In_New_TraceID."' AND C.SKU_GROUP1 <> '".$r_SKU_Group1."' AND qty>0"));
  579. if ($TABLE_INV_LOT_LOC_ID)return '273';
  580. }
  581. //ID是否重复
  582. $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 ='".
  583. $IN_Warehouse."' AND a.LocationID<>'".$In_TOLocation."' AND a.TraceID='".$In_New_TraceID."' AND a.QTY>0"));
  584. if ($TABLE_INV_LOT_LOC_ID)return '218'.$In_New_TraceID;
  585. }
  586. }else $In_New_TraceID = '*';
  587. }
  588. //r_QtyOnHold:=0
  589. if (!trim($In_HoldRejectCode)) $In_HoldRejectCode = 'OK'; //TODO 1098行
  590. //ID合法性校验 禁止收货到封存库位
  591. if (in_array($r_LocationAttribute,["HD","FI"]))return '228';
  592. //混放产品校验
  593. if (($R_Mix_Flag == 'N' || $r_SKUCount > 0) && $R_LocationUsage != 'ST'){
  594. $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.
  595. "' AND Qty > 0"));
  596. if ($TABLE_inv_lot_LOC_ID){
  597. if ($TABLE_inv_lot_LOC_ID[0]->c >= 1 && $R_Mix_Flag == 'N')return '205'.rtrim($In_TOLocation);
  598. elseif ($R_Mix_Flag == 'Y' && $r_SKUCount > 0 && $TABLE_inv_lot_LOC_ID[0]->c >= $r_SKUCount) return '367'.$r_SKUCount;
  599. }
  600. }
  601. //码盘后才能收货
  602. if (!rtrim($In_FMTraceID))$In_FMTraceID = '*';
  603. if ($r_PLT_RCV == 'Y' && $In_FMTraceID == '*')return '217';
  604. if ($In_FMTraceID != '*'){
  605. //无论是ASn收货还是码盘收货, 交易里的FMUOM/QTY/Packid都取收货的数据
  606. $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 ".
  607. "WHERE TraceID=In_FMTraceID AND ASNNO='".$In_ASNNo."' AND ASNLineNO='".$In_ASNLineNo."'"));
  608. if (!$TABLE_DOC_Trace_Details) return '104'.$In_ASNNo.":".$In_ASNLineNo;
  609. $r_PlanToLoc_Trace = $TABLE_DOC_Trace_Details[0]->plantoloc;
  610. $r_TraceUOM = $TABLE_DOC_Trace_Details[0]->uom;
  611. $r_LineStatus_Trace = $TABLE_DOC_Trace_Details[0]->linestatus;
  612. $R_Reserve_Flag = $TABLE_DOC_Trace_Details[0]->reserve_flag;
  613. $r_Lotnum_Trace = $TABLE_DOC_Trace_Details[0]->lotnum;
  614. $r_CancelQty_Trace = $TABLE_DOC_Trace_Details[0]->expectedqty_each - $TABLE_DOC_Trace_Details[0]->receivedqty_each;
  615. if ($R_Reserve_Flag == 'Y' && $R_LocationUsage != 'ST'){
  616. $OUT_Return_Code = '*_*';
  617. $OUT_Return_Code = $this->spasn_reserve_cancel($IN_Warehouse, 'TRACEID', $In_ASNNo, $In_ASNLineNo, $In_FMTraceID, $In_Language, $In_UserID, $OUT_Return_Code);
  618. if (substr($OUT_Return_Code,1,3) != '000'){
  619. DB::rollBack();
  620. return $OUT_Return_Code;
  621. }
  622. }
  623. }else{
  624. //没有码盘
  625. $r_FMUOM = $In_UOM;
  626. $r_FMPackID = $In_PackID;
  627. $r_FMQty_Each = '';
  628. $r_FMQty = $In_ReceivedQty;
  629. }
  630. //收货时使用的包装数量转换
  631. $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."'"));
  632. if (!$TABLE_bas_Package)return '104'.$In_PackID;
  633. $r_QTY1_P = $TABLE_bas_Package[0]->qty1;
  634. $r_QTY2_P = $TABLE_bas_Package[0]->qty2;
  635. $r_QTY3_P = $TABLE_bas_Package[0]->qty3;
  636. $r_QTY4_P = $TABLE_bas_Package[0]->qty4;
  637. $r_QTY5_P = $TABLE_bas_Package[0]->qty5;
  638. $r_IN_Label1 = $TABLE_bas_Package[0]->in_label1;
  639. $r_IN_Label3 = $TABLE_bas_Package[0]->in_label3;
  640. $r_IN_Label4 = $TABLE_bas_Package[0]->in_label4;
  641. if ($r_CopyPackIDToLotAtt12 == 'Y')$In_LotAtt12 = $r_QTY3_P;
  642. if ($R_LOT_12_PKG == 'Y' && $In_UOM == 'CS')$R_UOMQty_Read = $In_LotAtt12;
  643. else{
  644. switch ($In_UOM){
  645. case 'EA':
  646. $R_UOMQty_Read = $r_QTY1_P;
  647. break;
  648. case 'IP':
  649. $R_UOMQty_Read = $r_QTY2_P;
  650. break;
  651. case 'CS':
  652. $R_UOMQty_Read = $r_QTY3_P;
  653. break;
  654. case 'PL':
  655. $R_UOMQty_Read = $r_QTY4_P;
  656. break;
  657. case 'OT':
  658. $R_UOMQty_Read = $r_QTY5_P;
  659. break;
  660. }
  661. }
  662. $r_FMQty_Each = ($r_FMQty ?? 0) * ($R_UOMQty_Read ?? 0);
  663. $r_ReceivedQty_Each = $In_ReceivedQty * ($R_UOMQty_Read ?? 0);
  664. if (!$r_TotalCubic) $r_TotalCubic = ($r_SKU_Cube ?? 0) * $r_ReceivedQty_Each;
  665. if ($In_Process_Action != 2){
  666. if ($R_OverRCVPercentage_ASN ?? false)$r_OverRCVPercentage = $R_OverRCVPercentage_ASN;
  667. //质检控制
  668. if ($r_QC_RCV_CTL == 'C'){ //校验合格数
  669. $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'"));
  670. if ($TABLE_ACT_QC_Transaction)$r_QCQTY_Pass = $TABLE_ACT_QC_Transaction[0]->pass;
  671. if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > ($r_QCQTY_Pass ?? 0)) return '225';
  672. }else{
  673. $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"));
  674. if ($TABLE_doc_QC_Details) $r_UDF1 = $TABLE_doc_QC_Details[0]->udf1;
  675. if ($r_UDF1 ?? false){
  676. if ($r_UDF1 == 'NOPASS')return '229'; //拒收,原因:质检不合格'
  677. if ($r_UDF1 == 'CONTROL'){
  678. $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'"));
  679. if ($TABLE_ACT_QC_Transaction) $r_QCQTY_Reject = $TABLE_ACT_QC_Transaction[0]->qcqty_reject;
  680. if (($r_ReceivedQty_Each_ASN ?? 0 + $r_ReceivedQty_Each) > ($r_ExpectedQty_Each_ASN ?? 0 - ($r_QCQTY_Reject ?? 0)))return '225'; //超出质检合格数
  681. }
  682. }
  683. }
  684. }
  685. //超量收货校验
  686. if ($R_OverReceiving != 'Y' && ($r_ExpectedQty_Each_ASN ?? false) && ($In_Process_Action != 2)){
  687. if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > $r_ExpectedQty_Each_ASN)return '215';
  688. if (($r_PONO ?? false) && $r_PONO != '*' && ($r_POLineNO ?? false)){
  689. $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."'"));
  690. if ($TABLE_DOC_PO_DETAiLS){
  691. $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
  692. $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
  693. }
  694. if ((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each > ($r_OrderedQty_PO ?? 0)))return '215'.$In_CustomerID.",PONo=".$r_PONO;
  695. }
  696. }
  697. if ($R_OverReceiving == 'Y' && $r_OverRCVPercentage && ($r_ExpectedQty_Each_ASN ?? false) && $In_Process_Action != 2){//有百分比限制
  698. $r_OVR_RCV_BY = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'OVR_RCV_BY','BOTH');
  699. if (in_array($r_OVR_RCV_BY,["ASN","BOTH"])){
  700. if (((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) / $r_ExpectedQty_Each_ASN) > (1+$r_OverRCVPercentage))return '215'.$In_CustomerID;
  701. }elseif (in_array($r_OVR_RCV_BY,["PO","BOTH"])){
  702. if (($r_PONO ?? false) && $r_PONO!='*' && ($r_POLineNO ?? false)){
  703. $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"));
  704. if ($TABLE_DOC_PO_DETAiLS){
  705. $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
  706. $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
  707. }
  708. if (((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each) / ($r_OrderedQty_PO ?? 0)) > (1+$r_OverRCVPercentage)) return '215'.$In_CustomerID.',PONo='.$r_PONO;
  709. }
  710. }
  711. }
  712. if ($In_ASNNo == '*') $r_DocType = '*';
  713. else $r_DocType = 'ASN';
  714. //RF收货产生新的ID [In_New_TraceID],自动打印上架标签
  715. if ($In_New_TraceID == '*' && ($R_PRT_PTA_LBL == 'Y' || $r_ASN_GEN_TID == 'Y')){
  716. if ($R_LoseID_Flag != 'Y'){
  717. // $OUT_Return_Code = $this->spcom_getidsequence(); //1331 此SP调用 恒定返回000 无意义调用
  718. $OUT_Return_Code = '000';
  719. }
  720. }
  721. //判断目标库位是否冻结 @LocationHold
  722. $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."'"));
  723. if ($TABLE_ACT_InventoryHold)$r_nrow = $TABLE_ACT_InventoryHold[0]->c;
  724. if ($r_nrow >= 1) $r_LocationHold = 'Y';
  725. $r_LogicalFMSequence = null;
  726. $r_LogicalToSequence = null;
  727. $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID= '".$In_PlanToLoc."'"));
  728. if (!$TABLE_BAS_Location) $r_LogicalToSequence = 0;
  729. else $r_LogicalToSequence = $TABLE_BAS_Location[0]->logicalsequence;
  730. $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID='".$In_TOLocation."'"));
  731. if (!$TABLE_BAS_Location) $r_LogicalFMSequence = 0;
  732. else $r_LogicalFMSequence = $TABLE_BAS_Location[0]->logicalsequence;
  733. $r_MaxPATaskID_Sequence = 0;
  734. $r_MaxQCTaskID_Sequence = 0;
  735. // <<Loop1>>
  736. //批号处理
  737. if ($In_Process_Action != '2'){
  738. $r_nrow = 1;
  739. $query = DB::raw("SELECT LotNum from INV_LOT_ATT where CustomerID='".$In_CustomerID."' and SKU=in_SKU".
  740. " and nvl(LotAtt01,'*')=nvl(rtrim('".$In_LotAtt01."'),'*') and nvl(LotAtt02,'*')=nvl(rtrim('".$In_LotAtt02."'),'*') and nvl(LotAtt03,'*')=nvl(rtrim('".$In_LotAtt03."'),'*')".
  741. " and nvl(LotAtt04,'*')=nvl(rtrim('".$In_LotAtt04."'),'*') and nvl(LotAtt05,'*')=nvl(rtrim('".$In_LotAtt05."'),'*') and nvl(LotAtt06,'*')=nvl(rtrim('".$In_LotAtt06."'),'*')".
  742. " and nvl(LotAtt07,'*')=nvl(rtrim('".$In_LotAtt07."'),'*') and nvl(LotAtt08,'*')=nvl(rtrim('".$In_LotAtt08."'),'*') and nvl(LotAtt09,'*')=nvl(rtrim('".$In_LotAtt09."'),'*')".
  743. " and nvl(LotAtt10,'*')=nvl(rtrim('".$In_LotAtt10."'),'*') and nvl(LotAtt11,'*')=nvl(rtrim('".$In_LotAtt11."'),'*') and nvl(LotAtt12,'*')=nvl(rtrim('".$In_LotAtt12."'),'*') and rownum=1");
  744. $data = DB::connection('oracle')->select($query);
  745. if (!$data) $r_nrow = 0;
  746. else $r_Return_LotNum = $data[0]->lotnum;
  747. //产生新的批号
  748. if($r_nrow <= 0){
  749. //SP: SPCOM_GetIDSequence(IN_Warehouse,IN_Language,'LOTNumber',r_Return_LotNum,OUT_Return_Code);
  750. $r_Return_LotNum = '0';
  751. $OUT_Return_Code = '000';
  752. //TODO CREATE INV_LOT_ATT
  753. 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"),
  754. [$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)
  755. ,rtrim($In_LotAtt07),rtrim($In_LotAtt08),rtrim($In_LotAtt09),rtrim($In_LotAtt10),rtrim($In_LotAtt11),rtrim($In_LotAtt12)
  756. ,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString()]);
  757. }
  758. //预约库存的数量处理
  759. $r_Lotnum_Trace = $r_Lotnum_Trace ?? '';
  760. $r_PlanToLoc_Trace = $r_PlanToLoc_Trace ?? '';
  761. $r_Return_LotNum = $r_Return_LotNum ?? '';
  762. if ($R_Reserve_Flag == 'Y' && $R_LocationUsage == 'ST' && ($r_Lotnum_Trace ?? '') != $r_Return_LotNum){ //有预约,并且是收到ST库位,批次发生变化
  763. //TODO UPDATE
  764. DB::connection('oracle')->update(DB::raw('UPDATE INV_LOT_LOC_ID SET QTYPA = QTYPA - ? WHERE lotnum = ? and LocationID = ? and traceid = ?'),
  765. [(int)($r_CancelQty_Trace ?? 0),$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
  766. //TODO DELETE
  767. 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'),
  768. [$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
  769. DB::connection('oracle')->select(DB::raw('Select * from INV_LOT_LOC_ID Where LotNum=? and LocationID=? and TraceID=? for update'),[
  770. $r_Return_LotNum, $r_PlanToLoc_Trace, $In_FMTraceID
  771. ]);
  772. $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 = ?'),[
  773. $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
  774. ]);
  775. if ($TABLE_inv_lot_loc_id[0]->c > 0){
  776. //TODO UPDATE
  777. DB::connection('oracle')->update(DB::raw('update inv_lot_loc_id set QTYPA = QTYPA + ? where lotnum = ? and LocationID = ? and traceid = ?'),[
  778. (int)$r_ReceivedQty_Each,$r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
  779. ]);
  780. }else{
  781. //TODO CREATE INV_LOT_LOC_ID
  782. 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'),[
  783. $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID,$In_CustomerID,$In_SKU,0,0,0,0,0,
  784. 0,0,0,0,0,0,0,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),
  785. $In_UserID,null,$r_ReceivedQty_Each
  786. ]);
  787. }
  788. }
  789. //混放批次校验
  790. if ($R_Mix_LotFlag == 'N' && $R_LocationUsage != 'ST'){
  791. $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=?'),[
  792. $In_TOLocation,$r_Return_LotNum,$In_CustomerID,$In_SKU
  793. ]);
  794. if ($TABLE_inv_lot_LOC_ID->c >= 1){
  795. DB::rollBack();
  796. return '206'.rtrim($In_TOLocation);
  797. }
  798. }
  799. //货架生命周期,失效日期,自动冻结
  800. $r_Flag = '0';
  801. if (trim($In_LotAtt02)){
  802. if ((strtotime($In_LotAtt02) ? true : false)){
  803. $r_nrow = 1;
  804. $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'"),[
  805. $In_CustomerID,$In_SKU
  806. ]);
  807. if (!$TABLE_BAS_SKU)$r_nrow=0;
  808. else {
  809. $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
  810. $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
  811. }
  812. }
  813. if ($r_nrow > 0)$r_Flag = '1';
  814. else $r_Flag = '0';
  815. if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_OutboundLifeDays)) ||
  816. ($r_InboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_InboundLifeDays)))){
  817. if ($r_EXP_CTL == 'Y')return '222'; //过期 拒收
  818. if ($r_EXP_CTL != 'N')$r_Hold_EP = 'Y';
  819. }
  820. }
  821. //货架生命周期,生产日期,自动冻结
  822. if ($In_LotAtt01 && !(strtotime($In_LotAtt01) ? true : false) && (!$r_Flag || $r_Flag = '0')){
  823. $r_nrow = 1;
  824. $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=?') ,[
  825. $In_CustomerID,$In_SKU,'Y','M'
  826. ]);
  827. if (!$TABLE_BAS_SKU)$r_nrow = 0;
  828. else {
  829. $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
  830. $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
  831. }
  832. if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_OutboundLifeDays)) ||
  833. ($r_InboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_InboundLifeDays)))){
  834. if ($r_EXP_CTL == 'Y')return '222'; //有效期受控 拒收
  835. if ($r_EXP_CTL != 'N') $r_Hold_EP ='Y';
  836. }
  837. }
  838. if (trim($In_ContainerID)){
  839. DB::connection('oracle')->update(DB::raw('Update DOC_ASN_SerialNo Set LotNum=?,edittime=?,editwho=? Where LocationID=? and TraceID=? and LotNum=?'),[
  840. $r_Return_LotNum,$R_CurrentTime,$In_UserID,$In_TOLocation,$In_New_TraceID,$In_ContainerID
  841. ]);
  842. }
  843. }
  844. //计算上架库位 1543-1716 INSERT UPDATE
  845. //QTYPA 写入INV_LOT_LOC_ID 1719-1752 INSERT UPDATE
  846. //更新库存MVOut数量 1754-1810 SP:SPASN_Putaway_Calculation INSERT DELETE
  847. //上架库位处理 QTYPA 写入INV_LOT_LOC_ID 1854-1918 UPDATE
  848. // 1920-1989 UPDATE
  849. //任务处理 1992-2105 INSERT
  850. //--指定上架任务时此表为空 TMP_Putaway_task
  851. //混托盘任务处理
  852. //拆分上架任务后,需要分别写入收货交易,不然取消收货会导致QTYPA负数错误 库存交易处理 2107-2294 INSERT
  853. //产生交易记录 INSERT
  854. //更新冻结数 SP:SPINV_Hold_Update
  855. //只有质检后才能上架
  856. //根据收货交易产生质检明细
  857. //获取数据精度
  858. //2298-2378 UPDATE INSERT SP
  859. //更新码盘明细 2403-2460 UPDATE
  860. //码盘收货
  861. //更新ASN明细和ASN Header 2462-2617 SP UPDATE
  862. //判断拒收是否超量r_RejectedQty_Each_ASN
  863. //拒收数量应该< 预期数量-已收数量-已拒数量-本次收货数量,否则报错“拒收数量超量错误”
  864. if ($In_ASNNo != '*'){
  865. $query = DB::raw('Select PackID,UOM,ExpectedQty,ExpectedQty_Each,RejectedQty,RejectedQty_Each,ReceivedQty,ReceivedQty_Each,POLineNO,PONO From DOC_ASN_Details Where ASNNO=? and ASNLineNO=? for update');
  866. $TABLE_DOC_ASN_Details = DB::connection('oracle')->selectOne($query,[$In_ASNNo,$In_ASNLineNo]);
  867. if (!$TABLE_DOC_ASN_Details) return '803'.$In_ASNNo;
  868. $r_PackID_ASN = $TABLE_DOC_ASN_Details->packid;
  869. $r_UOM_ASN = $TABLE_DOC_ASN_Details->uom;
  870. $r_ExpectedQty_ASN = $TABLE_DOC_ASN_Details->expectedqty;
  871. $r_ExpectedQty_Each_ASN = $TABLE_DOC_ASN_Details->expectedqty_each;
  872. $r_RejectedQty_ASN = $TABLE_DOC_ASN_Details->rejectedqty;
  873. $r_RejectedQty_Each_ASN = $TABLE_DOC_ASN_Details->rejectedqty_each;
  874. $r_ReceivedQty_ASN = $TABLE_DOC_ASN_Details->receivedqty;
  875. $r_ReceivedQty_Each_ASN = $TABLE_DOC_ASN_Details->receivedqty_each;
  876. $r_POLineNO = $TABLE_DOC_ASN_Details->polineno;
  877. $In_PONo = $TABLE_DOC_ASN_Details->pono;
  878. //拒收超量
  879. if ($R_OverReceiving != 'Y' && (int)$In_RejectedQty > ((int)$r_ExpectedQty_Each_ASN - (int)$r_RejectedQty_Each_ASN - (int)$r_ReceivedQty_Each_ASN - (int)$r_ReceivedQty_Each_ASN))return '220';
  880. $r_ReceivedQty_Each_ASN = $r_ReceivedQty_Each + $r_ReceivedQty_Each_ASN;
  881. switch ($r_UOM_ASN){
  882. case "EA":
  883. $r_UOMQty_ASN = $r_QTY1_P;
  884. break;
  885. case "IP":
  886. $r_UOMQty_ASN = $r_QTY2_P;
  887. break;
  888. case "CS":
  889. $r_UOMQty_ASN = $r_QTY3_P;
  890. break;
  891. case "PL":
  892. $r_UOMQty_ASN = $r_QTY4_P;
  893. break;
  894. case "OT":
  895. $r_UOMQty_ASN = $r_QTY5_P;
  896. break;
  897. default:
  898. $r_UOMQty_ASN = 0;
  899. break;
  900. }
  901. if ($r_UOMQty_ASN <= 0)return '103'.rtrim($r_PackID_ASN);
  902. if ($r_ReceivedQty_Each_ASN >= $r_ExpectedQty_Each_ASN)$r_LineStatus = '40';
  903. else $r_LineStatus = '30';
  904. if ($r_ASN_RCV_UPD == 'Y'){
  905. $query = DB::raw("Update DOC_ASN_Details Set LineStatus=? ,ReceivedQty= (ReceivedQty_Each+?)/ ?,ReceivedQty_Each=ReceivedQty_Each+?,ReceivedTime=? ,".
  906. "RejectedQty=(RejectedQty_Each + (?))/?,RejectedQty_Each=RejectedQty_Each + (?),Reserve_Flag='Y',HoldRejectCode=?,HoldRejectReason=?,EditTime=? , EditWho=?,".
  907. "LotAtt01=?,LotAtt02=?,LotAtt04=?,LotAtt05=?,LotAtt06=?,LotAtt07=?,LotAtt08=?,LotAtt09=?,LotAtt10=?,LotAtt11=?,LotAtt12=?,Operator= ? Where ASNNO=? and ASNLineNO=?");
  908. DB::connection('oracle')->update($query,[$r_LineStatus,(int)$r_ReceivedQty_Each,(int)$r_UOMQty_ASN,(int)$r_ReceivedQty_Each,$R_ReceivingTime->toDateTimeString(),
  909. (int)$In_RejectedQty,(int)$r_UOMQty_ASN,(int)$In_RejectedQty,$In_HoldRejectCode,
  910. $In_HoldRejectReason,$R_CurrentTime->toDateTimeString(),$In_UserID,
  911. $In_LotAtt01,$In_LotAtt02,$In_LotAtt04,$In_LotAtt05,$In_LotAtt06,$In_LotAtt07,$In_LotAtt08,$In_LotAtt09,$In_LotAtt10,$In_LotAtt11,$In_LotAtt12,$In_Operator,$In_ASNNo,$In_ASNLineNo]);
  912. }else{
  913. $query = DB::raw('Update DOC_ASN_Details Set LineStatus=? ,ReceivedQty= (ReceivedQty_Each+?)/ ?,ReceivedQty_Each=ReceivedQty_Each+?'.
  914. ",ReceivedTime=?,RejectedQty=(RejectedQty_Each + (? ))/?,RejectedQty_Each=RejectedQty_Each + (?),Reserve_Flag='Y',HoldRejectCode=?".
  915. ",HoldRejectReason=?,EditTime=? , EditWho=?,Operator= ? Where ASNNO=? and ASNLineNO=?");
  916. DB::connection('oracle')->update($query,[$r_LineStatus,(int)$r_ReceivedQty_Each,(int)$r_UOMQty_ASN,(int)$r_ReceivedQty_Each,
  917. $R_ReceivingTime->toDateTimeString(),(int)$In_RejectedQty,(int)$r_UOMQty_ASN,(int)$In_RejectedQty,$In_HoldRejectCode,
  918. $In_HoldRejectReason,$R_CurrentTime->toDateTimeString(),$In_UserID,$In_Operator,$In_ASNNo,$In_ASNLineNo]);
  919. }
  920. if ($r_LineStatus == '40'){
  921. $count = DB::connection('oracle')->selectOne(DB::raw("Select Count(1) c from DOC_ASN_Details Where ASNNO=? and ASNLineNO<>? and LineStatus < '40'"),[$In_ASNNo,$In_ASNLineNo]);
  922. $r_nrow = $count->c;
  923. if ($r_nrow > 0) $r_LineStatus = '30';
  924. }
  925. $query = DB::raw("Update DOC_ASN_Header Set ASNStatus=?,Reserve_Flag='Y',LastReceivingTime=?,EditTime=? , EditWho=? Where ASNNO=?");
  926. DB::connection('oracle')->update($query,[$r_LineStatus,$R_ReceivingTime->toDateTimeString(),$R_CurrentTime->toDateTimeString(),$In_UserID, $In_ASNNo]);
  927. if ($r_RCV_CTL == 'Y' && $r_LineStatus == '40'){
  928. $r_nrow = 0;
  929. if ($r_PTA_CLS_CHK == 'Y'){
  930. $count = DB::connection('oracle')->selectOne(DB::raw("select count(1) c from TSK_Tasklists Where DocNo=? and TaskProcess='00' And DocType='ASN'"),[$In_ASNNo]);
  931. $r_nrow = $count->c;
  932. }
  933. if ($r_nrow == 0){
  934. $r_LineStatus = '99';
  935. //断点回滚,关闭ASN如果失败回滚该次操作而不是将上方全部操作回滚
  936. DB::transaction(function (){
  937. //2595-2614 关闭ASN 调用SP SPASN_Close_Process 该SP抛错时不影响全局回滚
  938. });
  939. }
  940. }
  941. }
  942. //更新PO信息 2620-2697 UPDATE
  943. //删除TMP_Putaway_Task(上架任务临时表) 2808 DELETE
  944. //DB::connection('oracle')->delete(DB::raw('delete from TMP_Putaway_Task where TMPID=?'),[$r_TMPID]);
  945. //修改UDF_A的调用方式 SP 2812-2828
  946. //清除0库存 2831-2834 SP
  947. //结束返回与异常判断
  948. return $OUT_Return_Code;
  949. }
  950. /** 对于快速入库 $IN_Parameter1 = 'RCV_AFTER' | 'RCV_BEFORE'
  951. * 目前该SP只存在 RCV_AFTER(校验近期产品) 且已被注释
  952. */
  953. private function SPUDF_ProcessA($IN_Warehouse, $IN_Parameter1, $IN_Parameter2, $IN_Parameter3, $IN_Parameter4, $IN_Language, $IN_UserID, $OUT_Return_Code){
  954. $r_CurrentTime = Carbon::now();
  955. //TODO 状态为 分配之前 走此逻辑,本快速入库不存在分配之前 不会走此逻辑 保留一下
  956. if ($IN_Parameter1='ALLOCATION_BEFORE'){
  957. $doc_order_header = DB::connection('oracle')->select(DB::raw("SELECT t.Carrierid,t.soreference5 FROM DOC_ORDER_HEADER t WHERE ORDERNO='".$IN_Parameter2."'"));
  958. $r_Carrierid = $doc_order_header[0]->carrierid;
  959. $r_soreference5 = $doc_order_header[0]->soreference5;
  960. if (in_array($r_Carrierid,['ZTO','YUNDA','POSTB','YTO','STO','EMS','SF']) && !$r_soreference5){
  961. $OUT_Return_Code = '999面单号未获取!';
  962. DB::rollBack();
  963. return $OUT_Return_Code;
  964. }
  965. }
  966. //TODO 状态为 导入后的逻辑:SPUDF_ProcessA 77行起 此处忽略 IN_Parameter1='SO_IMPORT_AFTER'
  967. //TODO 装箱完成前,做一些数据处理:SPUDF_ProcessA 125行起 此处忽略 IN_Parameter1='PACKING_BEFORE'
  968. //TODO 装箱完成后,做一些数据处理:SPUDF_ProcessA 132行起 此处忽略 IN_Parameter1='PACKING_AFTER'
  969. //TODO 打印标记:SPUDF_ProcessA 281行起 此处忽略 IN_Parameter1='PRINT'
  970. //TODO 发货前校验是否全部复核:SPUDF_ProcessA 553行起 此处忽略 IN_Parameter1='SHIP_BEFORE'
  971. //TODO 转移时校验库位是否允许混放批次:SPUDF_ProcessA 594行起 此处忽略 IN_Parameter1='TRAPPROVE_BEFORE'
  972. //TODO 分配之后,如果是单品单件订单,更新deliveryno:SPUDF_ProcessA 658行起 此处忽略 IN_Parameter1='ALLOCATION_AFTER'
  973. //TODO 上架前,校验此货主是否必须有拣货位,如果无拣货位,则拦截 by mxl 20191205:SPUDF_ProcessA 675行起 此处忽略 IN_Parameter1='PA_BEFORE'
  974. //TODO ASN关闭后 针对JIANSHANG货主,订单关闭后将数据写入临时表CUS_ADJ_H by mxl 20191217:SPUDF_ProcessA 700行起 此处忽略 IN_Parameter1='ASNCLOSE_AFTER'
  975. //TODO SO关闭后 针对JIANSHANG货主,订单关闭后将数据写入临时表CUS_ADJ_H by mxl 20191217:SPUDF_ProcessA 734行起 此处忽略 IN_Parameter1='SHIP_AFTER'
  976. $OUT_Return_Code = '000';
  977. return $OUT_Return_Code;
  978. }
  979. private function GETSYS_configuration($IN_WarehouseID, $IN_CustomerID, $IN_OrderType, $IN_ConfigID, $IN_DefaultValue = 'N', $IN_ValueType = 'C')
  980. {
  981. if ($IN_ValueType == 'C'){
  982. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='".($IN_OrderType ?? '*')."' AND CONFIG_ID='".$IN_ConfigID."'"));
  983. if (!$sys_configuration){
  984. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  985. if (!$sys_configuration){
  986. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  987. if (!$sys_configuration){
  988. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='*' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  989. if (!$sys_configuration) return $IN_DefaultValue;
  990. }
  991. }
  992. }
  993. return trim($sys_configuration[0]->value_string);
  994. }
  995. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='".($IN_OrderType ?? '*')."' AND CONFIG_ID='".$IN_ConfigID."'"));
  996. if (!$sys_configuration){
  997. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  998. if (!$sys_configuration){
  999. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  1000. if (!$sys_configuration){
  1001. $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='*' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
  1002. if (!$sys_configuration) return $IN_DefaultValue;
  1003. }
  1004. }
  1005. }
  1006. return trim($sys_configuration[0]->value_string);
  1007. }
  1008. /** 码盘调用SP,大概率不会被使用,内部 为游标,UPDATE操作 */
  1009. private function spasn_reserve_cancel($in_warehouse, $in_by, $in_asnno, $in_asnlineno, $in_traceid, $in_language, $in_userid, $out_return_code){
  1010. $query = DB::raw('Select TraceID,ASNLineNO,CustomerID,SKU,PackID,UOM,LotNUM,PlanToLoc,ExpectedQty,ExpectedQty_Each,TotalGrossWeight,TotalCubic from DOC_Trace_DETAILS '.
  1011. "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".
  1012. " (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".
  1013. " (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'))");
  1014. if ($out_return_code == 'NO_COMMIT')$r_no_commit = 'N';
  1015. else $r_no_commit = 'Y';
  1016. $sp_sql_r = "''".$in_by."'',''".$in_asnno."'',''".$in_asnlineno."'',''".$in_traceid."'',''".$in_language."'',''".$in_userid."''";
  1017. $R_CurrentTime = Carbon::now();
  1018. if ($in_by != 'ASNNO' && strtoupper($in_by) != 'ASNLINENO' && strtoupper($in_by) != 'TRACEID')return '887SPASN_Reserve_Cancel';
  1019. $ccur_asns = DB::connection('oracle')->select($query);
  1020. foreach ($ccur_asns as $crow_asn){
  1021. $sp_sql_r = 'Fetch cCur_ASN';
  1022. $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."'"));
  1023. if ($TABLE_DOC_Trace_Details && $TABLE_DOC_Trace_Details[0]->c == 1){
  1024. // TODO UPDATE
  1025. $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.
  1026. "' WHERE LotNum='".$crow_asn->lotnum."' and LocationID='".$crow_asn->plantoloc."' and TraceID='".$crow_asn->traceid."'"));
  1027. if ($rowcount == 0) return 'INV_LOT_LOC_ID,UPDATE';
  1028. // TODO UPDATE
  1029. 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.
  1030. "' where ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."' and TraceID='".$crow_asn->traceid."'"));
  1031. $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)<>'*'"));
  1032. if (!$TABLE_DOC_Trace_Details){
  1033. //TODO UPDATE
  1034. 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."'"));
  1035. }
  1036. }
  1037. //TODO COMMIT
  1038. if ($r_no_commit == 'Y')DB::commit();
  1039. }
  1040. $TABLE_DOC_ASN_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM DOC_ASN_Details Where ASNNO='".$in_asnno."' and Reserve_Flag='Y'"));
  1041. if (!$TABLE_DOC_ASN_Details){
  1042. $sp_sql_r = 'Update DOC_ASN_Header';
  1043. //TODO UPDATE
  1044. 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."'"));
  1045. }
  1046. //TODO COMMIT
  1047. if ($r_no_commit == 'Y')DB::commit();
  1048. return '000';
  1049. }
  1050. //获取数据表的ID(PO, ASN, SO...) $in_sequence_name_c = TraceID LOTNumber TEMPID Traceid TransactionID TaskID QCNO TransactionID
  1051. private function spcom_getidsequence($in_warehouse, $in_language, $in_sequence_name_c, $out_returnno, $out_return_code){
  1052. $out_return_code = '000';
  1053. $out_returnno = '0';
  1054. $in_sequence_name = $in_sequence_name_c;
  1055. $r_id_sequence = -1;
  1056. $r_length = 0;
  1057. //TODO $IN_Parameter1 = 'IDSEQUENCE' 单多包裹逻辑校验 应该调用SPUDF_ProcessA 但其中单多部分逻辑已被注释 恒定返回000 此处同理恒定返回000 不会下行执行其他逻辑
  1058. return;
  1059. //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;"));
  1060. //return [$out_returnno,$out_return_code];
  1061. }
  1062. }