ImsStoreController.php 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Date: 2018/5/28
  5. * Time: 17:14
  6. * 仓库类
  7. */
  8. class ImsStoreController extends Controller
  9. {
  10. /***************** 仓库调拨 *****************/
  11. //调拨列表
  12. public function actionAllocation()
  13. {
  14. $result = array();
  15. $params = array();
  16. $page = Req::get('page') ? Req::get('page') : 1;
  17. if (Req::get('deliveryStatus') && Req::get('deliveryStatus') != '') {
  18. $params['deliveryStatus'] = Req::get('deliveryStatus')-1;
  19. }
  20. if (Req::get('itemId')) {
  21. $params['itemId'] = Req::get('itemId');
  22. }
  23. if(Req::get('startDate')){
  24. $params['startTime'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
  25. }
  26. if(Req::get('endDate')){
  27. $params['endTime'] =date('Y-m-d 23:59:59',strtotime(Req::get('endDate')));
  28. }
  29. //品目名称
  30. $pmNameList = $this->getPmList();
  31. $result['itemList'] = $pmNameList;
  32. $res = $this->getHttp('storage-allocate/coach/list/' . $page, 'POST', $params);
  33. $result['schoolName']=$this->schoolInfo['school_name'];
  34. $result['list'] = array();
  35. if ($res['status'] == 1) {
  36. $result['list'] = $res['data']['list'];
  37. $result['page'] = $res['data'];
  38. } else {
  39. $result['list'] = array();
  40. $result['page'] = array();
  41. }
  42. $this->render('allocation', $result);
  43. }
  44. /**
  45. * 耗材调拨申请
  46. */
  47. public function actionApplyAllocation(){
  48. $atId = Req::get('atId');
  49. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  50. $param['coach_name']=Yii::app()->session['coachInfo']['real_name'];
  51. }else{
  52. $param['coach_name']=Yii::app()->session['coachInfo']['coach_name'];
  53. }
  54. //发货仓库
  55. $warehouse = $this->getHttp('storage/type/item/0/3','GET');
  56. $data['warehouse'] = isset($warehouse['data']) && $warehouse['data'] ? $warehouse['data'] : '';
  57. //查询所有零件
  58. $partRs=$this->getHttp('fixed/part/list/all','GET');
  59. $data['part_list']='';
  60. if($partRs['status']==1){
  61. if($partRs['data']){
  62. $partHtml='<select class="part_list">';
  63. $partHtml.='<option value="0">请选择</option>';
  64. foreach ($partRs['data'] as $item){
  65. $partHtml.='<option value="'.$item['partType'].'">'.$item['partName'].'</option>';
  66. }
  67. $partHtml.="</select>";
  68. $data['part_list']=$partHtml;
  69. }
  70. }
  71. //读取品目类型
  72. $res = $this->getHttp('storage-inventory/coach/low/list/3','GET');
  73. if ($res['status'] == 1) {
  74. $data['pm_type']=$res['data'];
  75. }else{
  76. $this->errorMsg('品目类型读取失败');
  77. }
  78. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  79. $data['uploadUrl'] = $url;
  80. $data['basic'] = $this->setToken();
  81. if($atId){
  82. $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
  83. $warehouseKeyVal = $data['warehouse'] ? _array_column($data['warehouse'],'storageName','storageId') : array();
  84. if($res1['status']==1){
  85. $data['title']=$res1['data']['atTitle'];
  86. $data['deliverName']=$res1['data']['deliverName']; //总仓
  87. $data['consignorName']=$res1['data']['consignorName']; //管理员
  88. $data['school_name']=$this->schoolInfo['school_name'];
  89. $data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
  90. $data['receiveUser']=$res1['data']['receiver'];
  91. $data['telephone']=$res1['data']['receiveMobile'];
  92. $data['address']=$res1['data']['receivePlace'];
  93. $data['remark']=$res1['data']['remark'];
  94. $data['atCode']=$res1['data']['atCode'];
  95. $data['atId']=$res1['data']['atId'];
  96. $data['images']=$res1['data']['images'];
  97. $data['deliverStorage']=$res1['data']['deliverStorage'];
  98. $data['deliverStorageName']=isset($warehouseKeyVal[$res1['data']['deliverStorage']]) ? $warehouseKeyVal[$res1['data']['deliverStorage']] : '';
  99. $data['receiveStorage']=$res1['data']['receiveStorage'];
  100. $data['operateType']='edit';
  101. if($res1['data']['details']){
  102. foreach ($res1['data']['details'] as $val){
  103. $data['allocateDetail'][]=array(
  104. 'itemId'=>$val['itemId'],
  105. 'itemName'=>$val['itemName'],
  106. 'applyNo'=>$val['applyNo'],
  107. 'invNo'=>$val['invNo'],
  108. 'unitName'=>$val['unitName'],
  109. 'typeName'=>$val['typeName']
  110. );
  111. }
  112. }
  113. //零件
  114. if($res1['data']['partDetailList']){
  115. foreach ($res1['data']['partDetailList'] as $val){
  116. //加载设备列表
  117. $device = $this->getHttp('storage-inventory/query-fixed/list/'.$val['fpTypeId'].'/'.$data['receiveStorage'], 'get');
  118. $deviceHtml='';
  119. $deviceHtml='<select class="device_list">';
  120. $deviceHtml.='<option value="0">请选择</option>';
  121. if($device['data']){
  122. foreach ($device['data'] as $item){
  123. if($val['fcId']==$item['fcId']){
  124. $deviceHtml.='<option selected value="'.$item['fcId'].'">'.$item['fixedCode'].'</option>';
  125. $val['itemName']=$item['itemName'];
  126. }else{
  127. $deviceHtml.='<option value="'.$item['fcId'].'">'.$item['fixedCode'].'</option>';
  128. }
  129. }
  130. }
  131. $deviceHtml.='</select>';
  132. $val['device_list']=$deviceHtml;
  133. $partHtml='<select class="part_list">';
  134. $partHtml.='<option value="0">请选择</option>';
  135. if($partRs['data']){
  136. foreach ($partRs['data'] as $item){
  137. if($val['fpTypeId']==$item['partType']){
  138. $partHtml.='<option selected value="'.$item['partType'].'">'.$item['partName'].'</option>';
  139. }else{
  140. $partHtml.='<option value="'.$item['partType'].'">'.$item['partName'].'</option>';
  141. }
  142. }
  143. }
  144. $partHtml.="</select>";
  145. $val['part_list']=$partHtml;
  146. $data['partDetailList'][]=$val;
  147. }
  148. }
  149. $this->render('allocationEdit',$data);
  150. exit;
  151. }else{
  152. $this->errorMsg('ID不正确');
  153. }
  154. }else{
  155. // debug($this->schoolInfo);
  156. $data['title']=$this->schoolInfo['school_name'].'-'.$param['coach_name'].'的耗材调拨申请'.date('Ymd');
  157. $data['school_name']=$this->schoolInfo['school_name'];
  158. $data['coach_name']=$param['coach_name'];
  159. $data['coach_phone']=$this->coachInfo['telephone'];
  160. $data['address']=$this->schoolInfo['address'];
  161. $data['operateType']='add';
  162. }
  163. $this->render('allocationCreate',$data);
  164. }
  165. /**
  166. * 品目列表
  167. */
  168. public function actionInventory(){
  169. $type=Req::post('type');
  170. $name=Req::post('name');
  171. $page=Req::post('page');
  172. $warehouse=Req::post('warehouse');
  173. $params=array();
  174. if($type){
  175. $params['typeId']=$type;
  176. }
  177. if(!$page) $page=1;
  178. if($name){
  179. $params['itemName']=$name;
  180. }
  181. $params['storageId'] = $warehouse;
  182. // debug($params);
  183. $res = $this->getHttp("storage-inventory/coach/not-in-part-type/{$page}", 'POST', $params);
  184. //debug($res);
  185. $result['list'] = array();
  186. $result['now_page'] = $page;
  187. if ($res['status'] == 1) {
  188. $result['list'] = $res['data']['list'];
  189. //$result['total_page'] = $res['data']['lastPage'];
  190. $result['total_page'] = $res['data']['pages'];
  191. } else {
  192. $result['list'] = array();
  193. $result['total_page'] = array();
  194. }
  195. exit(json_encode(array('status'=>1,'data'=>$result)));
  196. }
  197. /**
  198. * 调拨申请
  199. */
  200. public function actionApplySubmit(){
  201. $result['status']=0;
  202. $warehouse=Req::post('warehouse');
  203. $allocateDetail=Req::post('allocateDetail');
  204. $receiveDate=Req::post('receiveDate');
  205. $receiveUser=Req::post('receiveUser');
  206. $telephone=Req::post('telephone');
  207. $address=Req::post('address');
  208. $remark=Req::post('remark');
  209. $img = Req::post('img');
  210. $receiveStorage=Req::post('receiveStorage');
  211. $partDetail=Req::post('partDetail');
  212. if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
  213. exit(json_encode($result));
  214. }
  215. if(strtotime($receiveDate)<strtotime(date('Ymd'))){
  216. $result['msg']='收货日期不正确';
  217. exit(json_encode($result));
  218. }
  219. $params=array();
  220. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  221. $coach_name=Yii::app()->session['coachInfo']['real_name'];
  222. }else{
  223. $coach_name=Yii::app()->session['coachInfo']['coach_name'];
  224. }
  225. $params['alType']=3;
  226. $params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
  227. $params['deliverStorage']=$warehouse;
  228. $params['receivePlace']=$address;
  229. $params['receiver']=$receiveUser;
  230. $params['receiveMobile']=$telephone;
  231. $params['arriveDate']=$receiveDate;
  232. $params['remark']=$remark;
  233. $params['consigneeName']=$receiveUser;
  234. $params['doorDoor']=0;
  235. $params['images']=$img;
  236. $params['transportType']=1;
  237. $params['receiveStorage']=$receiveStorage;
  238. if($allocateDetail){
  239. foreach ($allocateDetail as $val){
  240. @$idNum=explode('///',$val);
  241. if(isset($idNum[0]) && isset($idNum[1])){
  242. $params['requestAllocateDetail'][]=array(
  243. 'itemId'=>$idNum[0],
  244. 'applyNo'=>round($idNum[1],6),
  245. );
  246. }
  247. }
  248. }
  249. if($partDetail){
  250. foreach ($partDetail as $val){
  251. $partArr=explode('///',$val);
  252. if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
  253. $params['partReqDTOList'][]=array(
  254. 'applyNo'=>round($partArr[0],6),
  255. 'fpTypeId'=>$partArr[1],
  256. 'fcId'=>$partArr[2]
  257. );
  258. }
  259. }
  260. }
  261. $res = $this->getHttp("storage-allocate/coach/add", 'POST', $params);
  262. if($res['status']==1){
  263. $result['status']=1;
  264. }else{
  265. $result['msg']=$res['msg'];
  266. }
  267. exit(json_encode($result));
  268. }
  269. /**
  270. * 编辑调拨申请
  271. */
  272. public function actionApplyEdit(){
  273. $result['status']=0;
  274. $allocateDetail=Req::post('allocateDetail');
  275. $receiveDate=Req::post('receiveDate');
  276. $receiveUser=Req::post('receiveUser');
  277. $telephone=Req::post('telephone');
  278. $address=Req::post('address');
  279. $remark=Req::post('remark');
  280. $atCode=Req::post('atCode');
  281. $atId=Req::post('atId');
  282. $img = Req::post('img');
  283. $warehouse=Req::post('warehouse');
  284. $receiveStorage=Req::post('receiveStorage');
  285. $partDetail=Req::post('partDetail');
  286. if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
  287. exit(json_encode($result));
  288. }
  289. if(strtotime($receiveDate)<strtotime(date('Ymd'))){
  290. $result['msg']='收货日期不正确';
  291. exit(json_encode($result));
  292. }
  293. $params=array();
  294. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  295. $coach_name=Yii::app()->session['coachInfo']['real_name'];
  296. }else{
  297. $coach_name=Yii::app()->session['coachInfo']['coach_name'];
  298. }
  299. $params['alType']=3;
  300. $params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
  301. $params['deliverStorage']=$warehouse;
  302. $params['receivePlace']=$address;
  303. $params['receiver']=$receiveUser;
  304. $params['receiveMobile']=$telephone;
  305. $params['arriveDate']=$receiveDate;
  306. $params['remark']=$remark;
  307. $params['consigneeName']=$receiveUser;
  308. $params['doorDoor']=0;
  309. $params['transportType']=1;
  310. $params['atCode']=$atCode;
  311. $params['atId']=$atId;
  312. $params['images']=$img;
  313. $params['receiveStorage']=$receiveStorage;
  314. if($allocateDetail){
  315. foreach ($allocateDetail as $val){
  316. @$idNum=explode('///',$val);
  317. if(isset($idNum[0]) && isset($idNum[1])){
  318. $params['requestAllocateDetail'][]=array(
  319. 'itemId'=>$idNum[0],
  320. 'applyNo'=>round($idNum[1],6),
  321. );
  322. }
  323. }
  324. }
  325. if($partDetail){
  326. foreach ($partDetail as $val){
  327. $partArr=explode('///',$val);
  328. if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
  329. $params['partReqDTOList'][]=array(
  330. 'applyNo'=>round($partArr[0],6),
  331. 'fpTypeId'=>$partArr[1],
  332. 'fcId'=>$partArr[2]
  333. );
  334. }
  335. }
  336. }
  337. $res = $this->getHttp("storage-allocate/coach/edit", 'POST', $params);
  338. if($res['status']==1){
  339. $result['status']=1;
  340. }else{
  341. $result['msg']=$res['msg'];
  342. }
  343. exit(json_encode($result));
  344. }
  345. /**
  346. * 调拨查看物流/确认收货
  347. */
  348. public function actionAllocationView()
  349. {
  350. $result = array();
  351. $atId = trim(Req::get('atId'));
  352. $result['atId'] = $atId;
  353. $result['sendData'] = array();
  354. $result['receiveData'] = array();
  355. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  356. $result['uploadUrl'] = $url;
  357. $result['basic'] = $this->setToken();
  358. if ($atId) {
  359. //发货记录
  360. $sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
  361. if ($sendRes['status'] == 1) {
  362. $result['sendData'] = $sendRes['data'];
  363. $logisticsTime = array();
  364. foreach ($sendRes['data'] as $v){
  365. $logisticsTime[] = $v['logisticsTime'];
  366. }
  367. $_logisticsTime = time() - strtotime(min($logisticsTime));
  368. if($_logisticsTime){
  369. $result['logisticsTime'] = floor($_logisticsTime/(24*3600));
  370. }else{
  371. $result['logisticsTime'] = 0;
  372. }
  373. } else {
  374. $this->errorMsg($sendRes['msg']);
  375. }
  376. //收货记录
  377. $receiveRes = $this->getHttp('storage-allocate/coach/receive-record/' . $atId, 'get');
  378. if ($receiveRes['status'] == 1) {
  379. foreach ($receiveRes['data'] as $value) {
  380. $result['receiveData'][$value['atoId']] = $value;
  381. }
  382. } else {
  383. $this->errorMsg($receiveRes['msg']);
  384. }
  385. $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
  386. if($res1['status']==1){
  387. if(isset($res1['data']['resDTOList'])){
  388. $result['logList']=$res1['data']['resDTOList'];
  389. }else{
  390. $result['logList']=array();
  391. }
  392. }
  393. } else {
  394. $this->errorMsg('调拨ID不正确');
  395. }
  396. //debug($result);
  397. $this->render('allocationView', $result);
  398. }
  399. /**
  400. * 确认收货
  401. */
  402. public function actionAjaxReceipt()
  403. {
  404. $result = array();
  405. $error = array();
  406. $atId = Req::post('atId');
  407. $atoId = Req::post('atoId');
  408. $qualifiedNo = round(Req::post('qualifiedNo'),6);
  409. $scrapNo = round(Req::post('scrapNo'),6);
  410. $tallyNo = round(Req::post('tallyNo'),6);
  411. $picUrl = (array)Req::post('imgArr');
  412. $fixedCodes = (array)Req::post('fixedCodes');
  413. $params = array(
  414. 'atId' => $atId,
  415. 'atoId' => $atoId,
  416. 'images' => $picUrl,
  417. 'qualifiedNo' => $qualifiedNo, //合格
  418. 'tallyNo'=>$qualifiedNo, //记账
  419. 'scrapNo' => $scrapNo, //不合格
  420. 'arriveNo'=> $tallyNo, //到账
  421. 'itemId' => Req::post('itemId'),
  422. 'fixedCodes' => $fixedCodes
  423. );
  424. $res = $this->getHttp('storage-allocate/coach/receipt', 'post', $params);
  425. $this->imsLog("仓库调拨-确认收货",'storage-allocate/coach/receipt',$params,$res);
  426. if ($res['status'] == 1) {
  427. $result = $res['data'];
  428. } else {
  429. $error[] = $res['msg'];
  430. }
  431. if ($error) {
  432. echo json_encode(array('status' => 0, 'error' => implode('<br/>', $error)));
  433. } else {
  434. echo json_encode(array('status' => 1, 'data' => $result));
  435. }
  436. }
  437. /**
  438. * 调拨查看物流/确认收货
  439. */
  440. public function actionAllocationViewDetail()
  441. {
  442. $atId = Req::get('atId');
  443. $data = array();
  444. if($atId){
  445. $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
  446. if($res1['status']==1){
  447. $data['title']=$res1['data']['atTitle'];
  448. $data['deliverName']=$res1['data']['deliverName']; //总仓
  449. $data['consignorName']=$res1['data']['consignorName']; //管理员
  450. $data['school_name']=$this->schoolInfo['school_name'];
  451. $data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
  452. $data['receiveUser']=$res1['data']['receiver'];
  453. $data['telephone']=$res1['data']['receiveMobile'];
  454. $data['address']=$res1['data']['receivePlace'];
  455. $data['remark']=$res1['data']['remark'];
  456. $data['atCode']=$res1['data']['atCode'];
  457. $data['atId']=$res1['data']['atId'];
  458. $data['images']=$res1['data']['images'];
  459. $data['receiveName']=$res1['data']['receiveName'];
  460. if(isset($res1['data']['resDTOList'])){
  461. $data['logList']=$res1['data']['resDTOList'];
  462. }else{
  463. $data['logList']=array();
  464. }
  465. if($res1['data']['details']){
  466. foreach ($res1['data']['details'] as $val){
  467. $data['allocateDetail'][]=array(
  468. 'itemId'=>$val['itemId'],
  469. 'itemName'=>$val['itemName'],
  470. 'applyNo'=>$val['applyNo'],
  471. 'invNo'=>$val['invNo'],
  472. 'unitName'=>$val['unitName'],
  473. 'typeName'=>$val['typeName']
  474. );
  475. }
  476. }
  477. if($res1['data']['partDetailList']){
  478. $data['partDetail']=$res1['data']['partDetailList'];
  479. }
  480. //读取问调表
  481. $res = $this->getHttp('storage-allocate/coach/experience-info/'.$atId,'GET');
  482. if($res['status']==1){
  483. $data['survey']=$res['data'];
  484. }
  485. $this->render('allocationViewDetail',$data);
  486. exit;
  487. }else{
  488. $this->errorMsg('ID不正确');
  489. }
  490. }
  491. }
  492. /***************** 销售出库 *****************/
  493. /**
  494. * 销售出库列表
  495. */
  496. public function actionDelivery()
  497. {
  498. $result = array();
  499. $params = array();
  500. $page = Req::get('page') ? Req::get('page') : 1;
  501. if (Req::get('isUse')) {
  502. $params['isUse'] = Req::get('isUse')-1;
  503. }
  504. if (Req::get('itemId')) {
  505. $params['itemId'] = Req::get('itemId');
  506. }
  507. if (Req::get('startDate')) {
  508. $params['startOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
  509. }
  510. if(Req::get('endDate')){
  511. $params['endOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
  512. }
  513. //品目名称
  514. $pmNameList = $this->getPmList();
  515. $result['itemList'] = $pmNameList;
  516. $res = $this->getHttp('storage-output/coach/list/' . $page, 'POST',$params);
  517. $result['pmDataList'] = array();
  518. if ($res['status'] == 1) {
  519. $result['pmDataList'] = $res['data'];
  520. }
  521. $result['useOutType']='use';
  522. $this->render('delivery', $result);
  523. }
  524. /*销售退库*/
  525. public function actionDeliveryOut(){
  526. $result = array();
  527. $params = array();
  528. $page = Req::get('page') ? Req::get('page') : 1;
  529. if (Req::get('isUse')) {
  530. $params['inputStatus'] = Req::get('isUse')-1;
  531. }
  532. if (Req::get('itemId')) {
  533. $params['itemId'] = Req::get('itemId');
  534. }
  535. if (Req::get('startDate')) {
  536. $params['startTime'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
  537. }
  538. if(Req::get('endDate')){
  539. $params['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
  540. }
  541. //品目名称
  542. $pmNameList = $this->getPmList();
  543. $result['itemList'] = $pmNameList;
  544. $params['pageNo'] = $page;
  545. $res = $this->getHttp('storage-input/coach/sale/list/' , 'POST',$params);
  546. $result['pmDataList'] = array();
  547. if ($res['status'] == 1) {
  548. $result['pmDataList'] = $res['data'];
  549. }
  550. $result['useOutType']='out';
  551. $this->render('deliveryOut', $result);
  552. }
  553. /*确认退库*/
  554. public function actionSubmitSale(){
  555. $inId = Req::post('inId');
  556. $res = $this->getHttp('storage-input/coach/sale/'.$inId, 'put');
  557. if ($res['status']){
  558. returnMsg(1,$res['msg']);
  559. }else{
  560. returnMsg(0,$res['msg']);
  561. }
  562. }
  563. /*退库学生列表*/
  564. public function actionAjaxSaleStudentList(){
  565. $inId = Req::post('inId');
  566. $page=Req::post('page');
  567. if(!$page) $page=1;
  568. $res = $this->getHttp("storage-input/coach/students/{$inId}/{$page}", 'get');
  569. if ($res['status']){
  570. returnMsg(1,'',$res['data']);
  571. }else{
  572. returnMsg(0,$res['msg']);
  573. }
  574. }
  575. /**
  576. * 销售出库编辑
  577. */
  578. public function actionDeliveryEdit()
  579. {
  580. $result = array();
  581. $outId = Req::get('outId');
  582. //品目名称
  583. $pmNameList = $this->getSalePmList();
  584. if (empty($pmNameList)){
  585. $this->errorMsg('暂无出库品目,无法新增出库单!');
  586. }
  587. $result['pmNameList'] = $pmNameList;
  588. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  589. $result['uploadUrl'] = $url;
  590. $result['basic'] = $this->setToken();
  591. if (is_numeric($outId) && $outId > 0) {
  592. $res = $this->getHttp('storage-output/coach/' . $outId, 'get');
  593. $result['pmData'] = array();
  594. if ($res['status'] == 1) {
  595. $result['pmData'] = $res['data'];
  596. $result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
  597. $result['total'] = $res['data']['outputDetails'][0]['no'];
  598. //出库学生列表
  599. $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
  600. $result['pmStudent'] = $outStudent['data'];
  601. $result['reStudentCount'] = count($outStudent['data']);
  602. } else {
  603. $this->errorMsg($res['msg']);
  604. }
  605. } else {
  606. $this->errorMsg('出库单ID不正确!');
  607. }
  608. $this->render('deliveryEdit', $result);
  609. }
  610. /**
  611. * 查看销售出库
  612. */
  613. public function actionDeliveryView()
  614. {
  615. $result = array();
  616. $outId = Req::get('outId');
  617. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  618. $result['uploadUrl'] = $url;
  619. $result['basic'] = $this->setToken();
  620. if (is_numeric($outId) && $outId > 0) {
  621. $res = $this->getHttp('storage-output/coach/' . $outId, 'get');
  622. $result['pmData'] = array();
  623. if ($res['status'] == 1) {
  624. $result['pmData'] = $res['data'];
  625. $result['itemName'] = $res['data']['outputDetails'][0]['itemName'];
  626. $result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
  627. $result['total'] = $res['data']['outputDetails'][0]['no'];
  628. //出库学生列表
  629. $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
  630. $result['pmStudent'] = $outStudent['data'];
  631. // dd($outStudent);
  632. $result['reStudentCount'] = count($outStudent['data']);
  633. } else {
  634. $this->errorMsg($res['msg']);
  635. }
  636. } else {
  637. $this->errorMsg('出库单ID不正确!');
  638. }
  639. $this->render('deliveryView', $result);
  640. }
  641. /**
  642. * 销售出库增加
  643. */
  644. public function actionDeliveryAdd()
  645. {
  646. $result = array();
  647. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  648. $result['uploadUrl'] = $url;
  649. $result['basic'] = $this->setToken();
  650. //品目名称
  651. $pmNameList = $this->getSalePmList();
  652. if (empty($pmNameList)){
  653. $this->errorMsg('暂无出库品目,无法新增出库单!');
  654. }
  655. $result['pmNameList'] = $pmNameList;
  656. $result['pmData'] = array();
  657. $this->render('deliveryAdd', $result);
  658. }
  659. /**
  660. * 删除出库
  661. */
  662. public function actionAjaxDelOut()
  663. {
  664. $outId = Req::post('outId');
  665. $http = http('storage-output/coach/'.$outId, 'delete', $this->authUsername);
  666. $response = formatResponse($http);
  667. $this->imsLog("销售出库-删除出库",'storage-output/coach/'.$outId,array(),$response);
  668. if ($response['status']){
  669. returnMsg(1, '提交成功!');
  670. }else{
  671. returnMsg(0, $response['data']);
  672. }
  673. }
  674. /**
  675. * 确认出库
  676. */
  677. public function actionAjaxUseOut()
  678. {
  679. $outId = Req::post('outId');
  680. $res = $this->getHttp('storage-output/coach/use/'.$outId, 'put');
  681. if ($res['status']){
  682. returnMsg(1,$res['msg']);
  683. }else{
  684. returnMsg(0,$res['msg']);
  685. }
  686. }
  687. /**
  688. * 销售出库编辑学生
  689. * @throws CException
  690. */
  691. public function actionAjaxEditStu(){
  692. $result = array();
  693. $error = array();
  694. $hasSelected = array();
  695. $orderId = trim(Req::post('orderId'));
  696. $outId = Req::post('outId')?Req::post('outId'):0;
  697. //正式订单列表的学生
  698. $res = $this->getHttp('order/coach/official/sale-out/students/'.$orderId, 'get');
  699. //出库学生列表
  700. if($outId){
  701. $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
  702. if ($outStudent['data']){
  703. foreach ($outStudent['data'] as $k=>$v){
  704. $hasSelected[$v['osId']] = $v;
  705. }
  706. }
  707. }
  708. if($res['status'] == 1){
  709. $result = $res['data'];
  710. }else{
  711. $error[] = $res['msg'];
  712. }
  713. if ($error) {
  714. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  715. } else {
  716. echo json_encode(array('status' => 1,'data' => $this->renderPartial('_selectStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'outId'=>$outId), true)));
  717. }
  718. }
  719. /**
  720. * ajax销售出库增加
  721. */
  722. public function actionAjaxDeliveryAdd(){
  723. $result = array();
  724. $error = array();
  725. $orderId = Req::post('orderId');
  726. $itemId = Req::post('itemId');
  727. $outDate = Req::post('outDate');
  728. $outTitle = Req::post('outTitle');
  729. $stuGetNum = (int)Req::post('stuGetNum');
  730. $stuIds= (array)Req::post('stuSeledArr');
  731. $imgArr= (array)Req::post('imgArr');
  732. //品目名称
  733. $pmNameList = $this->getSalePmList();
  734. $pmNameArr = array();
  735. foreach($pmNameList as $value){
  736. if($value['itemId'] == $itemId){
  737. $pmNameArr = $value;
  738. }
  739. }
  740. if(!$pmNameArr){
  741. $error[] = '品目信息不正确!';
  742. }
  743. if(!$error){
  744. $params = array(
  745. 'deliverStorage' => 0,
  746. 'itemType' => 2,
  747. 'orderId' => $orderId,
  748. 'osIds' => $stuIds,
  749. 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
  750. 'outTitle' => $outTitle,
  751. 'outType' => 1,
  752. 'images' => $imgArr,
  753. 'outputDetails' => array(
  754. array(
  755. 'itemCode' => $pmNameArr['itemCode'],
  756. 'itemId' => $pmNameArr['itemId'],
  757. 'itemName' => $pmNameArr['itemName'],
  758. 'itemSpec' => $pmNameArr['itemSpec'],
  759. 'no' => $stuGetNum*count($stuIds),
  760. )
  761. ),
  762. 'useType' => 0,
  763. 'userId' => 0,
  764. 'userName' => '',
  765. );
  766. //编辑
  767. if(Req::post('outId')){
  768. $params['outId'] = Req::post('outId');
  769. $res = $this->getHttp('storage-output/coach/edit', 'put',$params);
  770. $this->imsLog("销售出库-编辑出库单",'storage-output/coach/edit',$params,$res);
  771. }else{
  772. //新增
  773. $res = $this->getHttp('storage-output/coach/add', 'post',$params);
  774. $this->imsLog("销售出库-新增出库单",'storage-output/coach/add',$params,$res);
  775. }
  776. if($res['status'] == 1){
  777. $result = $res['data'];
  778. }else{
  779. $error[] = $res['msg'];
  780. }
  781. }
  782. if ($error) {
  783. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  784. } else {
  785. echo json_encode(array('status' => 1,'data' => $result));
  786. }
  787. }
  788. /**
  789. * 关联正式订单
  790. */
  791. public function actionAjaxRelOrder(){
  792. $error = array();
  793. $result = array();
  794. $page = (int)Req::post('page');
  795. $orderId = Req::post('orderId');
  796. $doType = Req::post('doType');
  797. $page = $page ? $page : 1;
  798. if($doType=='edit'){
  799. //编辑单独调取
  800. $res = $this->getHttp('order/coach/official/not-take/details/'.$page.'/except/'.$orderId, 'get');
  801. }else{
  802. $res = $this->getHttp('order/coach/official/not-take/details/'.$page, 'get');
  803. }
  804. if($res['status'] == 1){
  805. $result = $res['data'];
  806. }else{
  807. $error[] = $res['msg'];
  808. }
  809. if ($error) {
  810. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  811. } else {
  812. echo json_encode(array('status' => 1,'data' => $result));
  813. }
  814. }
  815. /***************** 仓库盘点 *****************/
  816. /**
  817. * 盘点页面
  818. */
  819. public function actionStock(){
  820. $result = array();
  821. $params = array();
  822. $page = Req::get('page')?Req::get('page'):1;
  823. if(Req::get('status')){
  824. $params['status'] = Req::get('status')-1;
  825. }
  826. if(Req::get('lossType')){
  827. $params['lossType'] = Req::get('lossType')-1;
  828. }
  829. if(Req::get('itemId')){
  830. $params['itemId'] = Req::get('itemId');
  831. }
  832. if(Req::get('startStockDate')){
  833. $params['startStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startStockDate')));
  834. }
  835. if(Req::get('endStockDate')){
  836. $params['endStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate')));
  837. }
  838. $res = $this->getHttp('storage-stock/coach/list/'.$page, 'post', $params);
  839. if($res['status']){
  840. $result['list'] = $res['data']['list'];
  841. $result['page'] = $res['data'];
  842. }else{
  843. $result['list'] = array();
  844. $result['page'] = array();
  845. }
  846. // debug($result['list']);
  847. //所有品目
  848. $item = $this->getHttp('item/all', 'get');
  849. $result['itemList'] = $item['data'];
  850. //审批状态
  851. $dict = $this->getDict('process_apply_status');
  852. $result['applyStatus'] = $dict;
  853. $this->render('stock',$result);
  854. }
  855. /**
  856. * 新增盘点
  857. */
  858. public function actionStockAdd(){
  859. $result = array();
  860. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  861. $result['uploadUrl'] = $url;
  862. $result['basic'] = $this->setToken();
  863. $this->render('stockAdd',$result);
  864. }
  865. //保存更新数据
  866. public function actionAjaxStockAdd(){
  867. $params = array();
  868. $params['stockTitle'] = Req::post('stockTitle');
  869. $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
  870. $params['itemId'] = Req::post('itemId');
  871. $params['itemCode'] = Req::post('itemCode');
  872. $params['itemName'] = Req::post('itemName');
  873. $params['itemSpec'] = Req::post('itemSpec');
  874. $params['unit'] = Req::post('unitId');
  875. $params['itemType'] = Req::post('itemType');
  876. $params['theoreticalNo'] = Req::post('theoreticalNo');
  877. $params['stockNo'] = Req::post('stockNo')?Req::post('stockNo'):0;
  878. $params['images'] = (array)Req::post('imgArr');
  879. $params['lossNo'] = Req::post('stockNo') - Req::post('theoreticalNo');
  880. $params['fixedCodes'] = (array)Req::post('fixedCodes');
  881. $params['invFixedCodes'] = (array)Req::post('invFixedCodes');
  882. $params['remark'] = Req::post('remark');
  883. if(Req::post('stockId')){
  884. //编辑
  885. $params['stockId'] = Req::post('stockId');
  886. //详情
  887. $detail = $this->getHttp('storage-stock/coach/'.$params['stockId'], 'get');
  888. $params['processInfo'] = $detail['data']['processInfo'];
  889. $response = $this->getHttp('storage-stock/coach/edit','put',$params);
  890. $this->imsLog("销售盘点-重盘",'storage-stock/coach/edit',$params,$response);
  891. }else{
  892. $response = $this->getHttp('storage-stock/coach/add','post',$params);
  893. $this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
  894. }
  895. if ($response['status']){
  896. returnMsg(1,$response['msg']);
  897. }else{
  898. returnMsg(0,$response['msg']);
  899. }
  900. }
  901. /**
  902. * 重盘
  903. */
  904. public function actionStockEdit(){
  905. $result = array();
  906. //品目
  907. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  908. $result['uploadUrl'] = $url;
  909. $result['basic'] = $this->setToken();
  910. $stockId = Req::get('stockId');
  911. //详情
  912. $detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
  913. if($detail['status']){
  914. $result['detail'] = $detail['data'];
  915. if(isset($detail['data']['remark'])){
  916. $result['detail']['remark'] = $detail['data']['remark'];
  917. }else{
  918. $result['detail']['remark'] = '';
  919. }
  920. //品目
  921. $itemType = $detail['data']['itemType'];
  922. $http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
  923. $result['itemList'] = $http['data'];
  924. $this->render('stockEdit',$result);
  925. }else{
  926. Yii::app()->jump->error($detail['msg']);
  927. }
  928. }
  929. //取消盘点
  930. public function actionAjaxStopStock()
  931. {
  932. $businessKey = Req::post('businessKey');
  933. $http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
  934. $response = formatResponse($http);
  935. $this->imsLog("销售盘点-取消",'activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
  936. if ($response['status']){
  937. returnMsg(1, '提交成功!');
  938. }else{
  939. returnMsg(0, $response['data']);
  940. }
  941. }
  942. //删除盘点
  943. public function actionAjaxDeleteStock()
  944. {
  945. $businessKey = Req::post('businessKey');
  946. $http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
  947. $response = formatResponse($http);
  948. $this->imsLog("销售盘点-删除",'activiti/coach/process-instances/'.$businessKey,array(),$response);
  949. if ($response['status']){
  950. returnMsg(1, '提交成功!');
  951. }else{
  952. returnMsg(0, $response['data']);
  953. }
  954. }
  955. /**
  956. * 查看
  957. */
  958. public function actionStockView()
  959. {
  960. $stockId = Req::get('stockId');
  961. $processInstanceId = Req::get('processInstanceId');
  962. //详情
  963. $detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
  964. //审核人员
  965. $process = $this->getHttp('activiti/coach/process-instances/'.$processInstanceId.'/trace','get');
  966. if($detail['status']){
  967. $result['detail'] = $detail['data'];
  968. $result['process'] = $process['data']['tasks'];
  969. $result['startUserName'] = $process['data']['startUserName'];
  970. $result['createTime'] = $process['data']['createTime'];
  971. $result['endTime'] = $process['data']['endTime'];
  972. $result['itemTypeName'] = itemType($detail['data']['itemType']);
  973. if(isset($detail['data']['remark'])){
  974. $result['detail']['remark'] = $detail['data']['remark'];
  975. }else{
  976. $result['detail']['remark'] = '';
  977. }
  978. $this->render('stockView',$result);
  979. }else{
  980. Yii::app()->jump->error($detail['msg']);
  981. }
  982. }
  983. //根据品类获取品目
  984. public function actionGetItem()
  985. {
  986. $itemType = Req::post('itemType');
  987. $http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
  988. if($http['status']){
  989. if($http['data']){
  990. returnMsg(1,'success',$http['data']);
  991. }else{
  992. returnMsg(0,'暂无数据');
  993. }
  994. }else{
  995. returnMsg(0,$http['msg']);
  996. }
  997. }
  998. //获取固定资产编号
  999. public function actionGetFixCode()
  1000. {
  1001. $itemId = Req::post('itemId');
  1002. $http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
  1003. if($http['status']){
  1004. if($http['data']){
  1005. returnMsg(1,'success',$http['data']);
  1006. }else{
  1007. returnMsg(0,'暂无数据');
  1008. }
  1009. }else{
  1010. returnMsg(0,$http['msg']);
  1011. }
  1012. }
  1013. /**
  1014. * 获取审核内容
  1015. */
  1016. public function actionGetTask()
  1017. {
  1018. $taskId = Req::post('taskId');
  1019. $task = $this->getHttp('activiti/coach/tasks/'.$taskId.'/form' ,'get');
  1020. if($task['status']){
  1021. returnMsg(1,'success',$task['data']);
  1022. }else{
  1023. returnMsg(0,$task['msg']);
  1024. }
  1025. }
  1026. /***************** 库存报表 *****************/
  1027. public function actionReport()
  1028. {
  1029. $params = array();
  1030. $result = array();
  1031. $page = Req::get('page')?Req::get('page'):1;
  1032. $itemId = trim(Req::get('itemId'));
  1033. $itemType = trim(Req::get('itemsType'));
  1034. if($itemId){
  1035. $params['itemId'] = Req::get('itemId');
  1036. }
  1037. if($itemType){
  1038. $params['itemIdType'] = $itemType;
  1039. }
  1040. //获取品目名称
  1041. $itemList = $this->getPmList();
  1042. $result['itemList'] = $itemList;
  1043. $res = $this->getHttp('storage-inventory/coach/report/'.$page, 'post',$params);
  1044. $result['list'] = array();
  1045. if ($res['status'] == 1) {
  1046. $result['list'] = $res['data']['list'];
  1047. $result['page'] = $res['data'];
  1048. } else {
  1049. $result['list'] = array();
  1050. $result['page'] = array();
  1051. }
  1052. $this->render('report', $result);
  1053. // $params = array();
  1054. // $result = array();
  1055. //
  1056. // $page = Req::get('page')?Req::get('page'):1;
  1057. // $itemId = trim(Req::get('itemId'));
  1058. //
  1059. // if($itemId){
  1060. // $params['itemId'] = Req::get('itemId');
  1061. // }
  1062. //
  1063. // //获取品目名称
  1064. // $itemList = $this->getPmList();
  1065. // $result['itemList'] = $itemList;
  1066. //
  1067. // $res = $this->getHttp('storage-inventory/report-coach/'.$page, 'post',$params);
  1068. // $result['reportList'] = array();
  1069. // if ($res['status'] == 1) {
  1070. // $result['reportList'] = $res['data'];
  1071. // } else {
  1072. // $result['reportList'] = array();
  1073. // }
  1074. //
  1075. // $this->render('report', $result);
  1076. }
  1077. /***************** 出入库账薄 *****************/
  1078. public function actionAccount(){
  1079. $params = array();
  1080. $result = array();
  1081. $itemId = trim(Req::get('itemId'));
  1082. $page = Req::get('page') ? Req::get('page') : 1;
  1083. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  1084. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  1085. }else{
  1086. $schoolId = 0;
  1087. }
  1088. if($itemId){
  1089. $params['itemId'] = $itemId;
  1090. }
  1091. $params['pageNum'] = $page;
  1092. $params['storageId'] = $schoolId;
  1093. $res = $this->getHttp('storage-inventory/coach/records', 'post',$params);
  1094. $result['list'] = array();
  1095. if ($res['status'] == 1) {
  1096. $result['list'] = $res['data']['list'];
  1097. $result['page'] = $res['data'];
  1098. } else {
  1099. $result['list'] = array();
  1100. $result['page'] = array();
  1101. }
  1102. $this->render('account', $result);
  1103. // $params = array();
  1104. // $result = array();
  1105. //
  1106. // $itemId = trim(Req::get('itemId'));
  1107. // $startTime = trim(Req::get('startDate'));
  1108. // $endTime = trim(Req::get('endDate'));
  1109. //
  1110. // //获取品目名称
  1111. // $itemList = $this->getPmList(true);
  1112. // $result['itemList'] = $itemList;
  1113. //
  1114. // if($itemId ){
  1115. // $params['itemId'] = Req::get('itemId');
  1116. // if($startTime){
  1117. // if(!getCheckDate($startTime)){
  1118. // $this->errorMsg('开始日期不正确!');
  1119. // }
  1120. // $params['startTime'] = $startTime;
  1121. // }
  1122. //
  1123. // if($endTime){
  1124. // if(!getCheckDate($endTime)){
  1125. // $this->errorMsg('结束日期不正确!');
  1126. // }
  1127. // $params['endTime'] = $endTime;
  1128. // }
  1129. // $result['startTime'] = $startTime;
  1130. // $result['endTime'] = $endTime;
  1131. //
  1132. // if(!isset($itemList[$itemId])){
  1133. // $this->errorMsg('品目不存在!');
  1134. // }else{
  1135. // $result['currItem'] = $itemList[$itemId];
  1136. // }
  1137. // $res = $this->getHttp('storage-inventory/ledger-coach/', 'post',$params);
  1138. //
  1139. // $result['reportList'] = array();
  1140. // if ($res['status'] == 1) {
  1141. // $result['reportList'] = $res['data'];
  1142. // } else {
  1143. // $this->errorMsg($res['msg']);
  1144. // }
  1145. // }else{
  1146. // $result['reportList'] = array();
  1147. // }
  1148. // $result['dateStrArr'] = $this->getDateStr();
  1149. //
  1150. //
  1151. // $this->render('account', $result);
  1152. }
  1153. /***************** 所需方法 *****************/
  1154. /**
  1155. * 处理接口返回的数据
  1156. * @param $res
  1157. * @return array
  1158. */
  1159. public function handleRes($res){
  1160. $result = array(
  1161. 'status' => 0,
  1162. 'data' => array(),
  1163. 'msg' => '暂无数据',
  1164. );
  1165. if($res){
  1166. $res = json_decode($res,true);
  1167. if(isset($res['errCode']) && $res['errCode'] == '00'){
  1168. $result['status'] = 1;
  1169. $result['data'] = isset($res['data'])?$res['data']:array();
  1170. $result['msg'] = $res['errMsg'];
  1171. }else{
  1172. if(isset($res['errMsg'])){
  1173. $result['msg'] = $res['errMsg'];
  1174. }
  1175. }
  1176. }
  1177. unset($res);
  1178. return $result;
  1179. }
  1180. /**
  1181. * 获取调拨所有品目列表
  1182. * @return array|mixed
  1183. */
  1184. private function getPmList($isRel = false){
  1185. $pmList = array();
  1186. $res = http('item/all', 'get', $this->authUsername);
  1187. if($res){
  1188. $result = $this->handleRes($res);
  1189. if($result['status'] == 1){
  1190. if($isRel){
  1191. foreach($result['data'] as $value){
  1192. $pmList[$value['itemId']] = $value;
  1193. }
  1194. }else{
  1195. $pmList = $result['data'];
  1196. }
  1197. }
  1198. }
  1199. unset($res);
  1200. return $pmList;
  1201. }
  1202. /**
  1203. * 获取销售品目列表
  1204. * @return array|mixed
  1205. */
  1206. private function getSalePmList($itemType=2){
  1207. $pmList = array();
  1208. $res = http('storage-inventory/coach-item/'.$itemType, 'get',$this->authUsername);
  1209. if($res){
  1210. $result = $this->handleRes($res);
  1211. if($result['status'] == 1){
  1212. $pmList = $result['data'];
  1213. }
  1214. }
  1215. unset($res);
  1216. return $pmList;
  1217. }
  1218. /**
  1219. * 获取接口数据
  1220. * @param $url
  1221. * @param $method
  1222. * @param array $params
  1223. * @return array
  1224. */
  1225. private function getHttp($url,$method,$params = array()){
  1226. $res = http($url, $method, $this->authUsername, $params);
  1227. $res = $this->handleRes($res);
  1228. return $res;
  1229. }
  1230. /**
  1231. * 错误信息
  1232. * @param $msg
  1233. */
  1234. private function errorMsg($msg){
  1235. Yii::app()->jump->error($msg);
  1236. }
  1237. /**
  1238. * 获取日期段
  1239. * @return array
  1240. */
  1241. private function getDateStr(){
  1242. $result = array();
  1243. $time = time();
  1244. $dayTime = 24*3600;
  1245. $week = date('w');
  1246. $result['curr_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime );
  1247. $result['curr_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime);
  1248. $result['pre_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime - 7*$dayTime);
  1249. $result['pre_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime - 7*$dayTime);
  1250. $result['curr_month_start'] = date("Y-m-01",$time);
  1251. $result['curr_month_end'] = date("Y-m-d",strtotime($result['curr_month_start']." +1 month -1 day"));
  1252. $result['pre_month_start'] = date("Y-m-d",strtotime($result['curr_month_start']." -1 month"));
  1253. $result['pre_month_end'] = date("Y-m-d",strtotime($result['pre_month_start']." +1 month -1 day"));
  1254. $result['curr_year_start'] = date("Y-01-01",$time);
  1255. $result['curr_year_end'] = date("Y-m-d",strtotime($result['curr_year_start']." +1 year -1 day"));
  1256. $result['pre_year_start'] = date('Y-m-d',strtotime($result['curr_year_start']." -1 year"));
  1257. $result['pre_year_end'] = date("Y-m-d",strtotime($result['pre_year_start']." +1 year -1 day"));
  1258. return $result;
  1259. }
  1260. public function setToken(){
  1261. $sign = $this->authUsername.Yii::app()->params['ims']['sign_url'].Yii::app()->params['ims']['sign'];
  1262. $authPassword = md5($sign);
  1263. $basic = "Basic ". base64_encode($this->authUsername.":".$authPassword);
  1264. return $basic;
  1265. }
  1266. /**
  1267. * @param $codeType
  1268. * @return array
  1269. * 获取字典
  1270. */
  1271. public function getDict($codeType)
  1272. {
  1273. $result = array();
  1274. $http = http('dictionary/list/type-code/'.$codeType, 'get', $this->authUsername);
  1275. $response = formatResponse($http);
  1276. if ($response['status']){
  1277. $result = $response['data'];
  1278. }
  1279. return $result;
  1280. }
  1281. public function actionSign(){
  1282. $result = array();
  1283. $result['data'] = array();
  1284. $outId = Req::get('outId');
  1285. $http = http('storage-output/coach/' . $outId, 'get',$this->authUsername);
  1286. if($http){
  1287. $http = json_decode($http,true);
  1288. }
  1289. if(isset($http['data']) && $http['data']){
  1290. $result['data'] = $http['data'];
  1291. $classSign = $singInfo = array();
  1292. $className = array();
  1293. $_data = array();
  1294. $result['data']['currClassId'] = 0;
  1295. if(isset($http['data']['signDetails']) && $http['data']['signDetails']){
  1296. $signDetails = $http['data']['signDetails'];
  1297. foreach ($signDetails as $value){
  1298. $classSign[$value['clazzId']] = $value['classSign'];
  1299. //签字图片,签字人
  1300. $_signInfo = array();
  1301. if(isset($value['signUrl']) && $value['signUrl']){
  1302. $_signInfo = array(
  1303. 'signUrl' => $value['signUrl'],
  1304. 'signRole' => $value['signRole'],
  1305. 'signPhone' => $value['signPhone']
  1306. );
  1307. }
  1308. $singInfo[$value['clazzId']] = $_signInfo;
  1309. //班级名称数组
  1310. $className[$value['clazzId']] = $value['clazzName'];
  1311. if(isset($value['studentNames']) && $value['studentNames']){
  1312. foreach ($value['studentNames'] as $v){
  1313. if(!$result['data']['currClassId']){
  1314. $result['data']['currClassId'] = $value['clazzId'];
  1315. }
  1316. $item = array();
  1317. $item['orderNo'] = isset($http['data']['orderNo'])?$http['data']['orderNo']:0;
  1318. $item['className'] = $value['clazzName'];
  1319. $item['classId'] = $value['clazzId'];
  1320. $item['studentName'] = $v;
  1321. $_data[] = $item;
  1322. }
  1323. }
  1324. }
  1325. }
  1326. $result['data']['_signDetails'] = $_data;
  1327. $result['data']['classSign'] = $classSign;
  1328. $result['data']['singInfo'] = $singInfo;
  1329. $result['data']['className'] = $className;
  1330. }else{
  1331. $this->errorMsg(isset($http['errMsg'])?$http['errMsg']:'接口获取数据失败');
  1332. }
  1333. $this->render('sign', $result);
  1334. }
  1335. /**********************************************************************************/
  1336. //领用出库
  1337. public function actionUseOut(){
  1338. $result = array();
  1339. $params = array();
  1340. $page = Req::get('page') ? Req::get('page') : 1;
  1341. if (Req::get('isUse')) { //状态
  1342. $params['status'] = Req::get('isUse')-1;
  1343. }
  1344. if (Req::get('itemId')) {
  1345. $params['itemId'] = Req::get('itemId');
  1346. }
  1347. if (Req::get('itemType')) {
  1348. $params['itemType'] = Req::get('itemType');
  1349. }
  1350. if (Req::get('inCode')) {
  1351. $params['inCode'] = Req::get('inCode');
  1352. }
  1353. if (Req::get('inputStatus')) {
  1354. $params['inputStatus'] = Req::get('inputStatus')-1;
  1355. }
  1356. $useOutType = Req::get('useOutType');
  1357. if(!$useOutType){
  1358. $useOutType = 'use';
  1359. }
  1360. if (Req::get('startDate')) {
  1361. $startDate = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
  1362. if($useOutType == 'use'){
  1363. $params['outDateBegin'] = $startDate;
  1364. }elseif($useOutType == 'useOut'){
  1365. $params['inDateBegin'] = $startDate;
  1366. }else{
  1367. $params['startTime'] = $startDate;
  1368. }
  1369. }
  1370. if(Req::get('endDate')){
  1371. $endDate = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
  1372. if($useOutType == 'use'){
  1373. $params['outDateEnd'] = $endDate;
  1374. }elseif($useOutType == 'useOut'){
  1375. $params['inDateEnd'] = $endDate;
  1376. }else{
  1377. $params['endTime'] = $endDate;
  1378. }
  1379. }
  1380. $params['pageNo'] = $page;
  1381. //品目名称
  1382. $pmNameList = $this->getPmList();
  1383. $result['itemList'] = $pmNameList;
  1384. if($useOutType == 'use'){
  1385. $res = $this->getHttp('storage/coach/client/take/list', 'POST',$params);
  1386. }elseif($useOutType == 'out'){
  1387. //退库
  1388. $res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
  1389. }else{
  1390. $res = $this->getHttp('storage-input/coach/cancel/list' , 'POST',$params);
  1391. // $res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
  1392. }
  1393. $result['pmDataList'] = array();
  1394. if ($res['status'] == 1) {
  1395. $result['pmDataList'] = $res['data'];
  1396. }
  1397. $result['useOutType'] = $useOutType;
  1398. //debug($result);
  1399. $this->render('useOut', $result);
  1400. }
  1401. /**
  1402. * 出库单出库
  1403. */
  1404. public function actionUseView()
  1405. {
  1406. $result = array();
  1407. $outId = Req::get('outId');
  1408. $scrapNo = 0;
  1409. if (is_numeric($outId) && $outId > 0) {
  1410. $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
  1411. $result['pmData'] = array();
  1412. if ($res['status'] == 1) {
  1413. $result['coachName']=$res['data']['userName'];
  1414. $result['pmData'] = $res['data'];
  1415. $result['coachName'] = isset($result['pmData']['userName'])?$result['pmData']['userName']:'';
  1416. if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
  1417. $result['itemName'] = $res['data']['itemList'][0]['itemName'];
  1418. $result['itemId'] = $res['data']['itemList'][0]['itemId'];
  1419. $result['stockNum'] = $res['data']['itemList'][0]['num'];
  1420. $result['itemTotal'] = $res['data']['itemList'][0]['invNo'];
  1421. $result['unitName'] = isset($res['data']['itemList'][0]['unitName'])?$res['data']['itemList'][0]['unitName']:'';
  1422. $result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
  1423. if(isset($res['data']['itemList'][0]['scrapNo'])){
  1424. $scrapNo = $res['data']['itemList'][0]['scrapNo'];
  1425. }
  1426. $result['fcCode'] = isset($res['data']['itemList'][0]['fcCode'])?$res['data']['itemList'][0]['fcCode']:'';
  1427. $result['fcName'] = isset($res['data']['itemList'][0]['fcName'])?$res['data']['itemList'][0]['fcName']:'';
  1428. $result['print'] = isset($res['data']['itemList'][0]['print'])?$res['data']['itemList'][0]['print']:'';
  1429. //$result['itemType'] = $res['data']['itemType'];
  1430. $result['fcId'] =isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
  1431. // $result['orderNo'] = $res['data']['orderNo'];
  1432. // $result['packageNo'] = $res['data']['packageNo'];
  1433. // $result['quantity'] = $res['data']['quantity'];
  1434. // $result['waitCheckNo'] = $res['data']['waitCheckNo'];
  1435. // $result['saleNo'] = $res['data']['saleNo'];
  1436. }else{
  1437. $this->errorMsg('数据为空');
  1438. }
  1439. if(isset($res['data']['processLogs'])){
  1440. $result['logList']=$res['data']['processLogs'];
  1441. }else{
  1442. $result['logList']=array();
  1443. }
  1444. } else {
  1445. $this->errorMsg($res['msg']);
  1446. }
  1447. } else {
  1448. $this->errorMsg('出库单ID不正确!');
  1449. }
  1450. //$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
  1451. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  1452. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  1453. }else{
  1454. $schoolId = 0;
  1455. }
  1456. $http = http('storage/coach/take/print/all', 'get', $this->authUsername);
  1457. $response = formatResponse($http);
  1458. $result['printList'] = $response['data'];
  1459. $result['schoolName'] = $this->getSchoolName($schoolId);
  1460. $result['scrapNo'] = $scrapNo;
  1461. $this->render('useView', $result);
  1462. }
  1463. /**
  1464. * 出库单增加
  1465. */
  1466. public function actionUseAddEdit()
  1467. {
  1468. $result = array();
  1469. $outId = Req::get('outId');
  1470. $itemType = Req::get('itemType')?Req::get('itemType'):0;
  1471. $result['pmData'] = array();
  1472. if($outId){
  1473. $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
  1474. if ($res['status'] == 1) {
  1475. $result['pmData'] = $res['data'];
  1476. $result['itemName'] = $res['data']['itemList'][0]['itemName'];
  1477. $result['itemId'] = $res['data']['itemList'][0]['itemId'];
  1478. $result['stockNum'] = $res['data']['itemList'][0]['num'];
  1479. if(!$itemType){
  1480. $itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
  1481. $result['fcId'] = isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
  1482. }
  1483. } else {
  1484. $this->errorMsg($res['msg']);
  1485. }
  1486. }
  1487. //品目名称
  1488. $itemType = $itemType?$itemType:2;
  1489. $pmNameList = $this->getSalePmList($itemType);
  1490. // if (empty($pmNameList)){
  1491. // $this->errorMsg('暂无出库品目,无法新增出库单!');
  1492. // }
  1493. $result['pmNameList'] = $pmNameList;
  1494. $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
  1495. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  1496. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  1497. }else{
  1498. $schoolId = 0;
  1499. }
  1500. $result['schoolName'] = $this->getSchoolName($schoolId);
  1501. $result['itemType'] = $itemType;
  1502. //获取学年
  1503. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  1504. $response = formatResponse($http);
  1505. $result['schoolYear'] = $response['data'];
  1506. //获取产品
  1507. $goodArr = $this->getGood();
  1508. $result['goodList'] = $goodArr;
  1509. //获取打印设备
  1510. $http = http('storage/coach/take/print/all', 'get', $this->authUsername);
  1511. $response = formatResponse($http);
  1512. $result['printList'] = $response['data'];
  1513. $this->render('useAddEdit', $result);
  1514. }
  1515. /**
  1516. * ajax出库增加
  1517. */
  1518. public function actionAjaxUseAdd(){
  1519. $result = array();
  1520. $error = array();
  1521. $itemId = Req::post('itemId');
  1522. $outDate = Req::post('outDate');
  1523. $outTitle = Req::post('outTitle');
  1524. $outStockNum = Req::post('outStockNum');
  1525. $useExplain= trim(Req::post('useExplain'));
  1526. $outId = Req::post('outId');
  1527. $itemType = Req::post('itemType');
  1528. $orderId = Req::post('orderId');
  1529. $fcId = Req::post('fcId');
  1530. //品目名称
  1531. $pmNameList = $this->getSalePmList($itemType);
  1532. $pmNameArr = array();
  1533. foreach($pmNameList as $value){
  1534. if($value['itemId'] == $itemId){
  1535. $pmNameArr = $value;
  1536. }
  1537. }
  1538. if(!$pmNameArr){
  1539. $error[] = '品目信息不正确!';
  1540. }
  1541. if(!$error){
  1542. $params = array(
  1543. 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
  1544. 'title' => $outTitle,
  1545. 'outItemDetail' => array(
  1546. 'itemId' => $itemId,
  1547. 'num' => round($outStockNum,6),
  1548. 'fcId'=>$fcId
  1549. ),
  1550. 'remark' => $useExplain,
  1551. 'orderId'=>$orderId,
  1552. );
  1553. //编辑
  1554. if($outId){
  1555. $params['outId'] = $outId;
  1556. $res = $this->getHttp('storage/coach/client/take/edit', 'post',$params);
  1557. $this->imsLog("编辑领用出库单",'storage/coach/client/take/edit',$params,$res);
  1558. }else{
  1559. //新增
  1560. $res = $this->getHttp('storage/coach/client/take/add', 'post',$params);
  1561. $this->imsLog("新增领用出库单",'storage/coach/client/take/add',$params,$res);
  1562. }
  1563. if($res['status'] == 1){
  1564. $result = $res['data'];
  1565. }else{
  1566. $error[] = $res['msg'];
  1567. }
  1568. }
  1569. if ($error) {
  1570. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1571. } else {
  1572. echo json_encode(array('status' => 1,'data' => $result));exit();
  1573. }
  1574. }
  1575. /**
  1576. * 关联正式订单
  1577. */
  1578. public function actionUseRelOrder(){
  1579. $error = array();
  1580. $result = array();
  1581. $page = (int)Req::get('page');
  1582. $doType = Req::get('doType');
  1583. $outId = Req::get('outId');
  1584. $allotNo = Req::get('allotNo');
  1585. $page = $page ? $page : 1;
  1586. if($doType=='relOrder'){
  1587. $res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
  1588. if(isset($res['status']) && $res['status'] == 1){
  1589. $result['validNum'] = isset($res['data']['validNum'])?$res['data']['validNum']:0;
  1590. $result['confirmNum'] = isset($res['data']['confirmNum'])?$res['data']['confirmNum']:0;
  1591. }else{
  1592. $this->errorMsg($res['msg']);
  1593. }
  1594. $res = $this->getHttp('storage/coach/client/take/not-allot/orders/'.$page, 'get');
  1595. if ($res['status'] == 1) {
  1596. $result['pmDataList'] = $res['data'];
  1597. } else {
  1598. $this->errorMsg($res['msg']);
  1599. }
  1600. }else{
  1601. $res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
  1602. if(isset($res['status']) && $res['status'] == 1){
  1603. $result['validList'] = $res['data'];
  1604. }else{
  1605. $this->errorMsg($res['msg']);
  1606. }
  1607. $res = $this->getHttp('storage/coach/client/take/orders/students/'.$outId.'/'.$page, 'get');
  1608. if ($res['status'] == 1) {
  1609. $result['pmDataList'] = $res['data'];
  1610. } else {
  1611. $this->errorMsg($res['msg']);
  1612. }
  1613. }
  1614. $result['outId'] = $outId;
  1615. $result['allotNo'] = $allotNo;
  1616. if($doType=='relOrder'){
  1617. $this->render('useRelOrder', $result);
  1618. }else{
  1619. $this->render('useViewRelOrder', $result);
  1620. }
  1621. }
  1622. /**
  1623. * 获取可发放数量
  1624. */
  1625. public function actionAjaxValidNum(){
  1626. $error = array();
  1627. $result = array();
  1628. $doType = Req::post('doType');
  1629. $outId = Req::post('outId');
  1630. if($doType == 'relOrder'){
  1631. $res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
  1632. }else{
  1633. $res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
  1634. }
  1635. if($res['status'] == 1){
  1636. $result = $res['data'];
  1637. }else{
  1638. $error[] = $res['msg'];
  1639. }
  1640. if ($error) {
  1641. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1642. } else {
  1643. echo json_encode(array('status' => 1,'data' => $result));exit();
  1644. }
  1645. }
  1646. /**
  1647. * 明细订单
  1648. * @throws CException
  1649. */
  1650. public function actionAjaxAppointDetail(){
  1651. $result = array();
  1652. $error = array();
  1653. $hasSelected = array();
  1654. $orderId = trim(Req::post('orderId'));
  1655. $outId = Req::post('outId')?Req::post('outId'):0;
  1656. //可选学生
  1657. $res = $this->getHttp('storage/coach/client/take/not-allot/students/'.$orderId, 'get');
  1658. if($res['status'] == 1){
  1659. $className = array();
  1660. foreach ($res['data'] as $v){
  1661. if(!isset($result[$v['clazzId']])){
  1662. $result[$v['clazzId']] = array();
  1663. }
  1664. $result[$v['clazzId']][] = $v;
  1665. $className[$v['clazzId']] = $v['clazzName'];
  1666. }
  1667. }else{
  1668. $error[] = $res['msg'];
  1669. }
  1670. if ($error) {
  1671. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1672. } else {
  1673. echo json_encode(array('status' => 1,'data' => $this->renderPartial('_orderSelectStu',array('relStuList'=>$result,'className'=>$className,'outId'=>$outId), true)));exit();
  1674. }
  1675. }
  1676. /**
  1677. * 保存关联订单
  1678. */
  1679. public function actionAjaxSaveRelOrder(){
  1680. $error = array();
  1681. $result = array();
  1682. $page = (int)Req::post('page');
  1683. $studentIds = (array)Req::post('studentIds');
  1684. $outId = Req::post('outId');
  1685. if(!$studentIds){
  1686. $error[] = '没有学生ID';
  1687. }
  1688. $params = array(
  1689. 'osIdList' => $studentIds,
  1690. 'outId' => $outId,
  1691. );
  1692. $res = $this->getHttp('storage/coach/client/take/allot/students', 'post',$params);
  1693. if($res['status'] == 1){
  1694. $result = $res['data'];
  1695. }else{
  1696. $error[] = $res['msg'];
  1697. }
  1698. if ($error) {
  1699. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1700. } else {
  1701. echo json_encode(array('status' => 1,'data' => $result));exit();
  1702. }
  1703. }
  1704. /************** 退库 *****************/
  1705. /**
  1706. * 退库单增加
  1707. */
  1708. public function actionOutAddEdit()
  1709. {
  1710. $result = array();
  1711. $outId = Req::get('outId');
  1712. $itemType = Req::get('itemType')?Req::get('itemType'):0;
  1713. $result['pmData'] = array();
  1714. if($outId){
  1715. $res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
  1716. if ($res['status'] == 1) {
  1717. $result['pmData'] = $res['data'];
  1718. if(!$itemType){
  1719. $itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
  1720. }
  1721. } else {
  1722. $this->errorMsg($res['msg']);
  1723. }
  1724. }
  1725. $itemType = $itemType?$itemType:2;
  1726. $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
  1727. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  1728. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  1729. }else{
  1730. $schoolId = 0;
  1731. }
  1732. $result['schoolName'] = $this->getSchoolName($schoolId);
  1733. $result['itemType'] = $itemType;
  1734. //品目名称
  1735. $pmNameList = $this->getPmList();
  1736. $result['itemList'] = $pmNameList;
  1737. //debug($result);
  1738. $this->render('outAdd', $result);
  1739. }
  1740. /**
  1741. * 退库选择品目
  1742. */
  1743. public function actionStockChioceItme(){
  1744. $error = array();
  1745. $result = array();
  1746. $params = array();
  1747. $page = Req::post('page');
  1748. $itemOutIds = Req::post('itemOutIds');
  1749. $itemType = Req::post('itemType');
  1750. $outCode = Req::post('outCode');
  1751. $itemId = Req::post('itemId');
  1752. // $res = $this->getHttp('storage/coach/client/take/items', 'get');
  1753. //筛选改成post
  1754. if($itemType){
  1755. $params['itemType'] = $itemType;
  1756. }else{
  1757. $params['itemType'] = 2;
  1758. }
  1759. if($outCode){
  1760. $params['outCode'] = $outCode;
  1761. }
  1762. if($itemId){
  1763. $params['itemId'] = $itemId;
  1764. }
  1765. // debug($params);exit;
  1766. $res = $this->getHttp('storage/coach/client/take/items', 'post',$params);
  1767. if($res['status'] == 1){
  1768. $result = $res['data'];
  1769. }else{
  1770. $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
  1771. }
  1772. if ($error) {
  1773. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
  1774. } else {
  1775. echo json_encode(array('status' => 1,'data' => $result));
  1776. }
  1777. exit();
  1778. }
  1779. /**
  1780. * ajax退库增加
  1781. */
  1782. public function actionAjaxOutAdd(){
  1783. $result = array();
  1784. $error = array();
  1785. $itemOutArr = (array)Req::post('itemOutArr');
  1786. $outDate = Req::post('outDate');
  1787. $outTitle = Req::post('outTitle');
  1788. $useExplain= trim(Req::post('useExplain'));
  1789. $outId = Req::post('outId');
  1790. $itemOutInfo = array();
  1791. if($itemOutArr){
  1792. foreach ($itemOutArr as $v){
  1793. $_arr = explode('_',$v);
  1794. if(count($_arr) != 3){
  1795. $error[] = '品目信息不正确!';
  1796. break;
  1797. }else{
  1798. $_temp = array();
  1799. $_temp['itemId'] = $_arr[0];
  1800. $_temp['outId'] = $_arr[1];
  1801. $_temp['num'] = round($_arr[2],6);
  1802. $itemOutInfo[] = $_temp;
  1803. }
  1804. }
  1805. }else{
  1806. $error[] = '品目信息不正确!';
  1807. }
  1808. if(!$error){
  1809. $params = array(
  1810. 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
  1811. 'title' => $outTitle,
  1812. 'outItemDetailList' => $itemOutInfo,
  1813. 'remark' => $useExplain,
  1814. 'title' => $outTitle,
  1815. );
  1816. //编辑
  1817. if($outId){
  1818. $params['outId'] = $outId;
  1819. $res = $this->getHttp('storage/coach/client/refound/edit', 'post',$params);
  1820. $this->imsLog("编辑退库单",'storage/coach/client/refound/edit',$params,$res);
  1821. }else{
  1822. //新增
  1823. $res = $this->getHttp('storage/coach/client/refound/add', 'post',$params);
  1824. $this->imsLog("新增退库单",'storage/coach/client/refound/add',$params,$res);
  1825. }
  1826. if($res['status'] == 1){
  1827. $result = $res['data'];
  1828. }else{
  1829. $error[] = $res['msg'];
  1830. }
  1831. }
  1832. if ($error) {
  1833. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1834. } else {
  1835. echo json_encode(array('status' => 1,'data' => $result));exit();
  1836. }
  1837. }
  1838. /**
  1839. * 出库单出库
  1840. */
  1841. public function actionOutView()
  1842. {
  1843. $result = array();
  1844. $outId = Req::get('outId');
  1845. if (is_numeric($outId) && $outId > 0) {
  1846. $res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
  1847. // debug($res);
  1848. $result['pmData'] = array();
  1849. if ($res['status'] == 1) {
  1850. $result['pmData'] = $res['data'];
  1851. if(isset($res['data']['processLogs'])){
  1852. $result['logList']=$res['data']['processLogs'];
  1853. }else{
  1854. $result['logList']=array();
  1855. }
  1856. $result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
  1857. // $result['itemType'] = $res['data']['itemType'];
  1858. // $result['orderNo'] = $res['data']['orderNo'];
  1859. // $result['packageNo'] = $res['data']['packageNo'];
  1860. // $result['quantity'] = $res['data']['quantity'];
  1861. // $result['waitCheckNo'] = $res['data']['waitCheckNo'];
  1862. // $result['saleNo'] = $res['data']['saleNo'];
  1863. } else {
  1864. $this->errorMsg($res['msg']);
  1865. }
  1866. } else {
  1867. $this->errorMsg('退库单ID不正确!');
  1868. }
  1869. $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
  1870. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  1871. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  1872. }else{
  1873. $schoolId = 0;
  1874. }
  1875. $result['schoolName'] = $this->getSchoolName($schoolId);
  1876. $this->render('outView', $result);
  1877. }
  1878. /**
  1879. * 确认退库
  1880. */
  1881. public function actionAjaxConfirmOut()
  1882. {
  1883. $result = array();
  1884. $error = array();
  1885. $outId = Req::get('outId');
  1886. if (is_numeric($outId) && $outId > 0) {
  1887. $params = array();
  1888. $res = $this->getHttp('storage/coach/client/refound/confirm/' . $outId, 'post',$params);
  1889. $result['pmData'] = array();
  1890. if ($res['status'] == 1) {
  1891. $result['pmData'] = $res['data'];
  1892. } else {
  1893. $error[] = $res['msg'];
  1894. }
  1895. } else {
  1896. $error[] = '退库单ID不正确!';
  1897. }
  1898. if ($error) {
  1899. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1900. } else {
  1901. echo json_encode(array('status' => 1, 'data' => $result));
  1902. exit();
  1903. }
  1904. }
  1905. /**
  1906. * 退库删除和中止
  1907. */
  1908. public function actionAjaxOutDelStop(){
  1909. $result = array();
  1910. $error = array();
  1911. $businessKey = Req::get('businessKey');
  1912. $doType = Req::get('doType');
  1913. if ($businessKey) {
  1914. if($doType == 'del'){
  1915. $http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
  1916. $response = formatResponse($http);
  1917. $this->imsLog('出库或退库删除','activiti/coach/process-instances/'.$businessKey,array(),$response);
  1918. }else{
  1919. $http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
  1920. $response = formatResponse($http);
  1921. $this->imsLog('出库或退库中止','activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
  1922. }
  1923. if (!$response['status']){
  1924. $error[] = $response['data'];
  1925. }
  1926. } else {
  1927. $error[] = 'businessKey不正确!';
  1928. }
  1929. if ($error) {
  1930. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
  1931. } else {
  1932. echo json_encode(array('status' => 1, 'data' => $result,'msg' => '提交成功!'));
  1933. exit();
  1934. }
  1935. }
  1936. /**
  1937. * 获取学校名称
  1938. */
  1939. public function getSchoolName($schoolId){
  1940. $schoolName = '';
  1941. if($schoolId){
  1942. $schoolInfo = BusinessSchool::model()->find('school_id=:school_id',array(':school_id'=>$schoolId));
  1943. if(isset($schoolInfo->school_name)){
  1944. $schoolName = $schoolInfo->school_name;
  1945. }
  1946. }
  1947. return $schoolName;
  1948. }
  1949. /********新盘点计划*************/
  1950. public function actionNewStock(){
  1951. $result = array();
  1952. $condition = array();
  1953. $page = Req::get('page')?Req::get('page'):1;
  1954. if(Req::get('planName')){
  1955. $condition['title'] = Req::get('planName');
  1956. }
  1957. if(Req::get('startStockDate')){
  1958. $condition['beginTime'] = date("Y-m-d H:i:s",strtotime(Req::get('startStockDate')));
  1959. }
  1960. if(Req::get('endStockDate')){
  1961. $condition['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate').' + 23 hours'));
  1962. }
  1963. $condition['pageNum'] = $page;
  1964. $res = $this->getHttp('plan/coach/page', 'post', $condition);
  1965. // debug($res);
  1966. if(!$res || $res['status'] != 1){
  1967. $this->errorMsg($res['msg']);
  1968. }else{
  1969. if(isset($res['data']) && isset($res['data']['list'])){
  1970. $result['list'] = $res['data']['list'];
  1971. }
  1972. $result['page'] = $res['data'];
  1973. }
  1974. $this->render('newstock',$result);
  1975. }
  1976. public function actionCreatePlanList(){
  1977. $result = array();
  1978. $planId = Req::get('planId');
  1979. if(isset($this->schoolInfo->school_name) && isset($this->coachInfo['coach_name'])){
  1980. $result['title'] = $this->schoolInfo->school_name.'-'.$this->coachInfo['coach_name'].'的盘点单'.date("Ymd",time());
  1981. }else{
  1982. $result['title'] = '';
  1983. }
  1984. $res = $this->getHttp('plan/coach/item/'.$planId, 'get');
  1985. // debug($res);
  1986. if(!$res || $res['status'] != 1){
  1987. $this->errorMsg($res['msg']);
  1988. }else{
  1989. if($res['data'] && isset($res['data']['fixedList'])){
  1990. // debug($res['data']['fixedList']);
  1991. if($res['data']['fixedList']){
  1992. foreach($res['data']['fixedList'] as $k=>$v){
  1993. $itemId = $v['itemId'];
  1994. $http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
  1995. if($http['status']){
  1996. if($http['data']){
  1997. $res['data']['fixedList'][$k]['originIds'] = implode(",", $http['data']);
  1998. }else{
  1999. $res['data']['fixedList'][$k]['originIds'] = '';
  2000. }
  2001. }else{
  2002. $res['data']['fixedList'][$k]['originIds'] = '';
  2003. }
  2004. }
  2005. }
  2006. }
  2007. }
  2008. $result['list'] = $res['data'];
  2009. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  2010. $result['uploadUrl'] = $url;
  2011. $result['basic'] = $this->setToken();
  2012. $result['planId'] = $planId;
  2013. //示例图片
  2014. $result['result'] = array();
  2015. $data = $this->getHttp('storage-stock/coach/example', 'get');
  2016. if($data && isset($data['status']) && $data['status'] == 1){
  2017. if(isset($data['data']) && $data['data']){
  2018. // $list = $data['data'];
  2019. $result['result'] = $data['data'];
  2020. }
  2021. }
  2022. // debug($result);
  2023. $this->render('createPlanList',$result);
  2024. }
  2025. //获取编号
  2026. public function actionAjaxGetIdentifier() {
  2027. $planId = Req::post('planId');
  2028. $http = $this->getHttp('storage-inventory/coach/fixed/'.$planId, 'get');
  2029. if($http['status']){
  2030. if($http['data']){
  2031. returnMsg(1,'success',$http['data']);
  2032. }else{
  2033. returnMsg(0,'暂无数据');
  2034. }
  2035. }else{
  2036. returnMsg(0,$http['msg']);
  2037. }
  2038. }
  2039. //提交盘点单
  2040. public function actionAjaxNewStockAdd(){
  2041. $params = array();
  2042. $params['pId'] = Req::post('pId');
  2043. $params['stockTitle'] = Req::post('stockTitle');
  2044. $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
  2045. $params['images'] = (array)Req::post('imgArr');
  2046. $params['remark'] = Req::post('remark');
  2047. $params['details'] = Req::post('details');
  2048. $response = $this->getHttp('storage-stock/coach/add','post',$params);
  2049. $this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
  2050. if ($response['status']){
  2051. returnMsg(1,$response['msg']);
  2052. }else{
  2053. returnMsg(0,$response['msg']);
  2054. }
  2055. }
  2056. //查看盘点单
  2057. public function actionViewPlanList(){
  2058. // echo 11;exit;
  2059. $result = array();
  2060. $planId = Req::get('planId');
  2061. $statusId = Req::get('statusId');
  2062. $res = $this->getHttp('storage-stock/coach/edit/'.$planId, 'get');
  2063. // debug($res);
  2064. if($res['status']){
  2065. if($res['data']['stocktakingDate']){
  2066. $res['data']['stocktakingDate'] = date("Y-m-d",strtotime($res['data']['stocktakingDate']));
  2067. }
  2068. $result['list'] = $res['data'];
  2069. if(isset($res['data']['resDTOList'])){
  2070. $result['logList']=$res['data']['resDTOList'];
  2071. }else{
  2072. $result['logList']=array();
  2073. }
  2074. }else{
  2075. $this->errorMsg($res['msg']);
  2076. }
  2077. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  2078. $result['uploadUrl'] = $url;
  2079. $result['basic'] = $this->setToken();
  2080. $result['statusId'] = $statusId;
  2081. // debug($result['list']);
  2082. $this->render('viewPlanList',$result);
  2083. }
  2084. //编辑盘点单
  2085. public function actionAjaxNewStockEdit(){
  2086. $params = array();
  2087. $params['pId'] = Req::post('pId');
  2088. $params['stockTitle'] = Req::post('stockTitle');
  2089. $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
  2090. $params['images'] = (array)Req::post('imgArr');
  2091. $params['remark'] = Req::post('remark');
  2092. $params['details'] = Req::post('details');
  2093. $params['stockId'] = Req::post('stockId');
  2094. $params['processInfo'] = Req::post('processInfo');
  2095. // debug($params);
  2096. $response = $this->getHttp('storage-stock/coach/edit','put',$params);
  2097. $this->imsLog("销售盘点-新增",'storage-stock/coach/edit',$params,$response);
  2098. if ($response['status']){
  2099. returnMsg(1,$response['msg']);
  2100. }else{
  2101. returnMsg(0,$response['msg']);
  2102. }
  2103. }
  2104. public function actionTransferList(){
  2105. $result = array();
  2106. $params = array();
  2107. $page = Req::get('page') ? Req::get('page') : 1;
  2108. if (Req::get('itemsType') && Req::get('itemsType')>0) {
  2109. $params['itemType'] = intval(Req::get('itemsType'));
  2110. }
  2111. if (Req::get('itemId')) {
  2112. $params['itemId'] = Req::get('itemId');
  2113. }
  2114. if(Req::get('transferType')){
  2115. if(Req::get('transferType') == 2){
  2116. $params['changeType'] = 0;
  2117. }else{
  2118. $params['changeType'] = intval(Req::get('transferType'));
  2119. }
  2120. }
  2121. if(Req::get('endDate')){
  2122. $params['endTime'] = Req::get('endDate');
  2123. }
  2124. //品目名称
  2125. $pmNameList = $this->getPmList();
  2126. $result['itemList'] = $pmNameList;
  2127. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  2128. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  2129. }else{
  2130. $schoolId = 0;
  2131. }
  2132. $params['pageNo'] = $page;
  2133. $params['storageId'] = $schoolId;
  2134. $res = $this->getHttp('storage/change/coach/list', 'POST', $params);
  2135. $result['list'] = array();
  2136. if ($res['status'] == 1) {
  2137. $result['list'] = $res['data']['list'];
  2138. $result['page'] = $res['data'];
  2139. } else {
  2140. $result['list'] = array();
  2141. $result['page'] = array();
  2142. }
  2143. $this->render('transferList', $result);
  2144. }
  2145. public function actionCreateTransfer(){
  2146. $result = array();
  2147. $outId = Req::get('outId');
  2148. //品目名称
  2149. $result['pmData'] = array();
  2150. if($outId){
  2151. $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
  2152. if ($res['status'] == 1) {
  2153. $result['pmData'] = $res['data'];
  2154. $result['itemName'] = $res['data']['itemList'][0]['itemName'];
  2155. $result['itemId'] = $res['data']['itemList'][0]['itemId'];
  2156. $result['stockNum'] = $res['data']['itemList'][0]['num'];
  2157. } else {
  2158. $this->errorMsg($res['msg']);
  2159. }
  2160. }
  2161. // $pmNameList = $this->getSalePmList();
  2162. // if (empty($pmNameList)){
  2163. // $this->errorMsg('暂无品目,无法新建转移!');
  2164. // }
  2165. $http = $this->getHttp('storage-inventory/coach-item/2', 'get');
  2166. $result['pmNameList'] = $http['data'];
  2167. $result['coachName'] = isset(Yii::app()->session['coachInfo']['coach_name'])?Yii::app()->session['coachInfo']['coach_name']:'';
  2168. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  2169. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  2170. }else{
  2171. $schoolId = 0;
  2172. }
  2173. $result['schoolName'] = $this->getSchoolName($schoolId);
  2174. $this->render('createTransfer', $result);
  2175. }
  2176. public function actionAjaxGetItem(){
  2177. $type = Req::post('type');
  2178. $res = $this->getHttp('storage-inventory/coach-item/'.$type, 'get');
  2179. $error = array();
  2180. if ($res['status'] == 1) {
  2181. $result = $res['data'];
  2182. } else {
  2183. $error[] = $res['msg'];
  2184. }
  2185. if ($error) {
  2186. echo json_encode(array('status' => 0, 'error' => implode('<br/>', $error)));
  2187. } else {
  2188. echo json_encode(array('status' => 1, 'data' => $result));
  2189. }
  2190. exit;
  2191. }
  2192. public function actionAjaxAddTransfer(){
  2193. $itemId = Req::post('itemId');
  2194. $title = Req::post('title');
  2195. $transferType = intval(Req::post('transferType'));
  2196. $outDate = Req::post('outDate');
  2197. $outStockNum = Req::post('outStockNum');
  2198. $itemsType = intval(Req::post('itemsType'));
  2199. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  2200. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  2201. }else{
  2202. $schoolId = 0;
  2203. }
  2204. $params = array(
  2205. 'changeDate' => $outDate.' 00:00:00',
  2206. 'changeType' => $transferType,
  2207. 'icTitle' => $title,
  2208. 'itemType' => $itemsType,
  2209. 'storageId'=>intval($schoolId),
  2210. 'details' => array(
  2211. array(
  2212. 'changeNo'=>round($outStockNum,6),
  2213. 'itemId'=>$itemId
  2214. )
  2215. ),
  2216. );
  2217. $response = $this->getHttp('storage/change/coach/add','POST',$params);
  2218. if ($response['status']){
  2219. returnMsg(1,$response['msg']);
  2220. }else{
  2221. returnMsg(0,$response['msg']);
  2222. }
  2223. }
  2224. /*****************新建退库单*********************/
  2225. //新建退库单
  2226. public function actionDeliveryOutAdd()
  2227. {
  2228. $result = array();
  2229. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  2230. $result['uploadUrl'] = $url;
  2231. $result['basic'] = $this->setToken();
  2232. //品目名称
  2233. $pmNameList = $this->getSalePmList();
  2234. if (empty($pmNameList)){
  2235. $this->errorMsg('暂无出库品目,无法新增出库单!');
  2236. }
  2237. $result['pmNameList'] = $pmNameList;
  2238. $result['pmData'] = array();
  2239. $this->render('deliveryOutAdd', $result);
  2240. }
  2241. /**
  2242. * 关联正式订单
  2243. */
  2244. public function actionAjaxOutputOrder(){
  2245. $error = array();
  2246. $result = array();
  2247. $page = (int)Req::post('page');
  2248. $orderId = Req::post('orderId');
  2249. $doType = Req::post('doType');
  2250. $page = $page ? $page : 1;
  2251. $res = $this->getHttp('storage-output/coach/order/list/'.$page, 'get');
  2252. if($res['status'] == 1){
  2253. $result = $res['data'];
  2254. }else{
  2255. $error[] = $res['msg'];
  2256. }
  2257. if ($error) {
  2258. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  2259. } else {
  2260. echo json_encode(array('status' => 1,'data' => $result));
  2261. }
  2262. die;
  2263. }
  2264. /**
  2265. * 销售出库编辑学生
  2266. * @throws CException
  2267. */
  2268. public function actionAjaxAddOutputStu(){
  2269. $result = array();
  2270. $error = array();
  2271. $hasSelected = array();
  2272. $params = array();
  2273. $orderId = trim(Req::post('orderId'));
  2274. $inId = Req::post('inId')?Req::post('inId'):0;
  2275. if(empty($orderId)){
  2276. echo json_encode(array('status' => 0, 'error' => '请选择订单'));
  2277. }
  2278. $params['orderId'] = $orderId;
  2279. $res = $this->getHttp('storage-output/coach/order/students/'.$orderId, 'get');
  2280. $gradeInfo = '';
  2281. if($res['status'] == 1){
  2282. $result = $res['data'];
  2283. }else{
  2284. $error[] = $res['msg'];
  2285. }
  2286. if ($error) {
  2287. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  2288. } else {
  2289. echo json_encode(array('status' => 1,'notice'=>$gradeInfo,'data' => $this->renderPartial('_selectOutStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'inId'=>$inId), true)));
  2290. }
  2291. exit;
  2292. }
  2293. /**
  2294. * ajax销售出库增加
  2295. */
  2296. public function actionAjaxDeliveryOutAdd(){
  2297. $result = array();
  2298. $error = array();
  2299. $orderId = Req::post('orderId');
  2300. $outDate = Req::post('outDate');
  2301. $stuIds= (array)Req::post('stuSeledArr');
  2302. if(empty($stuIds)){
  2303. $error[] = '请选择学生!';
  2304. }
  2305. // //品目名称
  2306. // $pmNameList = $this->getSalePmList();
  2307. // $pmNameArr = array();
  2308. // foreach($pmNameList as $value){
  2309. // if($value['itemId'] == $itemId){
  2310. // $pmNameArr = $value;
  2311. // }
  2312. // }
  2313. //
  2314. // if(!$pmNameArr){
  2315. // $error[] = '品目信息不正确!';
  2316. // }
  2317. if(!$error){
  2318. $params = array(
  2319. 'osIdList' => $stuIds
  2320. );
  2321. //编辑
  2322. // if(Req::post('inId')){
  2323. // $res = $this->getHttp('storage-input/coach/sale/edit/'.Req::post('inId'), 'post',$params);
  2324. // $this->imsLog("销售退库-编辑出库单",'storage-output/coach/edit',$params,$res);
  2325. // }else{
  2326. // //新增
  2327. // }
  2328. $res = $this->getHttp('storage-input/coach/sale/insert', 'post',$params);
  2329. $this->imsLog("取消分配",'storage-input/coach/sale/insert',$params,$res);
  2330. if($res['status'] == 1){
  2331. $result = $res['data'];
  2332. }else{
  2333. $error[] = $res['msg'];
  2334. }
  2335. }
  2336. if ($error) {
  2337. echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
  2338. } else {
  2339. echo json_encode(array('status' => 1,'data' => $result));
  2340. }
  2341. exit;
  2342. }
  2343. /**
  2344. * 查看销售退库
  2345. */
  2346. public function actionDeliveryOutView()
  2347. {
  2348. $result = array();
  2349. $inId = Req::get('inId');
  2350. $result['basic'] = $this->setToken();
  2351. if (is_numeric($inId) && $inId > 0) {
  2352. $res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
  2353. $result['pmData'] = array();
  2354. if ($res['status'] == 1) {
  2355. $result['pmData'] = $res['data'];
  2356. $result['pmStudent'] = $res['data']['students'];
  2357. } else {
  2358. $this->errorMsg($res['msg']);
  2359. }
  2360. } else {
  2361. $this->errorMsg('取消分配单ID不正确!');
  2362. }
  2363. $this->render('deliveryOutView', $result);
  2364. }
  2365. /**
  2366. * 删除退库
  2367. */
  2368. public function actionAjaxDelIn()
  2369. {
  2370. $inId = Req::post('inId');
  2371. if(empty($inId)){
  2372. returnMsg(0, '参数错误');
  2373. }
  2374. $http = http('storage-input/coach/sale/'.$inId, 'delete', $this->authUsername);
  2375. print_r($http);die;
  2376. $response = formatResponse($http);
  2377. $this->imsLog("销售退库-删除退库",'storage-input/coach/sale/'.$inId,array(),$response);
  2378. if ($response['status']){
  2379. returnMsg(1, '提交成功!');
  2380. }else{
  2381. returnMsg(0, $response['data']);
  2382. }
  2383. }
  2384. /**
  2385. * 销售出库编辑
  2386. */
  2387. public function actionDeliveryOutEdit()
  2388. {
  2389. $result = array();
  2390. $inId = Req::get('inId');
  2391. //品目名称
  2392. $pmNameList = $this->getSalePmList();
  2393. if (empty($pmNameList)){
  2394. $this->errorMsg('暂无出库品目,无法新增出库单!');
  2395. }
  2396. $result['pmNameList'] = $pmNameList;
  2397. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  2398. $result['uploadUrl'] = $url;
  2399. $result['basic'] = $this->setToken();
  2400. if (is_numeric($inId) && $inId > 0) {
  2401. $res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
  2402. $result['pmData'] = array();
  2403. if ($res['status'] == 1) {
  2404. $result['pmData'] = $res['data'];
  2405. $result['itemId'] = $res['data']['inputDetails'][0]['itemId'];
  2406. $result['pmStudent'] = $res['data']['students'];
  2407. $result['pmData']['outDate'] = $res['data']['inDate'];
  2408. } else {
  2409. $this->errorMsg($res['msg']);
  2410. }
  2411. } else {
  2412. $this->errorMsg('退库单ID不正确!');
  2413. }
  2414. $this->render('deliveryOutEdit', $result);
  2415. }
  2416. /**
  2417. * 查看盘点示例
  2418. */
  2419. public function actionPlanExamples(){
  2420. // $this->errorMsg('暂无出库品目,无法新增出库单!');
  2421. $list = array();
  2422. $planId = Req::get('planId');
  2423. $data = $this->getHttp('storage-stock/coach/example', 'get');
  2424. if($data && isset($data['status']) && $data['status'] == 1){
  2425. if(isset($data['data']) && $data['data']){
  2426. $list = $data['data'];
  2427. }else{
  2428. $this->errorMsg('暂无示例图片!');
  2429. }
  2430. }else{
  2431. $this->errorMsg('暂无示例!');
  2432. }
  2433. // debug($data);
  2434. $this->render('planExamples', array('result'=>$list,'planId'=>$planId));
  2435. }
  2436. //取消凭据
  2437. public function actionSuspended(){
  2438. $businessKey= Req::post('businessKey');
  2439. if(empty($businessKey)){
  2440. returnMsg(0, '参数错误');
  2441. }
  2442. $http = http("activiti/coach/process-instances/{$businessKey}/suspended", 'put', $this->authUsername);
  2443. $response = formatResponse($http);
  2444. if ($response['status']){
  2445. returnMsg(1, '提交成功!');
  2446. }else{
  2447. returnMsg(0, $response['data']);
  2448. }
  2449. }
  2450. //重新确认收货
  2451. public function actionRepeatReceipt(){
  2452. $imgArr= Req::post('imgArr');
  2453. $atoId= Req::post('atoId');
  2454. if(empty($imgArr) || empty($atoId)){
  2455. returnMsg(0, '参数错误');
  2456. }
  2457. $params = array(
  2458. 'atoId' => $atoId,
  2459. 'images' => $imgArr,
  2460. );
  2461. $res = $this->getHttp('storage-allocate/coach/fixed-receipt/'.$atoId, 'put', $params);
  2462. if ($res['status']){
  2463. returnMsg(1, '提交成功!');
  2464. }else{
  2465. returnMsg(0, $res['data']);
  2466. }
  2467. }
  2468. //领用,发放订单
  2469. public function actionGrant(){
  2470. $outId = Req::get('outId');
  2471. $num = 0;
  2472. $dataList=array();
  2473. if (is_numeric($outId) && $outId > 0) {
  2474. //搜索销售订单
  2475. $orderNo=Req::get('orderNo');
  2476. $grade=Req::get('grade');
  2477. $semester=Req::get('semester');
  2478. $schoolYearId=Req::get('schoolYearId');
  2479. $page=Req::get('page');
  2480. if(!$page) $page=1;
  2481. $params=array();
  2482. $params['pageNum']=$page;
  2483. $params['outId']=$outId;
  2484. if($orderNo){
  2485. $params['orderNo']=$orderNo;
  2486. }
  2487. if($grade){
  2488. $params['grade']=$grade;
  2489. }
  2490. if($semester){
  2491. $params['semester']=$semester-1;
  2492. }
  2493. if($schoolYearId){
  2494. $params['schoolYearId']=$schoolYearId;
  2495. }
  2496. $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
  2497. $result['pmData'] = array();
  2498. if ($res['status'] == 1) {
  2499. $result['pmData'] = $res['data'];
  2500. if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
  2501. $result['num']= $res['data']['itemList'][0]['num'];
  2502. $result['typeId']= $res['data']['itemList'][0]['typeId'];
  2503. }else{
  2504. $this->errorMsg('数据为空');
  2505. }
  2506. if(isset($res['data']['sendNo'])){
  2507. $result['sendNo']=$res['data']['sendNo'];
  2508. }else{
  2509. $result['sendNo']=0;
  2510. }
  2511. if(isset($res['data']['refoundNo'])){
  2512. $result['refoundNo']=$res['data']['refoundNo'];
  2513. }else{
  2514. $result['refoundNo']=0;
  2515. }
  2516. } else {
  2517. $this->errorMsg($res['msg']);
  2518. }
  2519. }
  2520. $params = array();
  2521. //获取学年
  2522. $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
  2523. $response = formatResponse($http);
  2524. $result['schoolYear'] = $response['data'];
  2525. $result['outId']=$outId;
  2526. //debug($result);
  2527. $this->render('grant',$result);
  2528. }
  2529. //查看发放记录
  2530. public function actionViewGrant(){
  2531. $outId = Req::get('outId');
  2532. $num = 0;
  2533. $dataList=array();
  2534. if (is_numeric($outId) && $outId > 0) {
  2535. //搜索销售订单
  2536. $orderNo=Req::get('orderNo');
  2537. $grade=Req::get('grade');
  2538. $semester=Req::get('semester');
  2539. $schoolYearId=Req::get('schoolYearId');
  2540. $page=Req::get('page');
  2541. if(!$page) $page=1;
  2542. $params=array();
  2543. $params['pageNum']=$page;
  2544. $params['outId']=$outId;
  2545. if($orderNo){
  2546. $params['orderNo']=$orderNo;
  2547. }
  2548. if($grade){
  2549. $params['grade']=$grade;
  2550. }
  2551. if($semester){
  2552. $params['semester']=$semester-1;
  2553. }
  2554. if($schoolYearId){
  2555. $params['schoolYearId']=$schoolYearId;
  2556. }
  2557. $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
  2558. $result['pmData'] = array();
  2559. if ($res['status'] == 1) {
  2560. $result['itemType']=$res['data']['itemType'];
  2561. $result['pmData'] = $res['data']['coachSaleOrders'];
  2562. } else {
  2563. $this->errorMsg($res['msg']);
  2564. }
  2565. }
  2566. //获取学年
  2567. $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
  2568. $response = formatResponse($http);
  2569. $result['schoolYear'] = $response['data'];
  2570. //学期
  2571. $http = http('sys/school/year/semester/list', 'get', $this->authUsername);
  2572. $response = formatResponse($http);
  2573. $result['seasonList'] = $response['data'];
  2574. $result['outId']=$outId;
  2575. $result['orderNo']=$orderNo;
  2576. $result['grade']=$grade;
  2577. $result['semester']=$semester;
  2578. $result['schoolYearId']=$schoolYearId;
  2579. $this->render('view_grant',$result);
  2580. }
  2581. //选择销售订单
  2582. public function actionAjaxGetOrderList(){
  2583. $orderNo=Req::post('orderNo');
  2584. $grade=Req::post('grade');
  2585. $semester=Req::post('semester');
  2586. $schoolYear=Req::post('schoolYearId');
  2587. $page=Req::post('page');
  2588. $typeId=Req::post('typeId');
  2589. $error=array();
  2590. if(!$page) $page=1;
  2591. $params=array();
  2592. $params['pageNum']=$page;
  2593. if($grade){
  2594. $params['grade']=$grade;
  2595. }
  2596. if($orderNo){
  2597. $params['orderNo']=$orderNo;
  2598. }
  2599. if($semester){
  2600. $params['semester']=$semester;
  2601. }
  2602. if($schoolYear){
  2603. $params['schoolYearId']=$schoolYear;
  2604. }
  2605. if($typeId){
  2606. $params['itemType']=$typeId;
  2607. }
  2608. $res = $this->getHttp('storage/coach/client/take/order/list', 'post', $params);
  2609. if($res['status'] == 1){
  2610. $result = $res['data'];
  2611. }else{
  2612. $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
  2613. }
  2614. if ($error) {
  2615. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
  2616. } else {
  2617. echo json_encode(array('status' => 1,'data' => $result));
  2618. }
  2619. exit();
  2620. }
  2621. /**
  2622. * @return array
  2623. * 获取商品
  2624. */
  2625. public function getGood()
  2626. {
  2627. $result = array();
  2628. $http = http('goods/up/list', 'get', $this->authUsername);
  2629. $response = formatResponse($http);
  2630. if($response['status']){
  2631. $result = $response['data'];
  2632. }
  2633. return $result;
  2634. }
  2635. //保存发放订单
  2636. public function actionSaveGrant(){
  2637. $outId=Req::post('outId');
  2638. $orders=Req::post('orders');
  2639. if(!$outId || !$orders){
  2640. returnMsg(0, '参数错误');
  2641. }
  2642. $error=array();
  2643. $param['outId']=$outId;
  2644. $param['orders']=$orders;
  2645. $res = $this->getHttp('storage/coach/client/take/allot/order', 'post', $param);
  2646. if($res['status'] == 1){
  2647. $result = $res['data'];
  2648. }else{
  2649. $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
  2650. }
  2651. if ($error) {
  2652. echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
  2653. } else {
  2654. echo json_encode(array('status' => 1,'data' => $result));
  2655. }
  2656. exit();
  2657. }
  2658. //发货
  2659. public function actionDeliverGoods(){
  2660. $result = array();
  2661. $atId = trim(Req::get('atId'));
  2662. $result['sendData'] = array();
  2663. if ($atId) {
  2664. //发货记录
  2665. $sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
  2666. if ($sendRes['status'] == 1) {
  2667. $result['sendData'] = $sendRes['data'];
  2668. }
  2669. $res1 = $this->getHttp('storage-allocate/coach/details/' . $atId, 'GET');
  2670. if ($res1['status'] == 1) {
  2671. $result['atType']=$res1['data']['atType'];
  2672. $result['images']=$res1['data']['images'];
  2673. if($res1['data']['details']){
  2674. foreach ($res1['data']['details'] as $val){
  2675. $result['allocateDetail'][]=array(
  2676. 'atDetailId'=>$val['atDetailId'],
  2677. 'itemId'=>$val['itemId'],
  2678. 'itemName'=>$val['itemName'],
  2679. 'applyNo'=>$val['applyNo'],
  2680. 'invNo'=>$val['invNo'],
  2681. 'unitName'=>$val['unitName'],
  2682. 'typeName'=>$val['typeName'],
  2683. 'itemSpec'=>$val['itemSpec'],
  2684. 'deliveryStatusName'=>$val['deliveryStatusName'],
  2685. );
  2686. }
  2687. }
  2688. }
  2689. //快递
  2690. $express = $this->getHttp('dictionary/list/type-code/express', 'get');
  2691. if ($express['status'] == 1) {
  2692. $result['express'] = $express['data'];
  2693. }
  2694. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  2695. $result['uploadUrl'] = $url;
  2696. $result['basic'] = $this->setToken();
  2697. }
  2698. $this->render('deliverGoods',$result);
  2699. }
  2700. //读取固定资产编号
  2701. public function actionGetFixedAssetsNo(){
  2702. $itemId = trim(Req::post('itemId'));
  2703. $result['status']=1;
  2704. $Fixed = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
  2705. if ($Fixed['status'] == 1) {
  2706. $result['data'] = $Fixed['data'];
  2707. }
  2708. exit(json_encode($result));
  2709. }
  2710. //确认发货
  2711. public function actionConfirmDeliver(){
  2712. $atDetailId= Req::post('atDetailId');
  2713. $logisticsCode= Req::post('logisticsCode');
  2714. $logisticsName= Req::post('logisticsName');
  2715. $fixedCodes= Req::post('fixedCodes');
  2716. $no= Req::post('no');
  2717. $imgUrls= Req::post('imgUrls');
  2718. $result['status']=0;
  2719. $params=array(
  2720. 'atDetailId'=>$atDetailId,
  2721. 'logisticsCode'=>$logisticsCode,
  2722. 'logisticsName'=>$logisticsName,
  2723. 'fixedCodes'=>$fixedCodes,
  2724. 'no'=>$no,
  2725. 'imgUrls'=>$imgUrls
  2726. );
  2727. $rs = $this->getHttp('storage-allocate/coach/deliver', 'post',$params);
  2728. if($rs['status']==1){
  2729. $result['status']=1;
  2730. }else{
  2731. if($rs['data']){
  2732. $result['msg']=$rs['data'];
  2733. }else{
  2734. $result['msg']='发货失败';
  2735. }
  2736. }
  2737. exit(json_encode($result));
  2738. }
  2739. //取消调拨
  2740. public function actionCancelAllocation(){
  2741. $atId= Req::post('atId');
  2742. $rs = $this->getHttp('storage-allocate/coach/status/'.$atId, 'put');
  2743. $result['status']=0;
  2744. if($rs['status']==1){
  2745. $result['status']=1;
  2746. }else{
  2747. if($rs['data']){
  2748. $result['msg']=$rs['msg'];
  2749. }else{
  2750. $result['msg']='操作失败';
  2751. }
  2752. }
  2753. exit(json_encode($result));
  2754. }
  2755. //加载设备编号(添加零件)
  2756. public function actionGetDevice(){
  2757. $storageId= Req::post('storageId');
  2758. $rs = $this->getHttp('storage-inventory/greater-zero/0/'.$storageId, 'get');
  2759. exit(json_encode($rs));
  2760. }
  2761. //加载设备编号(添加零件)
  2762. public function actionGetPart(){
  2763. $fixedId= Req::post('fixedId');
  2764. $rs = $this->getHttp('fixed/part/list/'.$fixedId, 'get');
  2765. exit(json_encode($rs));
  2766. }
  2767. //根据零配件类型加载设备
  2768. public function actionGetDeviceByPart(){
  2769. $partType= Req::post('partType');
  2770. $storageId= Req::post('storageId');
  2771. $rs = $this->getHttp('storage-inventory/query-fixed/list/'.$partType.'/ '.$storageId, 'get');
  2772. exit(json_encode($rs));
  2773. }
  2774. }