Transfer.php 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Transfer extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_transfer','transfer');
  8. $this->load->_model('Model_typeclass','typeclass');
  9. $this->load->_model('Model_warehouse','warehouse');
  10. $this->load->_model('Model_systemtransfer','systemtransfer');
  11. $this->load->_model('Model_excel','excel');
  12. $this->load->_model('Model_fullorder','fullorder');
  13. $this->load->_model('Model_fullordertt','fullordertt');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_purchase','purchase');
  16. $this->load->_model('Model_classid','classid');
  17. $this->load->_model('Model_express','express');
  18. $this->load->_model('Model_apiyy','apiyy');
  19. $this->load->_model('Model_shop','shop');
  20. $this->load->_model('Model_systemtransfer_cr','systemtransfer_cr');
  21. $this->load->_model("Model_logic_ding","logic_ding");
  22. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  23. $this->load->_model("Model_logic_order","logic_order");
  24. }
  25. //定义方法的调用规则 获取URI第二段值
  26. public function _remap($arg,$arg_array)
  27. {
  28. if($arg == 'add')
  29. {
  30. $this->_add();
  31. }
  32. else if($arg == 'edit')
  33. {
  34. $this->_edit($arg_array);
  35. }
  36. else if($arg == 'del')
  37. {
  38. $this->_del();
  39. }
  40. else if($arg == 'print')
  41. {
  42. $this->_print();
  43. }
  44. else if($arg == 'number')
  45. {
  46. $this->_number();
  47. }
  48. else if($arg == 'numberprint')
  49. {
  50. $this->_numberprint();
  51. }
  52. else if($arg == 'operate')
  53. {
  54. $this->_operate();
  55. }
  56. else if($arg == 'out')
  57. {
  58. $this->_out();
  59. }
  60. else if($arg == 'excel')
  61. {
  62. $this->_excel();
  63. }
  64. else if($arg == 'bdbb')
  65. {
  66. $this->_bdbb();
  67. }
  68. else if($arg == 'rk')
  69. {
  70. $this->_rk();
  71. }
  72. else if($arg == 'cqrk'){
  73. $this->_cqrk();
  74. }
  75. else if($arg == 'ck')
  76. {
  77. $this->_ck();
  78. }
  79. else if($arg == 'jgl')//交工率
  80. {
  81. $this->_jgl();
  82. }
  83. else if($arg == 'linqi')
  84. {
  85. $this->_linqi();
  86. }
  87. else if($arg == 'jiaji'){
  88. $this->_jiaji();
  89. }
  90. else if($arg == 'overtime_export'){
  91. $this->_overtime_export();
  92. }
  93. else if($arg == 'scz'){
  94. $this->_scz();
  95. }
  96. else if($arg == 'wjsrk'){
  97. $this->_wjsrk();
  98. }
  99. else if($arg == 'wjsrkexcel'){
  100. $this->_wjsrkexcel();
  101. }
  102. else if($arg == 'cqrkexcel'){
  103. $this->_cqrkexcel();
  104. }
  105. else if($arg == 'sczexcel'){
  106. $this->_sczexcel();
  107. }else if($arg == 'czbmsfcz'){
  108. $this->_czbmIsOutExcel();
  109. }
  110. else
  111. {
  112. $this->_index();
  113. }
  114. }
  115. //管理
  116. public function _index()
  117. {
  118. $t = array();
  119. $typeclass = $this->typeclass->find_all();
  120. foreach ($typeclass as $v)
  121. {
  122. $t[$v['id']] = $v['title'];
  123. }
  124. $post = $this->input->post(NULL, TRUE);
  125. if(isset($post['page']))
  126. {
  127. $page = $this->input->post('page',true);
  128. $perpage = $this->input->post('perpage',true);
  129. $type = $this->input->post('type',true);
  130. $where = "1=1 ";
  131. //数据排序
  132. $order_str = "id asc";
  133. if($type)
  134. {
  135. $where .= "and type = '$type'";
  136. }
  137. if(empty($page))
  138. {
  139. $start = 0;
  140. $perpage = 1;
  141. }
  142. else
  143. {
  144. $start = ($page - 1)*$perpage;
  145. }
  146. //取得信息列表
  147. $info_list = $this->transfer->find_all($where,'id,title,orvertime,overtime_one,overtime_two',$order_str,$start,$perpage);
  148. $total = $this->transfer->find_count($where);
  149. $pagenum = ceil($total/$perpage);
  150. $over = $total-($start+$perpage);
  151. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  152. echo json_encode($rows);exit;
  153. }
  154. $this->_Template('transfer',$this->data);
  155. }
  156. //添加
  157. public function _add()
  158. {
  159. $post = $this->input->post(NULL, TRUE);
  160. if(isset($post['title']))
  161. {
  162. $title = $this->input->post('title',true);
  163. if($this->transfer->find_all("title = '$title'"))
  164. {
  165. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  166. }
  167. if($this->transfer->insert($post))
  168. {
  169. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  170. }
  171. else
  172. {
  173. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  174. }
  175. }
  176. $this->_Template('transfer_add',$this->data);
  177. }
  178. //修改
  179. public function _edit($arg_array)
  180. {
  181. $post = $this->input->post(NULL, TRUE);
  182. if(isset($post['id']))
  183. {
  184. $id = $this->input->post('id',true);
  185. $title = $this->input->post('title',true);
  186. if($this->transfer->find_all("title = '$title' and id != '".$id."'"))
  187. {
  188. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  189. }
  190. if($this->transfer->save($post,$id))
  191. {
  192. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  193. }
  194. else
  195. {
  196. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  197. }
  198. }
  199. $arg_array = $arg_array[0];
  200. $transfer = $this->transfer->read($arg_array);
  201. $this->data['transfer'] = $transfer;
  202. $this->_Template('transfer_edit',$this->data);
  203. }
  204. //删除
  205. public function _del()
  206. {
  207. $post = $this->input->post(NULL, TRUE);
  208. if(isset($post['s']))
  209. {
  210. $id_arr = $this->input->post('s');
  211. $id_arr = explode(',',$id_arr);
  212. if(!$id_arr)
  213. {
  214. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  215. }
  216. //循环删除记录
  217. foreach ($id_arr as $v)
  218. {
  219. $this->transfer->remove($v);
  220. }
  221. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  222. }
  223. }
  224. public function _print()
  225. {
  226. if(isset($_SESSION['api']))
  227. {
  228. $user = $this->user->get_api($_SESSION['api']);
  229. $usp = $user;
  230. $sid = "";$wid="";$wtype="";
  231. $userwh = explode('|',trim($user['warehouse'],'|'));
  232. foreach ($userwh as $value)
  233. {
  234. $wid .= " id = ".$value." or";
  235. $wtype .= " type = ".$value." or";
  236. }
  237. }
  238. $post = $this->input->post(NULL, TRUE);
  239. $classid = $this->classid->sku();
  240. $pm = $classid;
  241. $scsku = $classid;
  242. if(isset($post['category']))
  243. {
  244. $list = array();$num = "";$title = "";$features = "";
  245. $order = 0;
  246. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  247. $t = $this->input->post('t',true);//打印数量
  248. if($xbqnum > 99)
  249. {
  250. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  251. }
  252. if($xbqnum < 1)
  253. {
  254. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  255. }
  256. $post['purchase'] = $this->input->post('purchase',true);//所属工厂
  257. $category = $this->input->post('category',true);
  258. $list['category'] = $category;
  259. $list['hairtype'] = $this->input->post('hairtype',true);
  260. $list['grade'] = $this->input->post('grade',true);
  261. $size = $this->input->post('size',true);
  262. $xzsku = $this->input->post('xzsku',true);
  263. $list['size'] = rtrim($size,',');
  264. $list['hairnumber'] = $this->input->post('hairnumber',true);
  265. $list['extension'] = $this->input->post('extension',true);
  266. if($category == 1297)
  267. {
  268. $list['sywignumber'] = $this->input->post('sywignumber',true);
  269. }
  270. if($category == 1702)
  271. {
  272. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  273. $list['syother'] = $this->input->post('syother',true);
  274. }
  275. if($category == 133)
  276. {
  277. $list['fittype'] = $this->input->post('fittype',true);
  278. $list['acother'] = $this->input->post('acother',true);
  279. }
  280. $list['color'] = $this->input->post('color',true);
  281. $list['lowe'] = $this->input->post('lowe',true);
  282. if($category == 127)
  283. {
  284. $list['type'] = $this->input->post('type',true);
  285. $list['headroad'] = $this->input->post('headroad',true);
  286. $list['density'] = $this->input->post('density',true);
  287. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  288. {
  289. $list['lacesize'] = $this->input->post('lacesize',true);
  290. }
  291. $list['lacecolor'] = $this->input->post('lacecolor',true);
  292. $list['lacetypes'] = $this->input->post('lacetypes',true);
  293. }
  294. if($category == 128)
  295. {
  296. $list['lacetype'] = $this->input->post('lacetype',true);
  297. $list['haircap'] = $this->input->post('haircap',true);
  298. $list['density'] = $this->input->post('density',true);
  299. $list['lacecolor'] = $this->input->post('lacecolor',true);
  300. $list['lacetypes'] = $this->input->post('lacetypes',true);
  301. $list['wigother'] = $this->input->post('wigother',true);
  302. $list['wigother1'] = $this->input->post('wigother1',true);
  303. $list['wigother2'] = $this->input->post('wigother2',true);
  304. }
  305. if($category == 129)
  306. {
  307. $list['wide'] = $this->input->post('wide',true);
  308. }
  309. if($category == 131)
  310. {
  311. $list['gifttype'] = $this->input->post('gifttype',true);
  312. $list['giftother'] = $this->input->post('giftother',true);
  313. }
  314. if($category == 134)
  315. {
  316. $list['pieceweight'] = $this->input->post('pieceweight',true);
  317. }
  318. if($category == 1297)
  319. {
  320. $list['synthetictype'] = $this->input->post('synthetictype',true);
  321. $list['sywigother'] = $this->input->post('sywigother',true);
  322. }
  323. if($category == 130 || $category == 133 || $category == 1702)
  324. {
  325. $list['items'] = $this->input->post('items',true);
  326. $list['weight'] = $this->input->post('weight',true);
  327. }
  328. if($category == 1702)
  329. {
  330. $list['syhairther'] = $this->input->post('syhairther',true);
  331. }
  332. foreach($list as $k=>$v)
  333. {
  334. if($v != 0)
  335. {
  336. $num .=$v;
  337. $features .=$v.'-';
  338. $post[$k] = $v;
  339. $typeclass = $this->typeclass->read($v);
  340. if(isset($pm[$typeclass['classid']]))
  341. {
  342. $pm[$typeclass['classid']] = $typeclass['zh'];
  343. }
  344. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  345. if($k != 'size')
  346. {
  347. $title .= $typeclass['title']." ";
  348. }
  349. }
  350. }
  351. $typeclass = $this->typeclass->read($list['size']);
  352. $title .= $typeclass['title'];
  353. $time = time();
  354. $post['printtime'] = $time;
  355. $post['title'] = rtrim($title,' ');
  356. $post['number'] = $num;
  357. $post['features'] = '-'.$features;
  358. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  359. $featurespp = explode('-',trim($featurespp,'-'));
  360. if(isset($featurespp[5]))
  361. {
  362. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  363. }
  364. else
  365. {
  366. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  367. }
  368. $post['time'] = $time;//操作时间
  369. $scsku = implode("-",$scsku);
  370. $zh = implode(" ",$pm);
  371. $zh = str_replace('自然色 ','',trim($zh,' '));
  372. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  373. $post['shipremarks'] = $zh;
  374. $scsku = str_replace('- ','-',trim($scsku,'-'));
  375. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  376. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;
  377. $post['sku'] = $bqsku;
  378. $post['rk'] = "|1|";//默认配货 打印后直接入库
  379. $post['rktime'] = "|".$time."|";
  380. $rows = array();
  381. $this->db->trans_begin();
  382. for($i=0;$i<$xbqnum;$i++)
  383. {
  384. $label = substr($time,1)*100;
  385. $post['label'] = $label+$i;
  386. $rows[] = array('num'=>$post['label'],'number'=>'','shipremarks'=>$zh,'ex'=>'','t'=>$t,'time'=>'布标打印时间:'.date('Y-m-d H:i:s',$time),'s'=>'('.($i+1).'/'.$xbqnum.')');
  387. $this->systemtransfer->insert($post);
  388. }
  389. if ($this->db->trans_status() === TRUE)
  390. {
  391. $this->db->trans_commit();
  392. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  393. }
  394. else
  395. {
  396. $this->db->trans_rollback();
  397. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  398. }
  399. }
  400. $purchase = $this->purchase->find_all("yyid != ''");
  401. $this->data['purchase'] = $purchase;
  402. $this->_Template('transfer_print',$this->data);
  403. }
  404. public function _number()
  405. {
  406. if(isset($_SESSION['api']))
  407. {
  408. $user = $this->user->get_api($_SESSION['api']);
  409. $pid = "";$tid="";$sid="";$wid="";
  410. $purchase = explode('|',trim($user['purchase'],'|'));
  411. $transfer = explode('|',trim($user['transfer'],'|'));
  412. foreach ($purchase as $value)
  413. {
  414. $pid .= " id = ".$value." or";
  415. }
  416. foreach ($transfer as $value)
  417. {
  418. $tid .= " id = ".$value." or";
  419. }
  420. }
  421. else
  422. {
  423. header('Location: /');exit;
  424. }
  425. $post = $this->input->post(NULL, TRUE);
  426. if(isset($post['number']))
  427. {
  428. $number = $this->input->post('number',true);
  429. $type = $this->input->post('type',true);
  430. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  431. $purchase = $this->input->post('purchase',true);
  432. // $f = 'fullorder';
  433. // $y = $this->fullorder->get_number($number);
  434. // if(!$y)
  435. // {
  436. // $f = 'fullordersmt';
  437. // $y = $this->fullordersmt->get_number($number);
  438. // if(!$y)
  439. // {
  440. // $f = 'fullordertt';
  441. // $y = $this->fullordertt->get_number($number);
  442. // if(!$y)
  443. // {
  444. // echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  445. // }
  446. // }
  447. // }
  448. $y = $this->logic_order->getInfo("number = '".$number."'");
  449. if(!$y)
  450. {
  451. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  452. }
  453. $f = $y['lv_platform'];
  454. if($y['librarytime'] > 0)
  455. {
  456. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  457. }
  458. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;$typeclass = array();
  459. $classid = $this->classid->sku();
  460. $tc = $this->typeclass->find_all();
  461. foreach($tc as $v)
  462. {
  463. $typeclass[$v['id']] = $v;
  464. }
  465. $bm = '03';
  466. $fpdata = explode(';',trim($y['fpdata'],';'));
  467. $whlabelsc = explode('|',trim($y['whlabel'],'|'));
  468. foreach($fpdata as $key=>$val)
  469. {
  470. $pm = $classid;
  471. $jm = $classid;
  472. $sku = $classid;
  473. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  474. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  475. $jvnr = explode('|',trim($features,'|'));
  476. if(stripos($jvnr[0],',') !== false)
  477. {
  478. $ft = explode(',',$jvnr[0]);
  479. $features = explode('-',trim($ft[1],'-'));
  480. array_splice($features,2,0,$ft[0]);
  481. }
  482. else
  483. {
  484. $features = explode('-',trim($jvnr[0],'-'));
  485. }
  486. $title = $jvnr[1];
  487. foreach($features as $k=>$v)
  488. {
  489. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  490. {
  491. if($typeclass[$v]['bm'] != '')
  492. {
  493. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  494. }
  495. }
  496. if($v != 0)
  497. {
  498. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  499. if(isset($pm[$typeclass[$v]['classid']]))
  500. {
  501. if($typeclass[$v]['title'] == '9A')
  502. {
  503. $pm[$typeclass[$v]['classid']] = '9A';
  504. }
  505. else if($typeclass[$v]['title'] == '10A')
  506. {
  507. $pm[$typeclass[$v]['classid']] = '10A';
  508. }
  509. else
  510. {
  511. $clzh = $typeclass[$v]['zh'];
  512. if(stripos($typeclass[$v]['zh'],'|') !== false)
  513. {
  514. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  515. $clzh = $clzh[0];
  516. }
  517. $pm[$typeclass[$v]['classid']] = $clzh;
  518. }
  519. }
  520. if(isset($jm[$typeclass[$v]['classid']]))
  521. {
  522. if($typeclass[$v]['jm'])
  523. {
  524. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  525. }
  526. }
  527. }
  528. }
  529. $jm = array_filter($jm);//去除空值
  530. $jm = implode("-",$jm);
  531. $sku = array_filter($sku);//去除空值
  532. $sku = implode("-",$sku);
  533. $pm = array_filter($pm);//去除空值
  534. $zh = implode(" ",$pm);
  535. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  536. $features = implode("-",$features);
  537. $y['shipremarks'] = str_replace("'",'"',$y['shipremarks']);
  538. $cp[] = array('ordernumber'=>$number,'title'=>$title,'sku'=>$sku,'jm'=>$jm,'zh'=>$zh,'n'=>$jvnr[2],'b'=>$y['shipremarks'],'is_jiaji'=>$y['is_jiaji'],'data'=>json_encode(array('ordernumber'=>$number,'features'=>$features,'number'=>$number,'title'=>$title,'jm'=>$jm,'sku'=>$sku,'pm'=>$zh,'bm'=>$bm.implode("",$bmpx))));
  539. }
  540. ob_clean();
  541. echo json_encode(array('rows'=>$cp,'success'=>true));exit;
  542. }
  543. $purchase = $this->purchase->find_all("yyid != ''");
  544. $this->data['purchase'] = $purchase;
  545. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  546. $this->data['transfer'] = $transfer;
  547. $this->_Template('transfer_number',$this->data);
  548. }
  549. public function _numberprint()
  550. {
  551. $time = time();
  552. $post = $this->input->post(NULL);
  553. $classid = $this->classid->sku();
  554. $pm = $classid;
  555. $scsku = $classid;
  556. if(isset($post['data']))
  557. {
  558. $data = json_decode($post['data'],true);
  559. // $f = 'fullorder';
  560. // $y = $this->fullorder->get_number($data['ordernumber']);
  561. // if(!$y)
  562. // {
  563. // $f = 'fullordersmt';
  564. // $y = $this->fullordersmt->get_number($data['ordernumber']);
  565. // if(!$y)
  566. // {
  567. // $f = 'fullordertt';
  568. // $y = $this->fullordertt->get_number($data['ordernumber']);
  569. // if(!$y)
  570. // {
  571. // echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  572. // }
  573. // }
  574. // }
  575. $y = $this->logic_order->getInfo("number = '".$data['ordernumber']."'");
  576. if(!$y)
  577. {
  578. echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  579. }
  580. $f = $y['lv_platform'];
  581. if($y['printtime'] == 0)
  582. {
  583. echo json_encode(array('msg'=>'此单已重置,请询问梦体','success'=>false));exit;
  584. }
  585. $order = 0;$time = time();
  586. $xbqnum = $this->input->post('n',true);//打印数量
  587. if($xbqnum > 99)
  588. {
  589. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  590. }
  591. if($xbqnum < 1)
  592. {
  593. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  594. }
  595. $transfer = $this->input->post('transfer',true);
  596. $post['type'] = $this->input->post('type',true);
  597. $post['shipremarks'] = $this->input->post('b',true);
  598. $post['ph'] = $this->input->post('ph',true);
  599. $is_jiaji = $this->input->post('is_jiaji',true);
  600. if($is_jiaji == 2){
  601. $post['is_jiaji'] = 2;
  602. }else{
  603. $post['is_jiaji'] = 0;
  604. }
  605. $zps = $this->input->post('zps',true);
  606. $post['purchase'] = $this->input->post('purchase',true);//供应商
  607. $post['time'] = $time;//操作时间
  608. $post['jm'] = $data['jm'];
  609. $post['bm'] = $data['bm'];
  610. $post['pm'] = $data['pm'];
  611. $post['features'] = $data['features'];
  612. $post['number'] = $data['number'];
  613. $post['title'] = $data['title'];
  614. $post['sku'] = $data['sku'];
  615. $post['printtime'] = $y['printtime'];
  616. $post['rk'] = "|12|";//默认订单中心 打印后直接入库
  617. $post['ck'] = "|12|";
  618. $post['rktime'] = "|".$time."|";
  619. $post['cktime'] = $post['rktime'];
  620. $post['ctime12'] = $time;
  621. $express = $this->express->read($y['express']);
  622. $rows = array();$t='';
  623. $this->db->trans_begin();
  624. $post['xbqnum'] = $xbqnum;
  625. $kh = $this->shop->read($y['shop']);
  626. $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']);
  627. //$this->logic_ding->sendToDing("小布表打印异常".json_encode($yy)."|".json_encode($y['number']));
  628. if($yy['c'] == 0)
  629. {
  630. $post['scapi'] = '99';
  631. $post['scid'] = $yy['scid'];
  632. if(!$post['purchase'])
  633. {
  634. $post['purchase'] = '';
  635. }
  636. $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'");
  637. //able_ext 实在打印小单布标时判断是否可以打印备货单
  638. $able_ext = 0;
  639. $tmp_fetaures = explode('-',$data['features']);
  640. //只有头套和马尾才会要配货单
  641. if(in_array(128, $tmp_fetaures)){
  642. $able_ext = 1;
  643. }
  644. if(in_array(133, $tmp_fetaures)){
  645. if(in_array(673, $tmp_fetaures)){
  646. $able_ext = 1;
  647. }
  648. }
  649. for($i=0;$i<$xbqnum;$i++)
  650. {
  651. if($post['zps'])
  652. {
  653. if($post['zps'] > 0)
  654. {
  655. $t = '总量:'.($mqsl+$i+1).'/'.$zps;
  656. }
  657. }
  658. $label = $time.rand(1000,9999); //substr($time,1)*100;
  659. $post['label'] = $label+$i;
  660. $rows[] = array('num'=>$post['label'],'number'=>$post['number'],'shipremarks'=>$post['shipremarks'],'ph'=>$post['ph'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$post['printtime']),'gtime'=>date('YmdH',time()),'s'=>'('.($i+1).'/'.$xbqnum.')','t'=>$t,'able_ext'=>$able_ext,'is_jiaji'=>$is_jiaji);
  661. $this->systemtransfer->insert($post);
  662. }
  663. }
  664. else
  665. {
  666. $this->db->trans_rollback();
  667. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  668. }
  669. if($this->db->trans_status() === TRUE)
  670. {
  671. $this->db->trans_commit();
  672. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  673. }
  674. else
  675. {
  676. $this->db->trans_rollback();
  677. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  678. }
  679. }
  680. }
  681. public function _operate()
  682. {
  683. $post = $this->input->post(NULL, TRUE);
  684. if(isset($post['page']))
  685. {
  686. $api = $this->input->post('api',true);
  687. $page = $this->input->post('page',true);
  688. $perpage = $this->input->post('perpage',true);
  689. $number = $this->input->post('number',true);
  690. $color = $this->input->post('color',true);
  691. $purchase = $this->input->post('purchase',true);
  692. $transfer = $this->input->post('transfer',true);
  693. $lx = $this->input->post('lx',true);
  694. $type = $this->input->post('type',true);
  695. $pm = $this->input->post('pm',true);
  696. $jiaji = $this->input->post('jiaji',true);
  697. $xztime = $this->input->post('xztime',true);
  698. $timetk = $this->input->post('timetk',true);
  699. $timetj = $this->input->post('timetj',true);
  700. $timetk = strtotime($timetk);
  701. $timetj = strtotime($timetj);
  702. $where = '1=1';
  703. if($number)
  704. {
  705. $where .= " and number = '$number'";
  706. }
  707. if($pm){
  708. $where .= " and pm like '%".$pm."%'";
  709. }
  710. if($purchase)
  711. {
  712. $where .= " and purchase = '$purchase'";
  713. }
  714. if($color)
  715. {
  716. $where .= " and fpdata like '%-".$color."-%'";
  717. }
  718. if($lx)
  719. {
  720. if($lx == 1)
  721. {
  722. $where .= " and ordernumber = ''";
  723. }
  724. else
  725. {
  726. $where .= " and ordernumber != ''";
  727. }
  728. }
  729. if($jiaji){
  730. if($jiaji == 1){
  731. $where .= " and is_jiaji = 0";
  732. }
  733. if($jiaji == 2){
  734. $where .= " and is_jiaji = 2";
  735. }
  736. }
  737. //数据排序
  738. $order_str = "id desc";
  739. if(empty($page))
  740. {
  741. $start = 0;
  742. $perpage = 1;
  743. }
  744. else
  745. {
  746. $start = ($page - 1)*$perpage;
  747. }
  748. if($xztime == 'printtime')
  749. {
  750. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  751. if($type)
  752. {
  753. if($type == 3){
  754. if($transfer)
  755. {
  756. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  757. }
  758. }else{
  759. $type = ($type==1)?'rk':'ck';
  760. if($transfer)
  761. {
  762. $where .= " and $type like '%|".$transfer."|%'";
  763. }
  764. }
  765. }
  766. else
  767. {
  768. if($transfer)
  769. {
  770. $where .= " and rk like '%|".$transfer."|%'";
  771. }
  772. }
  773. }
  774. else
  775. {
  776. $cr = "time > '$timetk' and time < '$timetj'";
  777. if($transfer)
  778. {
  779. $cr .= " and lx = '".$transfer."' ";
  780. }
  781. if($type)
  782. {
  783. if($type == 3){
  784. $cr .= " and is_over = 0 ";
  785. }else{
  786. $cr .= " and type = '".$type."' ";
  787. }
  788. }
  789. $fid = '';
  790. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  791. foreach ($info_list_cr as $v)
  792. {
  793. $fid .= "id = '".$v['fid']."' or ";
  794. }
  795. if($fid)
  796. {
  797. $where .= ' and ('.trim($fid,'or ').')';
  798. }
  799. else
  800. {
  801. $where .= ' and id = 0';
  802. }
  803. }
  804. //取得信息列表
  805. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  806. $transfer = $this->transfer->find_all();
  807. $t = array();
  808. foreach ($transfer as $v)
  809. {
  810. $t[$v['id']] = $v['title'];
  811. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  812. }
  813. //格式化数据
  814. foreach ($info_list as $key=>$value)
  815. {
  816. if($value['is_jiaji'] == 2){
  817. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  818. }else{
  819. $info_list[$key]['is_jiaji'] = "常规";
  820. }
  821. $dd = $this->systemtransfer->read($value['id']);
  822. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  823. $rk = explode('|',trim($dd['rk'],'|'));
  824. $rktime = explode('|',trim($dd['rktime'],'|'));
  825. $ck = explode('|',trim($dd['ck'],'|'));
  826. $cktime = explode('|',trim($dd['cktime'],'|'));
  827. $info_list[$key]['time'] = '';
  828. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  829. //"<h9 class='window' data-h='/returngoods/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>"
  830. $info_list[$key]['number'] = "<h9 class='window' data-h='/colour/seebynumber/".$value['number']."' data-t='订单号:".$value['number']."'><p>".$value['number']."</p></h9>";
  831. /**
  832. for($i=0;$i<count($rk);$i++)
  833. {
  834. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  835. {
  836. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  837. }
  838. else
  839. {
  840. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  841. }
  842. $info_list[$key]['time'] .= $d;
  843. if(isset($ck[$i]) && $ck[$i] != '')
  844. {
  845. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  846. }
  847. }
  848. **/
  849. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  850. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  851. foreach ($data as $k=>$v)
  852. {
  853. // $type = ($v['type']==1)?'入库':'出库';
  854. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  855. $type = ($v['type']==1)?'入库':'出库';
  856. if($v['orver_flag'] == 1){
  857. if($v['is_over'] == 0){
  858. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>";
  859. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  860. }else{
  861. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  862. }
  863. }elseif($v['orver_flag'] == 2){
  864. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>";
  865. }elseif($v['orver_flag'] == 3){
  866. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>";
  867. }else{
  868. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  869. }
  870. if($v['extra_status'] == 1){
  871. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  872. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  873. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  874. }else{
  875. $info_list[$key]['time'] .= "<br>";
  876. }
  877. }
  878. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  879. unset($info_list[$key]['ctime12']);
  880. }
  881. $total = $this->systemtransfer->find_count($where);
  882. $pagenum = ceil($total/$perpage);
  883. $over = $total-($start+$perpage);
  884. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  885. echo json_encode($rows);exit;
  886. }
  887. if(isset($_SESSION['api']))
  888. {
  889. $user = $this->user->get_api($_SESSION['api']);
  890. $usp = $user;
  891. $pid = "";$tid="";$sid="";$wid="";
  892. $purchase = explode('|',trim($user['purchase'],'|'));
  893. $transfer = explode('|',trim($user['transfer'],'|'));
  894. $warehouse = explode('|',trim($user['warehouse'],'|'));
  895. foreach ($purchase as $value)
  896. {
  897. $pid .= " id = ".$value." or";
  898. }
  899. foreach ($transfer as $value)
  900. {
  901. $tid .= " id = ".$value." or";
  902. }
  903. foreach ($warehouse as $value)
  904. {
  905. $wid .= " id = ".$value." or";
  906. }
  907. }
  908. else
  909. {
  910. header('Location: /');exit;
  911. }
  912. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  913. //只有admin和toutao用户可以查看
  914. if(in_array($user['id'],[10,44,50])){
  915. $sc_flag = 1;
  916. }
  917. $this->data['sc_flag'] = $sc_flag;
  918. $kx = '';$zjtab = '';
  919. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  920. $this->data['warehouse'] = $warehouse;
  921. $purchase = $this->purchase->find_all("yyid != ''");
  922. $this->data['purchase'] = $purchase;
  923. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  924. $this->data['transfer'] = $transfer;
  925. $this->data['vip'] = $user['vip'];
  926. $transfer_ids = array_column($transfer,'id');
  927. $transfer_str = implode(",",$transfer_ids);
  928. $this->data['cz_1_num'] = $this->systemtransfer_cr->find_count("orver_flag = 1 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  929. $this->data['cz_2_num'] = $this->systemtransfer_cr->find_count("orver_flag = 2 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  930. //$jiaji_num = 0;
  931. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  932. foreach($transfer_ids as $k=>$v){
  933. if($v == 11){
  934. unset($transfer_ids[$k]);
  935. }
  936. }
  937. if(empty($transfer_ids)){
  938. $this->data['jiaji_num'] = -1;
  939. }else{
  940. $transfer_str = implode(",",$transfer_ids);
  941. $sql_r = $this->db->query("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*14) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  942. // print_r("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*7) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  943. $tmp_list= $sql_r->result_array();
  944. $this->data['jiaji_num'] = count($tmp_list);
  945. }
  946. $this->_Template('transfer_operate',$this->data);
  947. }
  948. public function _out()
  949. {
  950. $post = $this->input->post(NULL, TRUE);
  951. if(isset($post['label']))
  952. {
  953. $time = time();
  954. $label = $this->input->post('label',true);
  955. $cz = $this->input->post('cz',true);
  956. $transfer = $this->input->post('transfer',true);
  957. if(!$label)
  958. {
  959. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  960. }
  961. if(!$transfer)
  962. {
  963. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  964. }
  965. $lb = $this->systemtransfer->get_label($label);
  966. if(!$lb)
  967. {
  968. $this->logic_ding->sendToDing("检测货物流转异常的编码".$transfer."|".$label);
  969. echo json_encode(array('msg'=>'错误!未找到此条码,请联系申天','success'=>false));exit;
  970. }
  971. if($lb['id'] == 136872 || $label == '17573171077300'){
  972. echo json_encode(array('msg'=>'此单请退 回配货库','success'=>false));exit;
  973. }
  974. //东恒的如果扫过完成 就不允许再扫入
  975. if($lb['type'] == 2){
  976. if((strpos($lb['rk'],3)!== false) && ($transfer !=3)){
  977. echo json_encode(array('msg'=>'东恒的货物不允许重复扫描!','success'=>false));exit;
  978. }
  979. }
  980. if($lb['number']!='')
  981. {
  982. $nu = $this->fullorder->get_number($lb['number']);
  983. if(!$nu)
  984. {
  985. $nu = $this->fullordersmt->get_number($lb['number']);
  986. if(!$nu)
  987. {
  988. $nu = $this->fullordertt->get_number($lb['number']);
  989. }
  990. }
  991. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  992. // if($nu['state'] == '214' || $nu['state'] == '217')
  993. // {
  994. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  995. // }
  996. }
  997. $tdata = $this->transfer->find_all();
  998. $t = array();
  999. foreach ($tdata as $v)
  1000. {
  1001. $t[$v['id']] = $v['title'];
  1002. }
  1003. /**
  1004. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  1005. {
  1006. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  1007. }
  1008. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  1009. {
  1010. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  1011. }
  1012. **/
  1013. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  1014. // {
  1015. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  1016. // }
  1017. //如果是外销单 成品库不许扫入
  1018. if($transfer == 11 && $cz == 1 && $lb['type'] == 2){
  1019. echo json_encode(array('msg'=>'工厂的外销单成品库不许扫入!','success'=>false));exit;
  1020. }
  1021. //重新定义配货的原则问题
  1022. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  1023. $sku_arr = explode("-",$lb['features']);
  1024. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  1025. // 145 Full Lace Wig
  1026. // 1170 HDFullLaceWig
  1027. // 1249 FullLaceBobwithBang
  1028. // 1484 FullLaceBob
  1029. //如果是这4中全蕾丝那么配货就不处理
  1030. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  1031. }else{
  1032. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  1033. {
  1034. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  1035. }
  1036. }
  1037. }
  1038. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  1039. {
  1040. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  1041. }
  1042. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1043. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1044. if($transfer != 3 && $transfer != 11 )
  1045. {
  1046. if($cz == 1)
  1047. {
  1048. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1049. {
  1050. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1051. }
  1052. }
  1053. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1054. {
  1055. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1056. }
  1057. }
  1058. if($cz == 1)
  1059. {
  1060. $lb['rk'] .= $transfer.'|';
  1061. $lb['rktime'] .= $time.'|';
  1062. if($lbrk[0] == $transfer)
  1063. {
  1064. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1065. }
  1066. }
  1067. else if($cz == 2)
  1068. {
  1069. $lb['ck'] .= $transfer.'|';
  1070. $lb['cktime'] .= $time.'|';
  1071. if($lbck[0] == $transfer)
  1072. {
  1073. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1074. }
  1075. }
  1076. $this->_doCancelWlz($lb['id']);
  1077. $cztime = 'ctime'.$transfer;
  1078. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1079. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1080. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1081. {
  1082. if($lb['type'] == 0)
  1083. {
  1084. $s = $this->shop->read($nu['shop']);
  1085. $lb['kh'] = $s['yyid'];
  1086. $lb['ts'] = 1;
  1087. $rk = $this->apiyy->_newrk($lb);
  1088. if($rk['c'] == 0)
  1089. {
  1090. $this->db->trans_begin();
  1091. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$rk['scid'].time(),$cztime=>$time),$lb['id']);
  1092. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1093. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1094. if($cz == 2){
  1095. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1096. }
  1097. if ($this->db->trans_status() === TRUE)
  1098. {
  1099. $this->db->trans_commit();
  1100. if($nu['state'] == '216')
  1101. {
  1102. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1103. }
  1104. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1105. //标记订单已经取消
  1106. $this->_doCheckCancelFlag($lb['id']);
  1107. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1108. }
  1109. else
  1110. {
  1111. if($lb['is_jiaji'] == 2){
  1112. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1113. }elseif($lb['type'] == 2){
  1114. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1115. }else{
  1116. echo json_encode(array('music'=>'1','success'=>true));exit;
  1117. }
  1118. }
  1119. }
  1120. else
  1121. {
  1122. $this->db->trans_rollback();
  1123. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1124. }
  1125. }
  1126. else
  1127. {
  1128. if(stripos($rk['error'],'DocNo') !== false)
  1129. {
  1130. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1131. }
  1132. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1133. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1134. }
  1135. }elseif($lb['type'] == 2){
  1136. $this->db->trans_begin();
  1137. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,$cztime=>$time),$lb['id']);
  1138. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1139. $this->zzquque_u9->insert([
  1140. 'platform'=>'',
  1141. 'warehouse'=>0,
  1142. 'type'=>20, //5代表美仓
  1143. 'order_no'=>$lb['number'],
  1144. 'child_order_no'=>$lb['id'],
  1145. 'status'=>0,
  1146. 'create_time'=>time(),
  1147. 'update_time'=>time(),
  1148. ]);
  1149. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1150. if($cz == 2){
  1151. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1152. }
  1153. if ($this->db->trans_status() === TRUE)
  1154. {
  1155. $this->db->trans_commit();
  1156. if($nu['state'] == '216')
  1157. {
  1158. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1159. }
  1160. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1161. //标记订单已经取消
  1162. $this->_doCheckCancelFlag($lb['id']);
  1163. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1164. }
  1165. else
  1166. {
  1167. if($lb['is_jiaji'] == 2){
  1168. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1169. }elseif($lb['type'] == 2){
  1170. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1171. }else{
  1172. echo json_encode(array('music'=>'1','success'=>true));exit;
  1173. }
  1174. }
  1175. }
  1176. else
  1177. {
  1178. $this->db->trans_rollback();
  1179. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1180. }
  1181. }
  1182. else
  1183. {
  1184. $scid = explode('~',$lb['scid']);
  1185. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1186. $rk = $this->apiyy->get_bzsh($rkdata);
  1187. if(isset($rk['Data'][0]))
  1188. {
  1189. if($rk['Data'][0]['IsSucess'] == 1)
  1190. {
  1191. $this->db->trans_begin();
  1192. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$lb['scid'].'~'.$rk['Data'][0]['Code'],$cztime=>$time),$lb['id']);
  1193. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1194. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1195. if($cz == 2){
  1196. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1197. }
  1198. if ($this->db->trans_status() === TRUE)
  1199. {
  1200. $this->db->trans_commit();
  1201. if($nu['state'] == '216')
  1202. {
  1203. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1204. }
  1205. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1206. //标记订单已经取消
  1207. $this->_doCheckCancelFlag($lb['id']);
  1208. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1209. }
  1210. else
  1211. {
  1212. if($lb['is_jiaji'] == 2){
  1213. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1214. }else{
  1215. echo json_encode(array('music'=>'1','success'=>true));exit;
  1216. }
  1217. }
  1218. }
  1219. else
  1220. {
  1221. $this->db->trans_rollback();
  1222. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1223. }
  1224. }
  1225. else
  1226. {
  1227. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1228. }
  1229. }
  1230. else
  1231. {
  1232. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1233. }
  1234. }
  1235. }
  1236. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1237. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1238. {
  1239. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1240. }
  1241. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']);
  1242. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1243. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1244. if($cz == 2){
  1245. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1246. }
  1247. if ($this->db->trans_status() === TRUE)
  1248. {
  1249. $this->db->trans_commit();
  1250. if($nu['state'] == '216')
  1251. {
  1252. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1253. }
  1254. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1255. //标记订单已经取消
  1256. $this->_doCheckCancelFlag($lb['id']);
  1257. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1258. }
  1259. else
  1260. {
  1261. if($lb['is_jiaji'] == 2){
  1262. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1263. }else{
  1264. echo json_encode(array('music'=>'1','success'=>true));exit;
  1265. }
  1266. }
  1267. }
  1268. else
  1269. {
  1270. $this->db->trans_rollback();
  1271. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1272. }
  1273. }
  1274. }
  1275. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1276. private function _doCheckCancelFlag($fid){
  1277. $info = $this->systemtransfer->read($fid);
  1278. if($info['status'] != 11){
  1279. $this->systemtransfer->save(['status'=>11],$fid);
  1280. }
  1281. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1282. if(empty($list)){
  1283. return;
  1284. }
  1285. $is_cancel = false;
  1286. foreach($list as $val){
  1287. if($val['orver_flag'] == 3){
  1288. $is_cancel = true;
  1289. }
  1290. }
  1291. if($is_cancel){
  1292. return ;
  1293. }
  1294. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1295. }
  1296. //检测是否可以取消长期未流转
  1297. private function _doCancelWlz($fid){
  1298. //$info = $this->systemtransfer->read($fid);
  1299. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1300. if(empty($list)){
  1301. return;
  1302. }
  1303. $id = $list[0]['id'];
  1304. $scan_time = $list[0]['time'];
  1305. if($list[0]['type'] == 2){
  1306. if(time() - $scan_time < 3600 * 24 * 3){
  1307. $this->systemtransfer_cr->save([
  1308. 'extra_status'=>0,
  1309. ],$id);
  1310. }else{
  1311. $this->systemtransfer_cr->save([
  1312. 'extra_status'=>3,
  1313. ],$id);
  1314. }
  1315. }
  1316. }
  1317. //检测是否超时 车间流转环节
  1318. private function _doCheckIsOverTime($fid,$transfer){
  1319. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1320. if(count($list) < 2){
  1321. return ;
  1322. }
  1323. if($list[0]['type'] != 2){
  1324. return;
  1325. }
  1326. if($list[1]['type'] != 1){
  1327. return;
  1328. }
  1329. if($list[1]['orver_flag'] == 2){
  1330. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1331. }else{
  1332. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1333. }
  1334. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1335. }
  1336. public function _bdbb()
  1337. {
  1338. $post = $this->input->post(NULL, TRUE);
  1339. if(isset($post['s']))
  1340. {
  1341. $id_arr = $this->input->post('s');
  1342. $id_arr = explode(',',trim($id_arr,','));
  1343. if(!$id_arr)
  1344. {
  1345. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1346. }
  1347. //循环删除记录
  1348. foreach ($id_arr as $v)
  1349. {
  1350. $t = $this->systemtransfer->read($v);
  1351. if(!isset($t['number']))
  1352. {
  1353. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1354. }
  1355. $y = $this->fullorder->get_number($t['number']);
  1356. if(!$y)
  1357. {
  1358. $y = $this->fullordersmt->get_number($t['number']);
  1359. if(!$y)
  1360. {
  1361. $y = $this->fullordertt->get_number($t['number']);
  1362. if(!$y)
  1363. {
  1364. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1365. }
  1366. }
  1367. }
  1368. $time = time();
  1369. $label = $time.rand(10000,99999); //substr($time,1)*100
  1370. $this->systemtransfer->save(array('label'=>$label),$v);
  1371. $express = $this->express->read($y['express']);
  1372. $rows[] = array('num'=>$label,'number'=>$t['number'],'shipremarks'=>$t['shipremarks'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$t['printtime']),'gtime'=>date('YmdH',time()),'s'=>'1/1','t'=>"补打");
  1373. }
  1374. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1375. }
  1376. }
  1377. public function _excel()
  1378. {
  1379. if(isset($_GET['fexcel']))
  1380. {
  1381. $tc = array();$zh = array();
  1382. $typeclass = $this->typeclass->find_all();
  1383. foreach ($typeclass as $v)
  1384. {
  1385. $tc[$v['id']] = $v;
  1386. }
  1387. $number = $this->input->get('number',true);
  1388. $color = $this->input->get('color',true);
  1389. $gs = $this->input->get('gs',true);
  1390. $transfer = $this->input->get('transfer',true);
  1391. $type = $this->input->get('type',true);
  1392. $timetk = $this->input->get('timetk',true);
  1393. $timetj = $this->input->get('timetj',true);
  1394. $purchase = $this->input->get('purchase',true);
  1395. $lx = $this->input->get('lx',true);
  1396. $timetk = strtotime($timetk);
  1397. $timetj = strtotime($timetj);
  1398. $where = "1=1";
  1399. $cr = "time > '$timetk' and time < '$timetj'";
  1400. if($number)
  1401. {
  1402. $where .= " and number = '$number'";
  1403. }
  1404. if($transfer)
  1405. {
  1406. $cr .= " and lx = '".$transfer."'";
  1407. }
  1408. if($type)
  1409. {
  1410. //$cr .= " and type = '".$type."'";
  1411. if($type == 3){
  1412. $cr .= " and is_over = 0 ";
  1413. }else{
  1414. $cr .= " and type = '".$type."' ";
  1415. }
  1416. }
  1417. if($purchase)
  1418. {
  1419. $where .= " and purchase = '$purchase'";
  1420. }
  1421. if($color)
  1422. {
  1423. $where .= " and fpdata like '%-".$color."-%'";
  1424. }
  1425. if($lx)
  1426. {
  1427. if($lx == 1)
  1428. {
  1429. $where .= " and ordernumber = ''";
  1430. }
  1431. else
  1432. {
  1433. $where .= " and ordernumber != ''";
  1434. }
  1435. }
  1436. $fid = '';
  1437. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1438. foreach ($info_list_cr as $v)
  1439. {
  1440. $fid .= "id = '".$v['fid']."' or ";
  1441. }
  1442. if($fid)
  1443. {
  1444. $where .= ' and ('.trim($fid,'or ').')';
  1445. }
  1446. else
  1447. {
  1448. $where .= ' and id = 0';
  1449. }
  1450. $data = array();
  1451. $datafy = array();
  1452. $j = 0;
  1453. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1454. $lzbm = $this->transfer->find_all();
  1455. foreach ($info_list as $key=>$value)
  1456. {
  1457. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1458. $d = $this->systemtransfer->read($value['id']);
  1459. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1460. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1461. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1462. $cp = explode('-',trim($d['features'],'-'));
  1463. $rk = explode('|',trim($d['rk'],'|'));
  1464. $rktime = explode('|',trim($d['rktime'],'|'));
  1465. foreach ($cp as $v)
  1466. {
  1467. if(isset($tc[$v]))
  1468. {
  1469. if($tc[$v]['classid'] == 13)
  1470. {
  1471. $dj = $tc[$v]['title'];
  1472. }
  1473. else if($tc[$v]['classid'] == 8)
  1474. {
  1475. $ys = $tc[$v]['title'];
  1476. }
  1477. else if($tc[$v]['classid'] == 14)
  1478. {
  1479. $cc = $tc[$v]['title'];
  1480. }
  1481. else if($tc[$v]['classid'] == 15)
  1482. {
  1483. $hx = $tc[$v]['title'];
  1484. }
  1485. else if($tc[$v]['classid'] == 10)
  1486. {
  1487. $md = $tc[$v]['title'];
  1488. }
  1489. }
  1490. }
  1491. $rt = array();
  1492. foreach ($rk as $k=>$v)
  1493. {
  1494. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1495. }
  1496. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1497. foreach ($lzbm as $v)
  1498. {
  1499. if(isset($rt[count($fpdata[0])]))
  1500. {
  1501. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1502. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1503. if($num > 0){
  1504. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1505. }else{
  1506. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1507. }
  1508. }
  1509. else
  1510. {
  1511. $fpdata[0][count($fpdata[0])] = '';
  1512. }
  1513. }
  1514. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1515. unset($info_list[$key]['id']);
  1516. }
  1517. //echo "<pre>";print_r($info_list);exit;
  1518. $lzxq = '';
  1519. foreach ($lzbm as $v)
  1520. {
  1521. $lzxq .= '<td>'.$v['title'].'</td>';
  1522. }
  1523. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1524. $titlename = "<table border=1>
  1525. <tr>
  1526. <td>订单编号</td>
  1527. <td>品名</td>
  1528. <td>简码</td>
  1529. <td>备注</td>
  1530. <td>打印时间</td>
  1531. <td>
  1532. <table border=1>
  1533. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1534. <tr>
  1535. <td>产品名称</td>
  1536. <td>尺寸</td>
  1537. <td>等级</td>
  1538. <td>颜色</td>
  1539. <td>花型</td>
  1540. <td>密度</td>
  1541. ".$lzxq."
  1542. </tr>
  1543. </table>
  1544. </td>
  1545. </tr>
  1546. </table>";
  1547. $filename = $title.".xls";
  1548. $tail = "\n";
  1549. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1550. }
  1551. }
  1552. public function _rk()
  1553. {
  1554. $post = $this->input->post(NULL, TRUE);
  1555. if(isset($post['page']))
  1556. {
  1557. $api = $this->input->post('api',true);
  1558. $page = $this->input->post('page',true);
  1559. $perpage = $this->input->post('perpage',true);
  1560. $number = $this->input->post('number',true);
  1561. $color = $this->input->post('color',true);
  1562. $purchase = $this->input->post('purchase',true);
  1563. $transfer = $this->input->post('transfer',true);
  1564. $lx = $this->input->post('lx',true);
  1565. $timetk = $this->input->post('timetk',true);
  1566. $timetj = $this->input->post('timetj',true);
  1567. $timetk = strtotime($timetk);
  1568. $timetj = strtotime($timetj);
  1569. $where = "1=1";
  1570. if($transfer)
  1571. {
  1572. $ctime = 'ctime'.$transfer;
  1573. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1574. }
  1575. else
  1576. {
  1577. $where .= " and time > '$timetk' and time < '$timetj'";
  1578. }
  1579. if($number)
  1580. {
  1581. $where .= " and number = '$number'";
  1582. }
  1583. if($transfer)
  1584. {
  1585. $where .= " and rk like '%|".$transfer."|%'";
  1586. }
  1587. if($purchase)
  1588. {
  1589. $where .= " and purchase = '$purchase'";
  1590. }
  1591. if($color)
  1592. {
  1593. $where .= " and fpdata like '%-".$color."-%'";
  1594. }
  1595. if($lx)
  1596. {
  1597. if($lx == 1)
  1598. {
  1599. $where .= " and ordernumber = ''";
  1600. }
  1601. else
  1602. {
  1603. $where .= " and ordernumber != ''";
  1604. }
  1605. }
  1606. //数据排序
  1607. $order_str = "id desc";
  1608. if(empty($page))
  1609. {
  1610. $start = 0;
  1611. $perpage = 1;
  1612. }
  1613. else
  1614. {
  1615. $start = ($page - 1)*$perpage;
  1616. }
  1617. //取得信息列表
  1618. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1619. $transfer = $this->transfer->find_all();
  1620. $t = array();
  1621. foreach ($transfer as $v)
  1622. {
  1623. $t[$v['id']] = $v['title'];
  1624. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1625. }
  1626. //格式化数据
  1627. foreach ($info_list as $key=>$value)
  1628. {
  1629. $dd = $this->systemtransfer->read($value['id']);
  1630. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1631. $rk = explode('|',trim($dd['rk'],'|'));
  1632. $rktime = explode('|',trim($dd['rktime'],'|'));
  1633. $ck = explode('|',trim($dd['ck'],'|'));
  1634. $cktime = explode('|',trim($dd['cktime'],'|'));
  1635. $info_list[$key]['time'] = '';
  1636. for($i=0;$i<count($rk);$i++)
  1637. {
  1638. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1639. {
  1640. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1641. }
  1642. else
  1643. {
  1644. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1645. }
  1646. $info_list[$key]['time'] .= $d;
  1647. if(isset($ck[$i]) && $ck[$i] != '')
  1648. {
  1649. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1650. }
  1651. }
  1652. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1653. }
  1654. $total = $this->systemtransfer->find_count($where);
  1655. $pagenum = ceil($total/$perpage);
  1656. $over = $total-($start+$perpage);
  1657. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1658. echo json_encode($rows);exit;
  1659. }
  1660. if(isset($_SESSION['api']))
  1661. {
  1662. $user = $this->user->get_api($_SESSION['api']);
  1663. $usp = $user;
  1664. $pid = "";$tid="";$sid="";$wid="";
  1665. $purchase = explode('|',trim($user['purchase'],'|'));
  1666. $transfer = explode('|',trim($user['transfer'],'|'));
  1667. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1668. foreach ($purchase as $value)
  1669. {
  1670. $pid .= " id = ".$value." or";
  1671. }
  1672. foreach ($transfer as $value)
  1673. {
  1674. $tid .= " id = ".$value." or";
  1675. }
  1676. foreach ($warehouse as $value)
  1677. {
  1678. $wid .= " id = ".$value." or";
  1679. }
  1680. }
  1681. else
  1682. {
  1683. header('Location: /');exit;
  1684. }
  1685. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1686. $this->data['transfer'] = $transfer;
  1687. $this->_Template('transfer_rk',$this->data);
  1688. }
  1689. public function _ck()
  1690. {
  1691. $post = $this->input->post(NULL, TRUE);
  1692. if(isset($post['page']))
  1693. {
  1694. $api = $this->input->post('api',true);
  1695. $page = $this->input->post('page',true);
  1696. $perpage = $this->input->post('perpage',true);
  1697. $number = $this->input->post('number',true);
  1698. $color = $this->input->post('color',true);
  1699. $purchase = $this->input->post('purchase',true);
  1700. $transfer = $this->input->post('transfer',true);
  1701. $lx = $this->input->post('lx',true);
  1702. $timetk = $this->input->post('timetk',true);
  1703. $timetj = $this->input->post('timetj',true);
  1704. $timetk = strtotime($timetk);
  1705. $timetj = strtotime($timetj);
  1706. $where = "1=1";
  1707. if($transfer)
  1708. {
  1709. $ctime = 'ctime'.$transfer;
  1710. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1711. }
  1712. else
  1713. {
  1714. $where .= " and time > '$timetk' and time < '$timetj'";
  1715. }
  1716. if($number)
  1717. {
  1718. $where .= " and number = '$number'";
  1719. }
  1720. if($transfer)
  1721. {
  1722. $where .= " and ck like '%|".$transfer."|%'";
  1723. }
  1724. if($purchase)
  1725. {
  1726. $where .= " and purchase = '$purchase'";
  1727. }
  1728. if($color)
  1729. {
  1730. $where .= " and fpdata like '%-".$color."-%'";
  1731. }
  1732. if($lx)
  1733. {
  1734. if($lx == 1)
  1735. {
  1736. $where .= " and ordernumber = ''";
  1737. }
  1738. else
  1739. {
  1740. $where .= " and ordernumber != ''";
  1741. }
  1742. }
  1743. //数据排序
  1744. $order_str = "id desc";
  1745. if(empty($page))
  1746. {
  1747. $start = 0;
  1748. $perpage = 1;
  1749. }
  1750. else
  1751. {
  1752. $start = ($page - 1)*$perpage;
  1753. }
  1754. //取得信息列表
  1755. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1756. $transfer = $this->transfer->find_all();
  1757. $t = array();
  1758. foreach ($transfer as $v)
  1759. {
  1760. $t[$v['id']] = $v['title'];
  1761. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1762. }
  1763. //格式化数据
  1764. foreach ($info_list as $key=>$value)
  1765. {
  1766. $dd = $this->systemtransfer->read($value['id']);
  1767. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1768. $rk = explode('|',trim($dd['rk'],'|'));
  1769. $rktime = explode('|',trim($dd['rktime'],'|'));
  1770. $ck = explode('|',trim($dd['ck'],'|'));
  1771. $cktime = explode('|',trim($dd['cktime'],'|'));
  1772. $info_list[$key]['time'] = '';
  1773. for($i=0;$i<count($rk);$i++)
  1774. {
  1775. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1776. {
  1777. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1778. }
  1779. else
  1780. {
  1781. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1782. }
  1783. $info_list[$key]['time'] .= $d;
  1784. if(isset($ck[$i]) && $ck[$i] != '')
  1785. {
  1786. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1787. }
  1788. }
  1789. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1790. }
  1791. $total = $this->systemtransfer->find_count($where);
  1792. $pagenum = ceil($total/$perpage);
  1793. $over = $total-($start+$perpage);
  1794. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1795. echo json_encode($rows);exit;
  1796. }
  1797. if(isset($_SESSION['api']))
  1798. {
  1799. $user = $this->user->get_api($_SESSION['api']);
  1800. $usp = $user;
  1801. $pid = "";$tid="";$sid="";$wid="";
  1802. $purchase = explode('|',trim($user['purchase'],'|'));
  1803. $transfer = explode('|',trim($user['transfer'],'|'));
  1804. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1805. foreach ($purchase as $value)
  1806. {
  1807. $pid .= " id = ".$value." or";
  1808. }
  1809. foreach ($transfer as $value)
  1810. {
  1811. $tid .= " id = ".$value." or";
  1812. }
  1813. foreach ($warehouse as $value)
  1814. {
  1815. $wid .= " id = ".$value." or";
  1816. }
  1817. }
  1818. else
  1819. {
  1820. header('Location: /');exit;
  1821. }
  1822. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1823. $this->data['transfer'] = $transfer;
  1824. $this->_Template('transfer_ck',$this->data);
  1825. }
  1826. public function _jgl()
  1827. {
  1828. $post = $this->input->post(NULL, TRUE);
  1829. if(isset($post['printtime']))
  1830. {
  1831. $pt = $this->input->post('printtime',true);
  1832. $wt = $this->input->post('wgtime',true);
  1833. $printtime = strtotime($pt);
  1834. $wgtime = strtotime($wt);
  1835. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1836. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1837. if($printtime == $wgtime || $printtime > $wgtime)
  1838. {
  1839. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1840. }
  1841. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>".(($wgtime-$printtime)/86400)."天 完工数量:".$wg.", 总数量:".$sy.", 完工率:".number_format(($wg/$sy*100),2)."%</p>",'success'=>true));exit;
  1842. }
  1843. $this->_Template('transfer_wgl',$this->data);
  1844. }
  1845. public function _linqi(){
  1846. $post = $this->input->post(NULL, TRUE);
  1847. if(isset($post['page']))
  1848. {
  1849. $api = $this->input->post('api',true);
  1850. $page = $this->input->post('page',true);
  1851. $perpage = $this->input->post('perpage',true);
  1852. $transfer = $this->input->post('transfer',true);
  1853. $transfer_ids = $this->input->post('transfer_ids',true);
  1854. $orver_flag = $this->input->post('orver_flag',true);
  1855. $timetk = $this->input->post('timetk',true);
  1856. $timetj = $this->input->post('timetj',true);
  1857. $timetk = strtotime($timetk);
  1858. $timetj = strtotime($timetj);
  1859. $transfer_list = $this->transfer->find_all();
  1860. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1861. $where = 'type = 1 ';
  1862. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1863. //数据排序
  1864. $order_str = "id desc";
  1865. if(empty($page))
  1866. {
  1867. $start = 0;
  1868. $perpage = 1;
  1869. }
  1870. else
  1871. {
  1872. $start = ($page - 1)*$perpage;
  1873. }
  1874. if($transfer){
  1875. $where .= " and lx = '$transfer'";
  1876. }else{
  1877. $where .= " and lx in (".$transfer_ids.") ";
  1878. }
  1879. $where .= " and time > '$timetk' and time < '$timetj'";
  1880. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1881. $final_list = [];
  1882. foreach ($list as $key => $value) {
  1883. $info = $this->systemtransfer->read($value['fid']);
  1884. $final_list[$key]['id'] = $value['id'];
  1885. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1886. if($info['is_jiaji'] == 2){
  1887. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1888. }else{
  1889. $final_list[$key]['is_jiaji'] = "常规";
  1890. }
  1891. $final_list[$key]['pm'] = $info['pm'];
  1892. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1893. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1894. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1895. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1896. foreach ($data as $k=>$v)
  1897. {
  1898. $type = ($v['type']==1)?'入库':'出库';
  1899. if($v['orver_flag'] == 1){
  1900. if($v['is_over'] == 0){
  1901. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  1902. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1903. }else{
  1904. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1905. }
  1906. }elseif($v['orver_flag'] == 2){
  1907. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  1908. }else{
  1909. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1910. }
  1911. }
  1912. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1913. }
  1914. $total = $this->systemtransfer_cr->find_count($where);
  1915. $pagenum = ceil($total/$perpage);
  1916. $over = $total-($start+$perpage);
  1917. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1918. echo json_encode($rows);exit;
  1919. }
  1920. if(isset($_SESSION['api']))
  1921. {
  1922. $user = $this->user->get_api($_SESSION['api']);
  1923. $usp = $user;
  1924. $pid = "";$tid="";$sid="";$wid="";
  1925. $purchase = explode('|',trim($user['purchase'],'|'));
  1926. $transfer = explode('|',trim($user['transfer'],'|'));
  1927. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1928. foreach ($purchase as $value)
  1929. {
  1930. $pid .= " id = ".$value." or";
  1931. }
  1932. foreach ($transfer as $value)
  1933. {
  1934. $tid .= " id = ".$value." or";
  1935. }
  1936. foreach ($warehouse as $value)
  1937. {
  1938. $wid .= " id = ".$value." or";
  1939. }
  1940. }
  1941. else
  1942. {
  1943. header('Location: /');exit;
  1944. }
  1945. $kx = '';$zjtab = '';
  1946. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1947. $this->data['transfer'] = $transfer;
  1948. $transfer_ids = array_column($transfer, 'id');
  1949. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1950. $this->data['vip'] = $user['vip'];
  1951. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1952. $this->_Template('transfer_linqi',$this->data);
  1953. }
  1954. //按照条件导出超时车间
  1955. public function _overtime_export(){
  1956. $transfer_id = $this->input->get('transfer', TRUE);
  1957. $timetk = $this->input->get('timetk', TRUE);
  1958. $timetj = $this->input->get('timetj', TRUE);
  1959. $timetk = strtotime($timetk);
  1960. $timetj = strtotime($timetj);
  1961. if(isset($_SESSION['api']))
  1962. {
  1963. $user = $this->user->get_api($_SESSION['api']);
  1964. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1965. $tmp_transfer_list = $this->transfer->find_all();
  1966. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1967. }
  1968. else
  1969. {
  1970. header('Location: /');exit;
  1971. }
  1972. $where = " orver_flag = 2 and type = 1";
  1973. if(empty($transfer_id)){
  1974. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1975. }else{
  1976. $where .= " and lx = ".$transfer_id." ";
  1977. }
  1978. $where .= " and time > '$timetk' and time < '$timetj'";
  1979. $list = $this->systemtransfer_cr->find_all($where,'*');
  1980. $fid_list = array_column($list, 'fid');
  1981. if(empty($fid_list)){
  1982. echo "没有数据" ;
  1983. die ;
  1984. }
  1985. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  1986. $where_two = " orver_flag = 2 and type = 2";
  1987. if(empty($transfer_id)){
  1988. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  1989. }else{
  1990. $where_two .= " and lx = ".$transfer_id." ";
  1991. }
  1992. $where_two .= " and time > '$timetk' and time < '$timetj'";
  1993. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  1994. $final_list = [];
  1995. // foreach($list as $k => $v){
  1996. // $final_list[$v['fid']]['fid'] = $v['fid'];
  1997. // $final_list[$v['fid']]['lx'] = $v['lx'];
  1998. // $final_list[$v['fid']]['start_type'] = $v['type'];
  1999. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  2000. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  2001. // $final_list[$v['fid']]['end_time'] = "";
  2002. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  2003. // }
  2004. // foreach($order_list as $k=>$v){
  2005. // if(isset($final_list[$v['id']])){
  2006. // $final_list[$v['id']]['number'] = $v['number'];
  2007. // $final_list[$v['id']]['pm'] = $v['pm'];
  2008. // }
  2009. // }
  2010. // foreach($list_two as $k => $v){
  2011. // if(isset($final_list[$v['fid']])){
  2012. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  2013. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2014. // }
  2015. // }
  2016. // }
  2017. foreach($list as $k => $v){
  2018. $final_list[] = [
  2019. 'fid' => $v['fid'],
  2020. 'lx' => $v['lx'],
  2021. 'start_type' => $v['type'],
  2022. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  2023. 'condition' => json_decode($v['limit_time_str'],true),
  2024. 'end_time' => "",
  2025. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  2026. ];
  2027. }
  2028. foreach($order_list as $k=>$v){
  2029. foreach($final_list as $kk => $vv){
  2030. if($v['id'] == $vv['fid']){
  2031. $final_list[$kk]['number'] = $v['number'];
  2032. $final_list[$kk]['pm'] = $v['pm'];
  2033. }
  2034. }
  2035. }
  2036. foreach($list_two as $k => $v){
  2037. foreach($final_list as $kk => $vv){
  2038. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  2039. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2040. }
  2041. }
  2042. }
  2043. $filename = date("Y-m-d")."超时单导出.xls";
  2044. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2045. <head>
  2046. <!--[if gte mso 9]><xml>
  2047. <x:ExcelWorkbook>
  2048. <x:ExcelWorksheets>
  2049. <x:ExcelWorksheet>
  2050. <x:Name>EXCEL</x:Name>
  2051. <x:WorksheetOptions>
  2052. <x:Print>
  2053. <x:ValidPrinterInfo />
  2054. </x:Print>
  2055. </x:WorksheetOptions>
  2056. </x:ExcelWorksheet>
  2057. </x:ExcelWorksheets>
  2058. </x:ExcelWorkbook>
  2059. </xml>
  2060. <![endif]-->
  2061. </head><body>";
  2062. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2063. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  2064. foreach ($final_list as $key=>$value)
  2065. {
  2066. if(empty($value['number'])){
  2067. continue;
  2068. }
  2069. $str .= "<tr>";
  2070. $str .= "<td>". $value['number']. "</td>";
  2071. $str .= "<td>". $value['pm']. "</td>";
  2072. $str .= "<td>". $value['lx_name']. "</td>";
  2073. $str .= "<td>". $value['start_time']. "</td>";
  2074. $str .= "<td>". $value['end_time']. "</td>";
  2075. $str .= "</tr>";
  2076. }
  2077. $str .= "</table></body></html>";
  2078. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2079. header( "Content-type: application/octet-stream" );
  2080. header( "Content-Disposition: attachment; filename=".$filename );
  2081. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2082. header( "Pragma: no-cache" );
  2083. header( "Expires: 0" );
  2084. exit($str);
  2085. }
  2086. public function _jiaji(){
  2087. $post = $this->input->post(NULL, TRUE);
  2088. if(isset($post['page']))
  2089. {
  2090. $api = $this->input->post('api',true);
  2091. $page = $this->input->post('page',true);
  2092. $perpage = $this->input->post('perpage',true);
  2093. $transfer = $this->input->post('transfer',true);
  2094. $transfer_ids = $this->input->post('transfer_ids',true);
  2095. $orver_flag = $this->input->post('orver_flag',true);
  2096. $timetk = $this->input->post('timetk',true);
  2097. $timetj = $this->input->post('timetj',true);
  2098. $timetk = strtotime($timetk);
  2099. $timetj = strtotime($timetj);
  2100. $transfer_list = $this->transfer->find_all();
  2101. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2102. if(isset($_SESSION['api']))
  2103. {
  2104. $user = $this->user->get_api($_SESSION['api']);
  2105. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  2106. }
  2107. else
  2108. {
  2109. $transfer_ids = array_keys($t);
  2110. }
  2111. if(empty($page))
  2112. {
  2113. $start = 0;
  2114. $perpage = 1;
  2115. }
  2116. else
  2117. {
  2118. $start = ($page - 1)*$perpage;
  2119. }
  2120. $sql_r = "select s.* from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".$timetk ." and c.time < ".$timetj." ";
  2121. if($transfer){
  2122. $sql_r .= " and c.lx = ".$transfer." ";
  2123. }else{
  2124. foreach($transfer_ids as $k=>$v){
  2125. if($v == 11){
  2126. unset($transfer_ids[$k]);
  2127. }
  2128. }
  2129. $transfer_str = implode(",",$transfer_ids);
  2130. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2131. }
  2132. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2133. $rows_r = $this->db->query($sql_r);
  2134. $get_list = $rows_r->result_array();
  2135. $total = count($get_list);
  2136. $split_list = array_chunk($get_list,$perpage);
  2137. $pagenum = ceil(count($split_list));
  2138. $key = $page - 1;
  2139. $list = isset($split_list[$key])?$split_list[$key]:[];
  2140. $final_list = [];
  2141. foreach ($list as $key => $value) {
  2142. $final_list[$key]['id'] = $value['id'];
  2143. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2144. if($value['is_jiaji'] == 2){
  2145. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2146. }else{
  2147. $final_list[$key]['is_jiaji'] = "常规";
  2148. }
  2149. $final_list[$key]['pm'] = $value['pm'];
  2150. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2151. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2152. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2153. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2154. foreach ($data as $k=>$v)
  2155. {
  2156. $type = ($v['type']==1)?'入库':'出库';
  2157. if($v['orver_flag'] == 1){
  2158. if($v['is_over'] == 0){
  2159. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  2160. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2161. }else{
  2162. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2163. }
  2164. }elseif($v['orver_flag'] == 2){
  2165. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  2166. }else{
  2167. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2168. }
  2169. }
  2170. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2171. }
  2172. $over = $total-($start+$perpage);
  2173. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2174. echo json_encode($rows);exit;
  2175. }
  2176. if(isset($_SESSION['api']))
  2177. {
  2178. $user = $this->user->get_api($_SESSION['api']);
  2179. $usp = $user;
  2180. $pid = "";$tid="";$sid="";$wid="";
  2181. $purchase = explode('|',trim($user['purchase'],'|'));
  2182. $transfer = explode('|',trim($user['transfer'],'|'));
  2183. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2184. foreach ($purchase as $value)
  2185. {
  2186. $pid .= " id = ".$value." or";
  2187. }
  2188. foreach ($transfer as $value)
  2189. {
  2190. if($value){
  2191. if($value != 11){
  2192. $tid .= " id = ".$value." or";
  2193. }
  2194. }
  2195. }
  2196. foreach ($warehouse as $value)
  2197. {
  2198. $wid .= " id = ".$value." or";
  2199. }
  2200. }
  2201. else
  2202. {
  2203. header('Location: /');exit;
  2204. }
  2205. $kx = '';$zjtab = '';
  2206. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2207. $this->data['transfer'] = $transfer;
  2208. $transfer_ids = array_column($transfer, 'id');
  2209. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2210. $this->data['vip'] = $user['vip'];
  2211. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2212. $this->_Template('transfer_jiaji',$this->data);
  2213. }
  2214. public function _scz(){
  2215. $post = $this->input->post(NULL, TRUE);
  2216. if(isset($post['page']))
  2217. {
  2218. $page = $this->input->post('page',true);
  2219. $perpage = $this->input->post('perpage',true);
  2220. $transfer = $this->input->post('transfer',true);
  2221. $transfer_ids = $this->input->post('transfer_ids',true);
  2222. $timetk = $this->input->post('timetk',true);
  2223. $timetj = $this->input->post('timetj',true);
  2224. $timetk = strtotime($timetk);
  2225. $timetj = strtotime($timetj);
  2226. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2227. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2228. // $transfer_ids = array_keys($t);
  2229. if(empty($page))
  2230. {
  2231. $start = 0;
  2232. $perpage = 1;
  2233. }
  2234. else
  2235. {
  2236. $start = ($page - 1)*$perpage;
  2237. }
  2238. $where = "time > '$timetk' and time < '$timetj'";
  2239. $where .= " and rk not like '%11|' ";
  2240. if(!empty($transfer)){
  2241. $where .= " and rk like '%|".$transfer."|%' ";
  2242. }
  2243. // if($transfer)
  2244. // {
  2245. // $cr .= " and lx = '".$transfer."' ";
  2246. // }else{
  2247. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2248. // }
  2249. // $cr .= " and is_over = 0 ";
  2250. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2251. // $fid = [];
  2252. // foreach ($info_list_cr as $v)
  2253. // {
  2254. // $fid[] = $v['fid'];
  2255. // }
  2256. // if(empty($fid)){
  2257. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2258. // echo json_encode($rows);exit;
  2259. // }
  2260. // $fid = array_unique($fid);
  2261. $order_str = "id desc";
  2262. //取得信息列表
  2263. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2264. $transfer = $this->transfer->find_all();
  2265. $t = array();
  2266. foreach ($transfer as $v)
  2267. {
  2268. $t[$v['id']] = $v['title'];
  2269. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2270. }
  2271. //格式化数据
  2272. foreach ($info_list as $key=>$value)
  2273. {
  2274. if($value['is_jiaji'] == 2){
  2275. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2276. }else{
  2277. $info_list[$key]['is_jiaji'] = "常规";
  2278. }
  2279. $dd = $this->systemtransfer->read($value['id']);
  2280. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2281. $rk = explode('|',trim($dd['rk'],'|'));
  2282. $rktime = explode('|',trim($dd['rktime'],'|'));
  2283. $ck = explode('|',trim($dd['ck'],'|'));
  2284. $cktime = explode('|',trim($dd['cktime'],'|'));
  2285. $info_list[$key]['time'] = '';
  2286. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2287. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2288. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2289. foreach ($data as $k=>$v)
  2290. {
  2291. // $type = ($v['type']==1)?'入库':'出库';
  2292. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2293. $type = ($v['type']==1)?'入库':'出库';
  2294. if($v['orver_flag'] == 1){
  2295. if($v['is_over'] == 0){
  2296. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>".'<br>';
  2297. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2298. }else{
  2299. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2300. }
  2301. }elseif($v['orver_flag'] == 2){
  2302. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>".'<br>';
  2303. }elseif($v['orver_flag'] == 3){
  2304. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>".'<br>';
  2305. }else{
  2306. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2307. }
  2308. }
  2309. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2310. unset($info_list[$key]['ctime12']);
  2311. }
  2312. $total = $this->systemtransfer->find_count($where);
  2313. $pagenum = ceil($total/$perpage);
  2314. $over = $total-($start+$perpage);
  2315. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2316. echo json_encode($rows);exit;
  2317. }
  2318. if(isset($_SESSION['api']))
  2319. {
  2320. $user = $this->user->get_api($_SESSION['api']);
  2321. if(!in_array($user['id'],[10,44,50])){
  2322. exit('No direct script access allowed');
  2323. }
  2324. }
  2325. else
  2326. {
  2327. header('Location: /');exit;
  2328. }
  2329. $kx = '';$zjtab = '';
  2330. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2331. $this->data['transfer'] = $transfer;
  2332. $transfer_ids = array_column($transfer, 'id');
  2333. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2334. $this->_Template('transfer_scz',$this->data);
  2335. }
  2336. public function _sczexcel(){
  2337. $timetk = $this->input->get('timetk',true);
  2338. $timetj = $this->input->get('timetj',true);
  2339. $timetk = strtotime($timetk);
  2340. $timetj = strtotime($timetj);
  2341. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2342. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2343. // $transfer_ids = array_keys($t);
  2344. $where = "time > '$timetk' and time < '$timetj'";
  2345. $where .= " and rk not like '%11|' ";
  2346. if(!empty($transfer)){
  2347. $where .= " and rk like '%|".$transfer."|%' ";
  2348. }
  2349. $order_str = "id desc";
  2350. //取得信息列表
  2351. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2352. $transfer = $this->transfer->find_all();
  2353. $t = array();
  2354. foreach ($transfer as $v)
  2355. {
  2356. $t[$v['id']] = $v['title'];
  2357. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2358. }
  2359. //格式化数据
  2360. foreach ($info_list as $key=>$value)
  2361. {
  2362. if($value['is_jiaji'] == 2){
  2363. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2364. }else{
  2365. $info_list[$key]['is_jiaji'] = "常规";
  2366. }
  2367. $dd = $this->systemtransfer->read($value['id']);
  2368. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2369. $rk = explode('|',trim($dd['rk'],'|'));
  2370. $rktime = explode('|',trim($dd['rktime'],'|'));
  2371. $ck = explode('|',trim($dd['ck'],'|'));
  2372. $cktime = explode('|',trim($dd['cktime'],'|'));
  2373. $info_list[$key]['time'] = '';
  2374. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2375. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2376. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2377. foreach ($data as $k=>$v)
  2378. {
  2379. // $type = ($v['type']==1)?'入库':'出库';
  2380. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2381. $type = ($v['type']==1)?'入库':'出库';
  2382. if($v['orver_flag'] == 1){
  2383. if($v['is_over'] == 0){
  2384. $info_list[$key]['time'] .= "<span style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></span>".'<br>';
  2385. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2386. }else{
  2387. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2388. }
  2389. }elseif($v['orver_flag'] == 2){
  2390. $info_list[$key]['time'] .= "<span style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></span>".'<br>';
  2391. }elseif($v['orver_flag'] == 3){
  2392. $info_list[$key]['time'] .= "<span style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></span>".'<br>';
  2393. }else{
  2394. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2395. }
  2396. }
  2397. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2398. unset($info_list[$key]['ctime12']);
  2399. }
  2400. $filename = date("Y-m-d")."生产中订单.xls";
  2401. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2402. <head>
  2403. <!--[if gte mso 9]><xml>
  2404. <x:ExcelWorkbook>
  2405. <x:ExcelWorksheets>
  2406. <x:ExcelWorksheet>
  2407. <x:Name>EXCEL</x:Name>
  2408. <x:WorksheetOptions>
  2409. <x:Print>
  2410. <x:ValidPrinterInfo />
  2411. </x:Print>
  2412. </x:WorksheetOptions>
  2413. </x:ExcelWorksheet>
  2414. </x:ExcelWorksheets>
  2415. </x:ExcelWorkbook>
  2416. </xml>
  2417. <![endif]-->
  2418. </head><body>";
  2419. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2420. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2421. foreach ($info_list as $key=>$value)
  2422. {
  2423. $str .= "<tr>";
  2424. $str .= "<td>". $value['number']. "</td>";
  2425. $str .= "<td>". $value['is_jiaji']. "</td>";
  2426. $str .= "<td>". $value['pm']. "</td>";
  2427. $str .= "<td>". $value['shipremarks']. "</td>";
  2428. $str .= "<td>". $value['printtime']. "</td>";
  2429. $str .= "<td>". $value['time']. "</td>";
  2430. $str .= "</tr>";
  2431. }
  2432. $str .= "</table></body></html>";
  2433. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2434. header( "Content-type: application/octet-stream" );
  2435. header( "Content-Disposition: attachment; filename=".$filename );
  2436. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2437. header( "Pragma: no-cache" );
  2438. header( "Expires: 0" );
  2439. exit($str);
  2440. }
  2441. public function _wjsrk(){
  2442. $post = $this->input->post(NULL, TRUE);
  2443. if(isset($post['page']))
  2444. {
  2445. $api = $this->input->post('api',true);
  2446. $page = $this->input->post('page',true);
  2447. $perpage = $this->input->post('perpage',true);
  2448. $transfer = $this->input->post('transfer',true);
  2449. $transfer_ids = $this->input->post('transfer_ids',true);
  2450. $orver_flag = $this->input->post('orver_flag',true);
  2451. $timetk = $this->input->post('timetk',true);
  2452. $timetj = $this->input->post('timetj',true);
  2453. $timetk = strtotime($timetk);
  2454. $timetj = strtotime($timetj);
  2455. $transfer_list = $this->transfer->find_all();
  2456. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2457. $where = 'extra_status in (1,2) ';
  2458. //数据排序
  2459. $order_str = "id desc";
  2460. if(empty($page))
  2461. {
  2462. $start = 0;
  2463. $perpage = 1;
  2464. }
  2465. else
  2466. {
  2467. $start = ($page - 1)*$perpage;
  2468. }
  2469. if($transfer){
  2470. $where .= " and lx = '$transfer'";
  2471. }else{
  2472. $where .= " and lx in (".$transfer_ids.") ";
  2473. }
  2474. $where .= " and time > '$timetk' and time < '$timetj'";
  2475. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2476. $final_list = [];
  2477. foreach ($list as $key => $value) {
  2478. $info = $this->systemtransfer->read($value['fid']);
  2479. $final_list[$key]['id'] = $value['id'];
  2480. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2481. if($info['is_jiaji'] == 2){
  2482. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2483. }else{
  2484. $final_list[$key]['is_jiaji'] = "常规";
  2485. }
  2486. $final_list[$key]['pm'] = $info['pm'];
  2487. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2488. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2489. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2490. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2491. foreach ($data as $k=>$v)
  2492. {
  2493. $type = ($v['type']==1)?'入库':'出库';
  2494. if($v['orver_flag'] == 1){
  2495. if($v['is_over'] == 0){
  2496. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2497. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2498. }else{
  2499. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2500. }
  2501. }elseif($v['orver_flag'] == 2){
  2502. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2503. }else{
  2504. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2505. }
  2506. if($v['extra_status'] == 1){
  2507. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2508. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2509. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2510. }else{
  2511. $info_list[$key]['time'] .= "<br>";
  2512. }
  2513. }
  2514. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2515. }
  2516. $total = $this->systemtransfer_cr->find_count($where);
  2517. $pagenum = ceil($total/$perpage);
  2518. $over = $total-($start+$perpage);
  2519. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2520. echo json_encode($rows);exit;
  2521. }
  2522. if(isset($_SESSION['api']))
  2523. {
  2524. $user = $this->user->get_api($_SESSION['api']);
  2525. $usp = $user;
  2526. $pid = "";$tid="";$sid="";$wid="";
  2527. $purchase = explode('|',trim($user['purchase'],'|'));
  2528. $transfer = explode('|',trim($user['transfer'],'|'));
  2529. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2530. foreach ($purchase as $value)
  2531. {
  2532. $pid .= " id = ".$value." or";
  2533. }
  2534. foreach ($transfer as $value)
  2535. {
  2536. $tid .= " id = ".$value." or";
  2537. }
  2538. foreach ($warehouse as $value)
  2539. {
  2540. $wid .= " id = ".$value." or";
  2541. }
  2542. }
  2543. else
  2544. {
  2545. header('Location: /');exit;
  2546. }
  2547. $kx = '';$zjtab = '';
  2548. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2549. $this->data['transfer'] = $transfer;
  2550. $transfer_ids = array_column($transfer, 'id');
  2551. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2552. $this->data['vip'] = $user['vip'];
  2553. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2554. $this->_Template('transfer_wjsrk',$this->data);
  2555. }
  2556. public function _wjsrkexcel(){
  2557. $api = $this->input->get('api',true);
  2558. $transfer = $this->input->get('transfer',true);
  2559. $timetk = $this->input->get('timetk',true);
  2560. $timetj = $this->input->get('timetj',true);
  2561. $timetk = strtotime($timetk);
  2562. $timetj = strtotime($timetj);
  2563. $transfer_list = $this->transfer->find_all();
  2564. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2565. $where = 'extra_status in (1,2) ';
  2566. //数据排序
  2567. $order_str = "id desc";
  2568. if($transfer){
  2569. $where .= " and lx = '$transfer'";
  2570. }else{
  2571. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2572. $transfer_ids = array_column($transfer, 'id');
  2573. $transfer_ids = implode(",",$transfer_ids);
  2574. $where .= " and lx in (".$transfer_ids.") ";
  2575. }
  2576. $where .= " and time > '$timetk' and time < '$timetj'";
  2577. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2578. $final_list = [];
  2579. foreach ($list as $key => $value) {
  2580. $info = $this->systemtransfer->read($value['fid']);
  2581. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2582. $final_list[$key]['pm'] = $info['pm'];
  2583. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2584. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2585. }
  2586. $filename = date("Y-m-d")."超期未流转单导出.xls";
  2587. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2588. <head>
  2589. <!--[if gte mso 9]><xml>
  2590. <x:ExcelWorkbook>
  2591. <x:ExcelWorksheets>
  2592. <x:ExcelWorksheet>
  2593. <x:Name>EXCEL</x:Name>
  2594. <x:WorksheetOptions>
  2595. <x:Print>
  2596. <x:ValidPrinterInfo />
  2597. </x:Print>
  2598. </x:WorksheetOptions>
  2599. </x:ExcelWorksheet>
  2600. </x:ExcelWorksheets>
  2601. </x:ExcelWorkbook>
  2602. </xml>
  2603. <![endif]-->
  2604. </head><body>";
  2605. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2606. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2607. foreach ($final_list as $key=>$value)
  2608. {
  2609. if(empty($value['number'])){
  2610. continue;
  2611. }
  2612. $str .= "<tr>";
  2613. $str .= "<td>". $value['number']. "</td>";
  2614. $str .= "<td>". $value['pm']. "</td>";
  2615. $str .= "<td>". $value['lx_name']. "</td>";
  2616. $str .= "<td>". $value['time']. "</td>";
  2617. $str .= "</tr>";
  2618. }
  2619. $str .= "</table></body></html>";
  2620. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2621. header( "Content-type: application/octet-stream" );
  2622. header( "Content-Disposition: attachment; filename=".$filename );
  2623. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2624. header( "Pragma: no-cache" );
  2625. header( "Expires: 0" );
  2626. exit($str);
  2627. }
  2628. public function _cqrk(){
  2629. $post = $this->input->post(NULL, TRUE);
  2630. if(isset($post['page']))
  2631. {
  2632. $api = $this->input->post('api',true);
  2633. $page = $this->input->post('page',true);
  2634. $perpage = $this->input->post('perpage',true);
  2635. $transfer = $this->input->post('transfer',true);
  2636. $transfer_ids = $this->input->post('transfer_ids',true);
  2637. $orver_flag = $this->input->post('orver_flag',true);
  2638. $timetk = $this->input->post('timetk',true);
  2639. $timetj = $this->input->post('timetj',true);
  2640. $timetk = strtotime($timetk);
  2641. $timetj = strtotime($timetj);
  2642. $transfer_list = $this->transfer->find_all();
  2643. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2644. $where = 'extra_status in (2,3) ';
  2645. //数据排序
  2646. $order_str = "id desc";
  2647. if(empty($page))
  2648. {
  2649. $start = 0;
  2650. $perpage = 1;
  2651. }
  2652. else
  2653. {
  2654. $start = ($page - 1)*$perpage;
  2655. }
  2656. if($transfer){
  2657. $where .= " and lx = '$transfer'";
  2658. }else{
  2659. $where .= " and lx in (".$transfer_ids.") ";
  2660. }
  2661. $where .= " and time > '$timetk' and time < '$timetj'";
  2662. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2663. $final_list = [];
  2664. foreach ($list as $key => $value) {
  2665. $info = $this->systemtransfer->read($value['fid']);
  2666. $final_list[$key]['id'] = $value['id'];
  2667. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2668. if($info['is_jiaji'] == 2){
  2669. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2670. }else{
  2671. $final_list[$key]['is_jiaji'] = "常规";
  2672. }
  2673. $final_list[$key]['pm'] = $info['pm'];
  2674. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2675. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2676. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2677. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2678. foreach ($data as $k=>$v)
  2679. {
  2680. $type = ($v['type']==1)?'入库':'出库';
  2681. if($v['orver_flag'] == 1){
  2682. if($v['is_over'] == 0){
  2683. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2684. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2685. }else{
  2686. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2687. }
  2688. }elseif($v['orver_flag'] == 2){
  2689. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2690. }else{
  2691. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2692. }
  2693. if($v['extra_status'] == 1){
  2694. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2695. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2696. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2697. }else{
  2698. $info_list[$key]['time'] .= "<br>";
  2699. }
  2700. }
  2701. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2702. }
  2703. $total = $this->systemtransfer_cr->find_count($where);
  2704. $pagenum = ceil($total/$perpage);
  2705. $over = $total-($start+$perpage);
  2706. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2707. echo json_encode($rows);exit;
  2708. }
  2709. if(isset($_SESSION['api']))
  2710. {
  2711. $user = $this->user->get_api($_SESSION['api']);
  2712. $usp = $user;
  2713. $pid = "";$tid="";$sid="";$wid="";
  2714. $purchase = explode('|',trim($user['purchase'],'|'));
  2715. $transfer = explode('|',trim($user['transfer'],'|'));
  2716. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2717. foreach ($purchase as $value)
  2718. {
  2719. $pid .= " id = ".$value." or";
  2720. }
  2721. foreach ($transfer as $value)
  2722. {
  2723. $tid .= " id = ".$value." or";
  2724. }
  2725. foreach ($warehouse as $value)
  2726. {
  2727. $wid .= " id = ".$value." or";
  2728. }
  2729. }
  2730. else
  2731. {
  2732. header('Location: /');exit;
  2733. }
  2734. $kx = '';$zjtab = '';
  2735. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2736. $this->data['transfer'] = $transfer;
  2737. $transfer_ids = array_column($transfer, 'id');
  2738. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2739. $this->data['vip'] = $user['vip'];
  2740. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2741. $this->_Template('transfer_cqrk',$this->data);
  2742. }
  2743. public function _cqrkexcel(){
  2744. $api = $this->input->get('api',true);
  2745. $transfer = $this->input->get('transfer',true);
  2746. $timetk = $this->input->get('timetk',true);
  2747. $timetj = $this->input->get('timetj',true);
  2748. $timetk = strtotime($timetk);
  2749. $timetj = strtotime($timetj);
  2750. $transfer_list = $this->transfer->find_all();
  2751. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2752. $where = 'extra_status in (2,3) ';
  2753. //数据排序
  2754. $order_str = "id desc";
  2755. if($transfer){
  2756. $where .= " and lx = '$transfer'";
  2757. }else{
  2758. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2759. $transfer_ids = array_column($transfer, 'id');
  2760. $transfer_ids = implode(",",$transfer_ids);
  2761. $where .= " and lx in (".$transfer_ids.") ";
  2762. }
  2763. $where .= " and time > '$timetk' and time < '$timetj'";
  2764. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2765. $final_list = [];
  2766. foreach ($list as $key => $value) {
  2767. $info = $this->systemtransfer->read($value['fid']);
  2768. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2769. $final_list[$key]['pm'] = $info['pm'];
  2770. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2771. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2772. }
  2773. $filename = date("Y-m-d")."超期3天未流转单导出.xls";
  2774. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2775. <head>
  2776. <!--[if gte mso 9]><xml>
  2777. <x:ExcelWorkbook>
  2778. <x:ExcelWorksheets>
  2779. <x:ExcelWorksheet>
  2780. <x:Name>EXCEL</x:Name>
  2781. <x:WorksheetOptions>
  2782. <x:Print>
  2783. <x:ValidPrinterInfo />
  2784. </x:Print>
  2785. </x:WorksheetOptions>
  2786. </x:ExcelWorksheet>
  2787. </x:ExcelWorksheets>
  2788. </x:ExcelWorkbook>
  2789. </xml>
  2790. <![endif]-->
  2791. </head><body>";
  2792. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2793. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2794. foreach ($final_list as $key=>$value)
  2795. {
  2796. if(empty($value['number'])){
  2797. continue;
  2798. }
  2799. $str .= "<tr>";
  2800. $str .= "<td>". $value['number']. "</td>";
  2801. $str .= "<td>". $value['pm']. "</td>";
  2802. $str .= "<td>". $value['lx_name']. "</td>";
  2803. $str .= "<td>". $value['time']. "</td>";
  2804. $str .= "</tr>";
  2805. }
  2806. $str .= "</table></body></html>";
  2807. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2808. header( "Content-type: application/octet-stream" );
  2809. header( "Content-Disposition: attachment; filename=".$filename );
  2810. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2811. header( "Pragma: no-cache" );
  2812. header( "Expires: 0" );
  2813. exit($str);
  2814. }
  2815. /**
  2816. * 导出excel 操作部门是否出库
  2817. */
  2818. public function _czbmIsOutExcel(){
  2819. if($this->input->method() == 'get'){
  2820. $number = $this->input->get('number',true);
  2821. $color = $this->input->get('color',true);
  2822. $purchase = $this->input->get('purchase',true);
  2823. $transfer = $this->input->get('transfer',true);
  2824. $lx = $this->input->get('lx',true);
  2825. $type = $this->input->get('type',true);
  2826. $pm = $this->input->get('pm',true);
  2827. $jiaji = $this->input->get('jiaji',true);
  2828. $timetk = $this->input->get('timetk',true);
  2829. $timetj = $this->input->get('timetj',true);
  2830. $timetk = strtotime($timetk);
  2831. $timetj = strtotime($timetj);
  2832. $where = '1=1';
  2833. if($number)
  2834. {
  2835. $where .= " and number = '$number'";
  2836. }
  2837. if($pm){
  2838. $where .= " and pm like '%".$pm."%'";
  2839. }
  2840. if($purchase)
  2841. {
  2842. $where .= " and purchase = '$purchase'";
  2843. }
  2844. if($color)
  2845. {
  2846. $where .= " and fpdata like '%-".$color."-%'";
  2847. }
  2848. if($lx)
  2849. {
  2850. if($lx == 1)
  2851. {
  2852. $where .= " and ordernumber = ''";
  2853. }
  2854. else
  2855. {
  2856. $where .= " and ordernumber != ''";
  2857. }
  2858. }
  2859. if($jiaji){
  2860. if($jiaji == 1){
  2861. $where .= " and is_jiaji = 0";
  2862. }
  2863. if($jiaji == 2){
  2864. $where .= " and is_jiaji = 2";
  2865. }
  2866. }
  2867. //数据排序
  2868. $order_str = "id desc";
  2869. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  2870. if($type)
  2871. {
  2872. if($type == 3){
  2873. if($transfer)
  2874. {
  2875. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  2876. }
  2877. }else{
  2878. $type = ($type==1)?'rk':'ck';
  2879. if($transfer)
  2880. {
  2881. $where .= " and $type like '%|".$transfer."|%'";
  2882. }
  2883. }
  2884. }
  2885. else
  2886. {
  2887. if($transfer)
  2888. {
  2889. $where .= " and rk like '%|".$transfer."|%'";
  2890. }
  2891. }
  2892. //取得信息列表
  2893. $info_list = $this->systemtransfer->find_all($where,'*',$order_str);
  2894. $transfer = $this->transfer->find_all();
  2895. $t = array();
  2896. foreach ($transfer as $v)
  2897. {
  2898. $t[$v['id']] = $v['title'];
  2899. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2900. }
  2901. $final_list = [];
  2902. //格式化数据
  2903. foreach ($info_list as $key=>$value)
  2904. {
  2905. $transfer_list = $this->_get_transfer_data($value,$t);
  2906. $final_list[] = [
  2907. 'number'=>$value['number'],
  2908. 'pm'=>$value['pm'],
  2909. 'transfer_list'=>$transfer_list,
  2910. ];
  2911. }
  2912. echo "<pre>";
  2913. print_r($final_list);
  2914. die;
  2915. }
  2916. }
  2917. public function _get_transfer_data($info,$t){
  2918. $rk_list = explode('|',trim($info['rk'],'|'));
  2919. $rk_time = explode('|',trim($info['rktime'],'|'));
  2920. $ck_list = explode('|',trim($info['ck'],'|'));
  2921. $ck_time = explode('|',trim($info['cktime'],'|'));
  2922. if(count($rk_time) < count($ck_time)){
  2923. return [
  2924. 'code'=>-1,
  2925. 'msg'=>'数据异常,('.$info['id'].')联系技术',
  2926. ];
  2927. }
  2928. $tran_list = [];
  2929. $len = count($rk_list);
  2930. $ck_index = 0;
  2931. for($i = 0;$i < $len;$i++){
  2932. if(isset($rk_list[$i]) && empty($ck_list[$ck_index]) ){
  2933. $tran_list[] = [
  2934. 'lx'=>$rk_list[$i],
  2935. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  2936. 'rk_time'=>$rk_time[$i],
  2937. 'ck_time'=>'',
  2938. 'is_over'=>1,//未出库
  2939. ];
  2940. }else{
  2941. if($rk_list[$i] == $ck_list[$ck_index]){
  2942. $tran_list[] = [
  2943. 'lx'=>$rk_list[$i],
  2944. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  2945. 'rk_time'=>$rk_time[$i],
  2946. 'ck_time'=>$ck_time[$ck_index],
  2947. 'is_over'=>2,//已出库
  2948. ];
  2949. $ck_index++;
  2950. }else if($rk_list[$i] != $ck_list[$ck_index]){
  2951. if($rk_list[$i] == $ck_list[$ck_index-1]){
  2952. //估计是之前完成 或者 成品库 强制扫入
  2953. $tran_list[] = [
  2954. 'lx'=>$rk_list[$i],
  2955. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  2956. 'rk_time'=>$rk_time[$i],
  2957. 'ck_time'=>$ck_time[$ck_index-1],
  2958. 'is_over'=>2,//已出库
  2959. ];
  2960. }else if($rk_list[$i] == $ck_list[$ck_index+1]){
  2961. //估计是完成 或者 成品库 强制扫出了
  2962. $tran_list[] = [
  2963. 'lx'=>$rk_list[$i],
  2964. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  2965. 'rk_time'=>$rk_time[$i],
  2966. 'ck_time'=>$ck_time[$ck_index+1],
  2967. 'is_over'=>2,//已出库
  2968. ];
  2969. $ck_index++;
  2970. $ck_index++;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. return $tran_list;
  2976. }
  2977. }