123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459 |
- package controllers
-
- import (
- "encoding/json"
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- )
-
- type SelfDrugApiController struct {
- BaseAuthAPIController
- }
-
- func SelfDrugRouters() {
-
- beego.Router("/api/drug/getcurrentpatient", &SelfDrugApiController{}, "Get:GetCurrentPatient")
- beego.Router("/api/drug/getalldrugname", &SelfDrugApiController{}, "Get:GetAllDrugName")
- beego.Router("/api/drug/savedrugname", &SelfDrugApiController{}, "Get:SaveDrugName")
- beego.Router("/api/drug/getdrugnamelist", &SelfDrugApiController{}, "Get:GetDrugNameList")
- beego.Router("/api/drug/getrullename", &SelfDrugApiController{}, "Get:GetRulleName")
- beego.Router("/api/drug/getunitbybaseid", &SelfDrugApiController{}, "Get:GetUnitByBaseId")
- beego.Router("/api/drug/saverullename", &SelfDrugApiController{}, "Get:SaveRulleName")
- beego.Router("/api/drug/editrullername", &SelfDrugApiController{}, "Get:EditRullerName")
- beego.Router("/api/drug/updatedrullername", &SelfDrugApiController{}, "Get:UpdatedRullerName")
- beego.Router("/api/drug/getalldrugnamelist", &SelfDrugApiController{}, "Get:GetAllDrugNameList")
- beego.Router("/api/drug/getrulllistbydrugname", &SelfDrugApiController{}, "Get:GetRullerListByDrugName")
- beego.Router("/api/drug/saveselfmedicines", &SelfDrugApiController{}, "Post:SaveSelfMedicines")
- beego.Router("/api/drug/getcurrentorgallstaff", &SelfDrugApiController{}, "Get:GetCurrentOrgAllStaff")
- beego.Router("/api/drug/savestock", &SelfDrugApiController{}, "Post:SaveStock")
- beego.Router("/api/drug/saveoutstock", &SelfDrugApiController{}, "Post:SaveOutStock")
- beego.Router("/api/drug/deletedrugbyid", &SelfDrugApiController{}, "Get:DeleteDrugById")
- beego.Router("/api/drug/saveradio", &SelfDrugApiController{}, "Get:SaveRadio")
- beego.Router("/api/drug/deletedrugstand", &SelfDrugApiController{}, "Get:DeleteDrugStand")
- beego.Router("/api/drug/getstocklist", &SelfDrugApiController{}, "Get:GetStockList")
- beego.Router("/api/drug/deletedrugname", &SelfDrugApiController{}, "Get:DeleteDrugName")
- beego.Router("/api/drug/getdrugdetail", &SelfDrugApiController{}, "Get:GetDrugDetail")
- beego.Router("/api/drug/getallpatientstocklist", &SelfDrugApiController{}, "Get:GetAllPatientStockList")
- beego.Router("/api/drug/getdrugdatabypatientid", &SelfDrugApiController{}, "Get:GetDrugDataByPatientId")
- beego.Router("/api/drug/getselfmedicallist", &SelfDrugApiController{}, "Get:GetSelfMedicalList")
- beego.Router("/api/drug/getdrugdescbydrugname", &SelfDrugApiController{}, "Get:GetDrugDescByDrugName")
- beego.Router("/api/drug/getdrugset", &SelfDrugApiController{}, "Get:GetDrugSet")
- beego.Router("/api/drug/getallmedicallist", &SelfDrugApiController{}, "Get:GetAllMedicalList")
- beego.Router("/api/drug/getstandname", &SelfDrugApiController{}, "Get:GetStandName")
- beego.Router("/api/drug/getrullerlist", &SelfDrugApiController{}, "Get:GetRullerList")
- beego.Router("/api/drug/deleteDrugNamebyid", &SelfDrugApiController{}, "Get:DeleteDrugNameById")
- beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
- //beego.Router("/api/drug/getpatientdetail",&SelfDrugApiController{},"Get:ToPatientDetail")
- beego.Router("/api/drug/getselfstockquery", &SelfDrugApiController{}, "Get:GetSelfStockQuery")
- beego.Router("/api/drug/postsearchdrugwarehouselist", &SelfDrugApiController{}, "Get:PostSearchDrugWarehouseList")
- beego.Router("/api/drug/savedrugpriceone", &SelfDrugApiController{}, "Post:SaveDrugPrice")
- beego.Router("/api/drug/drugpricelist", &SelfDrugApiController{}, "Get:GetDrugPriceList")
- beego.Router("/api/drug/savecheckdrugprice", &SelfDrugApiController{}, "Get:SaveCheckDrugPrice")
- beego.Router("/api/drug/savedrugdamageone", &SelfDrugApiController{}, "Post:SaveDrugDamage")
- beego.Router("/api/drug/getdrugdamagelist", &SelfDrugApiController{}, "Get:GetDrugDamageList")
- beego.Router("/api/drug/savedrugdamageprice", &SelfDrugApiController{}, "Get:SaveDrugDamagePrice")
- beego.Router("/api/drug/getdrugmodifyprice", &SelfDrugApiController{}, "Get:GetDrugModifyPrice")
- beego.Router("/api/drug/modifydrugprice", &SelfDrugApiController{}, "Get:ModifyDrugPrice")
- beego.Router("/api/drug/getmodifypriceprint", &SelfDrugApiController{}, "Get:GetModifyPricePrint")
- beego.Router("/api/drug/getdrugdamagedetail", &SelfDrugApiController{}, "Get:GetDrugDamageDetail")
- beego.Router("/api/drug/modifydrugdamage", &SelfDrugApiController{}, "Get:ModifyDrugDamage")
- beego.Router("/api/drug/deletedrugdamage", &SelfDrugApiController{}, "Get:DeleteDrugDamage")
- beego.Router("/api/drug/getdrugdamageprint", &SelfDrugApiController{}, "Get:GetDrugDamagePrint")
- beego.Router("/api/drug/warehouseinfobyid", &SelfDrugApiController{}, "Get:GetWarehoseInfoById")
- beego.Router("/api/drug/savedruginventory", &SelfDrugApiController{}, "Post:SaveDrugInventory")
- beego.Router("/api/drug/getdruginventorylist", &SelfDrugApiController{}, "Get:GetDrugInventoryList")
- beego.Router("/api/drug/savedrugcheckinventory", &SelfDrugApiController{}, "Get:SaveDrugCheckInventory")
- beego.Router("/api/drug/getdruginventorydetail", &SelfDrugApiController{}, "Get:GetDrugInventoryDetail")
- beego.Router("/api/drug/modifyinventory", &SelfDrugApiController{}, "Get:ModifyInventory")
- beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Get:DeleteDrugInventory")
- beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
- beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
- beego.Router("/api/drug/getinventorydetailprintlist", &SelfDrugApiController{}, "Get:GetInventoryDetailPrintList")
- beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
- beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
-
- beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
-
- beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
-
- beego.Router("/api/drug/getinventorymodelist", &SelfDrugApiController{}, "Get:GetInventoryModeList")
-
- //耗材库存优化接口
- beego.Router("/api/drug/getstorehouselist", &SelfDrugApiController{}, "Get:GetStorehouseList")
- beego.Router("/api/drug/getgoodnewquery", &SelfDrugApiController{}, "Get:GetGoodNewQuery")
- beego.Router("/api/drug/getgoodwarehouseoutinfobyid", &SelfDrugApiController{}, "Get:GetGoodWarehouseOutInfoByIdList")
- beego.Router("/api/good/getgoodpatientlist", &SelfDrugApiController{}, "Get:GetGoodPatientList")
- beego.Router("/api/good/getwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetWarehouseOutDetailByPatientId")
- beego.Router("/api/good/getgoodexpirydatequery", &SelfDrugApiController{}, "Get:GetGoodExpiryDateQuery")
- beego.Router("/api/good/getpurchasestockquery", &SelfDrugApiController{}, "Get:GetGoodPurchaseStockQuery")
-
- //药品库存优化接口
- beego.Router("/api/good/getdrugwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetDrugWarehouseOutDetailByPatientId")
- beego.Router("/api/drug/getdrugexpirydatequery", &SelfDrugApiController{}, "Get:GetDrugExpiryDateQuery")
- beego.Router("/api/drug/getpurchasedrugquery", &SelfDrugApiController{}, "Get:GetPurchaseDrugQuery")
- beego.Router("/api/drug/getdrugnewquery", &SelfDrugApiController{}, "Get:GetDrugNewQuery")
- beego.Router("/api/drug/getdrugwarehouseoutinfobyid", &SelfDrugApiController{}, "Get:GetDrugWarehouseInfoById")
-
- //耗材脚本
- beego.Router("/api/stock/tosendgoodinfomation", &SelfDrugApiController{}, "Get:GetSendGoodInformation")
- //药品脚本
- beego.Router("/api/drug/getdruginitdatalist", &SelfDrugApiController{}, "Get:GetDrugInitDetailList")
-
- //新数据
- beego.Router("/api/stock/getnewpurchasestockquery", &SelfDrugApiController{}, "Get:GetGoodNewPurchaseStockQuery")
- beego.Router("/api/stock/getpurchasenewdrugquery", &SelfDrugApiController{}, "Get:GetPurchaseNewDrugQuery")
- beego.Router("/api/stock/getgoodovercount", &SelfDrugApiController{}, "Get:GetGoodOverCount")
- beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
-
- beego.Router("/api/stock/getdruginfolist", &SelfDrugApiController{}, "Get:GetDrugInventoryWarehouseInfoList")
-
- beego.Router("/api/drug/getdrugflowdetailbyid", &SelfDrugApiController{}, "Get:GetDrugFlowDetailById")
-
- //康允新版本
- beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
-
- beego.Router("/api/stock/getpurchasestockquerylist", &SelfDrugApiController{}, "Get:GetPurchaseStockQueryList")
-
- beego.Router("/api/drug/getcheckdrugbatchlist", &SelfDrugApiController{}, "Get:GetCheckDrugBatchList")
-
- beego.Router("/api/good/getcheckgoodbatchlist", &SelfDrugApiController{}, "Get:GetCheckGoodBatchList")
-
- beego.Router("/api/drug/getdrugpatientname", &SelfDrugApiController{}, "Get:GetDrugPatientName")
-
- //自备药的接口
- beego.Router("/api/drug/getallselfdruginfolist", &SelfDrugApiController{}, "Get:GetAllSelfDrugInfoList")
-
- beego.Router("/api/drug/getallpatientlist", &SelfDrugApiController{}, "Get:GetAllPatientList")
-
- beego.Router("/api/drug/postsearchselfdruglist", &SelfDrugApiController{}, "Get:PostSearchSelfDrugList")
-
- beego.Router("/api/drug/postselfdrugwarehouse", &SelfDrugApiController{}, "Post:PostSelfDrugWarehouse")
-
- beego.Router("/api/drug/getallselfdrugwarehosueinfolist", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouseInfoList")
-
- beego.Router("/api/drug/getselfdrugwarehouseinfobyid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseInfoByID")
-
- beego.Router("/api/drug/modifyselfdrugwarehouse", &SelfDrugApiController{}, "Post:ModifySelfDrugWarehouse")
-
- beego.Router("/api/drug/deleteselfwarehouseinfo", &SelfDrugApiController{}, "Get:DeleteSelfDrugWarehouse")
-
- beego.Router("/api/drug/tocheckselfwarehouseinginfo", &SelfDrugApiController{}, "Get:TocheckSelfWarehouseingInfo")
-
- beego.Router("/api/drug/returnselfcheckwarehouse", &SelfDrugApiController{}, "Get:ReturnSelfCheckWarehouse")
-
- beego.Router("/api/drug/getselfdrugbatchnumber", &SelfDrugApiController{}, "Get:GetSelfDrugBatchNumber")
-
- beego.Router("/api/drug/postsetfdrugwarehouseout", &SelfDrugApiController{}, "Post:PostSelfDrugWarehouseOut")
-
- beego.Router("/api/drug/getallselfdrugwarehouseoutlist", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouseOutList")
-
- beego.Router("/api/drug/deleteselfwarehouseout", &SelfDrugApiController{}, "Get:DeleteSelfWarehouseOut")
-
- beego.Router("/api/drug/getselfdrugwarehouseoutbyid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseOutById")
-
- beego.Router("/api/drug/modifyselfdrugwarehouseout", &SelfDrugApiController{}, "Post:ModifySelfDrugWarehouseOut")
-
- beego.Router("/api/drug/getselfdrugquery", &SelfDrugApiController{}, "Get:GetSelfDrugQuery")
-
- beego.Router("/api/drug/checkselfdrugoutquery", &SelfDrugApiController{}, "Get:CheckSelfDrugOutQuery")
-
- beego.Router("/api/drug/returncheckselfoutdrugquery", &SelfDrugApiController{}, "Get:ReturnCheckSelfOutDrugQuery")
-
- beego.Router("/api/drug/getselfdrugflow", &SelfDrugApiController{}, "Get:GetSelfDrugFlow")
-
- beego.Router("/api/drug/getselfdrugbatchnumberlist", &SelfDrugApiController{}, "Get:GetSelfDrugBatchNumberList")
-
- beego.Router("/api/drug/getallselfdrugwarehouse", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouse")
-
- beego.Router("/api/drug/deleteselfwarehouse", &SelfDrugApiController{}, "Get:DeleteSelfWarehouse")
-
- beego.Router("/api/drug/getallselfdrugwarehouseout", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouseOut")
-
- beego.Router("/api/drug/deleteselfwarehouseoutlist", &SelfDrugApiController{}, "Get:DeleteSelfWarehouseOutList")
-
- beego.Router("/api/drug/getselfDrugwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseOutDetailByPatientId")
-
- beego.Router("/api/drug/getdruginventoryrecordlist", &SelfDrugApiController{}, "Get:GetDrugInventoryRecordList")
-
- beego.Router("/api/drug/getdruginventoryrecordprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryRecordPrintList")
-
- beego.Router("/api/drug/getdruginventorymodeprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryModePrintList")
-
- }
-
- func (this *SelfDrugApiController) GetCurrentPatient() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- patient, err := service.GetCurrentPatient(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *SelfDrugApiController) GetAllDrugName() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- //查询药品库是否开启
- //configStock, _ := service.GetDrugStockConfig(orgId)
- //if configStock.IsOpen == 1 {
- //
- //}
-
- drugName, err := service.GetAllDrugName(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查寻成功")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugName": drugName,
- })
-
- }
-
- func (this *SelfDrugApiController) SaveDrugName() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- drug_name := this.GetString("drug_name")
- id, _ := this.GetInt64("id")
- //fmt.Println("drug_name", drug_name)
- drugName := models.XtDrugName{
- UserOrgId: orgId,
- DrugName: drug_name,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- DrugId: id,
- }
- _, errcode := service.GetDrugName(drug_name, orgId)
- if errcode == gorm.ErrRecordNotFound {
- err := service.SaveDrugName(&drugName)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugName": drugName,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- }
-
- func (this *SelfDrugApiController) GetDrugNameList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, err := service.GetDrugNameList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetRulleName() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- drugId, _ := service.GetDrugId(id)
- rullerList, err := service.GetRulleList(orgId, drugId.DrugId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rullerList": rullerList,
- })
- }
-
- func (this *SelfDrugApiController) GetUnitByBaseId() {
-
- id, _ := this.GetInt64("id")
- baseList, err := service.GetUnitByBaseId(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "baseList": baseList,
- })
- }
-
- func (this *SelfDrugApiController) SaveRulleName() {
- drug_name := this.GetString("drug_name")
- drug_spec := this.GetString("drug_spec")
- drug_stock_limit := this.GetString("drug_stock_limit")
- drug_name_id, _ := this.GetInt64("drug_name_id")
- drug_id, _ := this.GetInt64("drug_id")
- price, _ := this.GetInt64("price")
- prices := strconv.FormatInt(price, 10)
- durg_price, _ := strconv.ParseFloat(prices, 64)
- unit := this.GetString("unit")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- fmt.Println(drug_name, drug_stock_limit, unit, price, drug_spec, orgId)
- drugSpecName := models.XtStandName{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- DrugStockLimit: drug_stock_limit,
- DrugNameId: drug_name_id,
- Price: durg_price,
- MinUnit: unit,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- DrugId: drug_id,
- }
-
- //查询该机构下药品规格名称是否存在
- _, errcode := service.IsExistStandName(drug_name, drug_spec, adminUserInfo.CurrentOrgId)
-
- if errcode == gorm.ErrRecordNotFound {
- err := service.SaveRulleName(&drugSpecName)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "创建规格失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "RullerName": drugSpecName,
- })
- } else if errcode == nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "规格已存在")
- return
- }
-
- }
-
- func (this *SelfDrugApiController) EditRullerName() {
-
- id, _ := this.GetInt64("id")
- rullerDetail, err := service.GetRullerNameDetail(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rullerDetail": rullerDetail,
- })
- }
-
- func (this *SelfDrugApiController) UpdatedRullerName() {
-
- id, _ := this.GetInt64("id")
- drug_name := this.GetString("drug_name")
- drug_stock_limit := this.GetString("drug_stock_limit")
- price, _ := this.GetInt64("price")
- prices := strconv.FormatInt(price, 10)
- durg_price, _ := strconv.ParseFloat(prices, 64)
-
- drug_spec := this.GetString("drug_spec")
- unit := this.GetString("unit")
- drug_name_id, _ := this.GetInt64("drug_name_id")
- drug_id, _ := this.GetInt64("drug_id")
-
- RullerName := models.XtStandName{
- DrugName: drug_name,
- DrugStockLimit: drug_stock_limit,
- Price: durg_price,
- DrugSpec: drug_spec,
- MinUnit: unit,
- DrugNameId: drug_name_id,
- DrugId: drug_id,
- }
- _, errcode := service.GetIsExit(drug_name, drug_spec, id)
- if errcode == gorm.ErrRecordNotFound {
- err := service.UpdatedRullerName(id, &RullerName)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "RullerName": RullerName,
- })
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- }
-
- func (this *SelfDrugApiController) GetAllDrugNameList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- rullerName, err := service.GetAllDrugNameList(orgId)
-
- list, err := service.GetMedicalDrugNameList(orgId)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rullerName": rullerName,
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetRullerListByDrugName() {
-
- id := this.GetString("id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- fmt.Println("orgid", orgId)
- drugName, err := service.GetRullerListByDrugName(id, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugName": drugName,
- })
- }
-
- func (this *SelfDrugApiController) SaveSelfMedicines() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- patient_id := int64(dataBody["patient_id"].(float64))
- medicineData, _ := dataBody["medicineData"].([]interface{})
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- for _, item := range medicineData {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- drug_name_id := int64(items["drug_name_id"].(float64))
- drug_spec := items["drug_spec"].(string)
- min_unit := items["min_unit"].(string)
- drug_id := int64(items["drug_id"].(float64))
- //根据drug_id
- drugMedical, _ := service.GetBaseDrugMedical(drug_name_id)
- medical := models.XtSelfMedical{
- DrugName: drug_name,
- DrugNameId: drug_name_id,
- DrugSpec: drug_spec,
- CreatedTime: time.Now().Unix(),
- Status: 1,
- UserOrgId: orgId,
- PatientId: patient_id,
- MinUnit: min_unit,
- ExecutionFrequency: drugMedical.ExecutionFrequency,
- PrescribingNumber: drugMedical.PrescribingNumber,
- DeliveryWay: drugMedical.DeliveryWay,
- SingleDose: drugMedical.SingleDose,
- DrugId: drug_id,
- }
- //查询同个病人同个药品同个规格是否已存在
- _, errcode := service.GetSelfMedicalByDrugName(drug_name, drug_spec, patient_id)
-
- if errcode == gorm.ErrRecordNotFound {
- err := service.CreateSelfMedical(&medical)
- fmt.Println(err)
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) GetCurrentOrgAllStaff() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgid := adminUserInfo.CurrentOrgId
- //fmt.Println(orgid)
- appId := adminUserInfo.CurrentAppId
- staff, err := service.GetCurrentOrgAllStaff(orgid, appId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "staff": staff,
- })
- }
-
- func (this *SelfDrugApiController) SaveStock() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- fmt.Println("start_time", start_time)
- admin_user_id, _ := this.GetInt64("admin_user_id")
- fmt.Println("admin_user_id", admin_user_id)
- patient_id, _ := this.GetInt64("patient_id")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- stocks, _ := dataBody["stocks"].([]interface{})
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- for _, item := range stocks {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- fmt.Println("drug_name", drug_name)
- drug_name_id := int64(items["drug_name_id"].(float64))
- fmt.Println("parient_id", drug_name_id)
- drug_spec := items["drug_spec"].(string)
- store_number := items["store_number"].(string)
- fmt.Println("store_number", store_number)
- storeNumber, _ := strconv.ParseInt(store_number, 10, 64)
- remarks := items["remarks"].(string)
- min_unit := items["min_unit"].(string)
- medic_id := int64(items["id"].(float64))
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
-
- total = total + 1
- warehousing_in_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_in_order, 10, 64)
- number = number + total
- warehousing_in_order = "RKD" + strconv.FormatInt(number, 10)
-
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- stock := models.XtSelfStock{
- DrugName: drug_name,
- DrugNameId: drug_name_id,
- DrugSpec: drug_spec,
- StoreNumber: storeNumber,
- Remarks: remarks,
- AdminUserId: admin_user_id,
- StorckTime: theTime.Unix(),
- CreatedTime: time.Now().Unix(),
- Status: 1,
- UserOrgId: orgId,
- StockInNumber: warehousing_in_order,
- PatientId: patient_id,
- MinUnit: min_unit,
- StorageMode: 1,
- MedicId: medic_id,
- }
- err := service.CreateStock(&stock)
- fmt.Println("err", err)
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) SaveOutStock() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- admin_user_id, _ := this.GetInt64("admin_user_id")
- patient_id, _ := this.GetInt64("patient_id")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- outStocks, _ := dataBody["outStocks"].([]interface{})
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- for _, item := range outStocks {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- drug_name_id := int64(items["drug_name_id"].(float64))
- drug_spec := items["drug_spec"].(string)
- outstore_number := items["outstore_number"].(string)
- outStoreNumber, _ := strconv.ParseInt(outstore_number, 10, 64)
- remarks := items["remarks"].(string)
- medic_id := int64(items["id"].(float64))
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
- fmt.Println(remarks)
- fmt.Println(items)
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- stock := models.XtSelfOutStock{
- DrugName: drug_name,
- DrugNameId: drug_name_id,
- DrugSpec: drug_spec,
- OutstoreNumber: outStoreNumber,
- Remarks: remarks,
- AdminUserId: admin_user_id,
- StorckTime: theTime.Unix(),
- CreatedTime: time.Now().Unix(),
- Status: 1,
- UserOrgId: orgId,
- StockOutNumber: warehousing_out_order,
- PatientId: patient_id,
- ExitMode: 1,
- MedicId: medic_id,
- }
- err := service.CreateOutStock(&stock)
- fmt.Println("err", err)
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) DeleteDrugById() {
- id, _ := this.GetInt64("id")
- drug_name := this.GetString("drug_name")
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
-
- if errcode == gorm.ErrRecordNotFound {
- service.DeleteDrugName(id)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- }
-
- func (this *SelfDrugApiController) SaveRadio() {
-
- radio, _ := this.GetInt64("radio")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- drugSet := models.XtDrugSet{
- DrugStart: radio,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- }
- _, errcode := service.GetDrugSetByUserOrgId(orgId)
- if errcode == gorm.ErrRecordNotFound {
- err := service.SaveRadio(&drugSet)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugSet": drugSet,
- })
- } else if errcode == nil {
- err := service.UpdateDrugSet(&drugSet, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugSet": drugSet,
- })
- }
-
- }
-
- func (this *SelfDrugApiController) DeleteDrugStand() {
-
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- _, errcode := service.GetMedicalsByName(orgId, name)
- if errcode == gorm.ErrRecordNotFound {
- err := service.DeleteDrugStand(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- } else if errcode == nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- }
-
- func (this *SelfDrugApiController) GetStockList() {
-
- patientid, _ := this.GetInt64("id")
- start_time := this.GetString("start_time")
- fmt.Println("开始时间", start_time)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- startimeUnix := theTime.Unix()
- keyword := this.GetString("keyword")
- fmt.Println("keyword", keyword)
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- //获取
- medicalList, _ := service.GetMedicalList(patientid, orgId, keyword)
- //统计总数量
- stocklist, err := service.GetStockList(patientid, startimeUnix, keyword, orgId)
- //统计出库数量
- outStocklist, err := service.GetOutStockList(patientid, startimeUnix, keyword, orgId)
-
- //统计该病人时间段内出库条数
- outList, err := service.GetTotalOutStockList(patientid, startimeUnix, keyword, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "medicalList": medicalList,
- "stocklist": stocklist,
- "outStocklist": outStocklist,
- "outList": outList,
- })
- }
-
- func (this *SelfDrugApiController) DeleteDrugName() {
-
- drug_name := this.GetString("drugname")
- patient_id, _ := this.GetInt64("patientid")
-
- //查询该药品是否出库
- stocklist, _ := service.GetStockOutDetail(drug_name, patient_id)
- if len(stocklist) == 0 {
- //删除该药品
- service.DeleteDrugStockNumber(drug_name, patient_id)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- }
-
- func (this *SelfDrugApiController) GetDrugDetail() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- drug_name := this.GetString("drug_name")
- drug_spec := this.GetString("drug_spec")
- start_time := this.GetString("start_time")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- end_time := this.GetString("end_time")
- endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- patient_id, _ := this.GetInt64("patient_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- //查询入库明细
- stockDetail, err := service.GetStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
-
- //查询出库明细
- outStockDetail, err := service.GetOutStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "stockDetail": stockDetail,
- "outStockDetail": outStockDetail,
- })
- }
-
- func (this *SelfDrugApiController) GetAllPatientStockList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- drug_name := this.GetString("drug_name")
- drug_spec := this.GetString("drug_spec")
- start_time := this.GetString("start_time")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- startUnix := theTime.Unix()
- end_time := this.GetString("end_time")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- endTimeUnix := endTimes.Unix()
- keywords := this.GetString("search_input")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- //入库
- stocklist, err := service.GetAllPatientStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
-
- //出库
- outStockList, err := service.GetAllPatientOutStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "stocklist": stocklist,
- "outStockList": outStockList,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugDataByPatientId() {
-
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println("patient_id", patient_id)
- medicalList, err := service.GetDrugDataByPatientId(patient_id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "medicalList": medicalList,
- })
- }
-
- func (this *SelfDrugApiController) GetSelfMedicalList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
- privateDrugConfig, _ := service.GetDrugSetByUserOrgId(orgId)
- drugList, _ := service.GetAllBaseDrugLibList(orgId)
- privateDrugList, _ := service.GetPrivateDrugList(patient_id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "base_drug_config": drugStockConfig,
- "private_drug_config": privateDrugConfig,
- "base_drug_list": drugList,
- "private_drug_list": privateDrugList,
- })
- ////查询是否开启药品库
- //config, _ := service.GetDruckStockConfig(orgId)
- //
- //fmt.Println("--------------------------",config.IsOpen)
- ////开启
- //if config.IsOpen == 1 {
- // //查询该机构下的药品库
- // drugName, _ := service.GetAllDrugName(orgId)
- //
- // //查询该机构是否开启自备药
- // medical, _ := service.GetSetSelfMedical(orgId)
- // fmt.Println("medical+++++++++++++++++",medical.DrugStart)
- // //开启
- // if medical.DrugStart == 1 {
- // list, err := service.GetSelfMedicalList(patient_id)
- // if err != nil {
- // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- // return
- // }
- // this.ServeSuccessJSON(map[string]interface{}{
- // "medicalList": list,
- // "drugName": drugName,
- // })
- // } else {
- // this.ServeSuccessJSON(map[string]interface{}{
- // "drugName": drugName,
- // })
- // }
- //}
- }
-
- func (this *SelfDrugApiController) GetDrugDescByDrugName() {
-
- drug_name := this.GetString("drug_name")
- patient_id, _ := this.GetInt64("patient_id")
- way, _ := this.GetInt64("way")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- drug_id, _ := this.GetInt64("id")
- //从基础库查询
- if way == 1 {
- //查询基础库数据
- medcal, err := service.GetBaseMedcal(drug_name, orgId)
- //统计入库数量
- countInfo, err := service.GetTotalBaseMedicalCount(drug_id, orgId)
-
- //统计出库数量
- countout, err := service.GetTotalBaseMedicalCountOut(drug_id, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugspec": medcal,
- "countInfo": countInfo,
- "countout": countout,
- })
- }
- //从自备药库查询
- if way == 2 {
- drugspec, err := service.GetDrugDescByDrugName(drug_name, patient_id, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugspec": drugspec,
- })
- }
-
- }
-
- func (this *SelfDrugApiController) GetDrugSet() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- drugSet, err := service.GetDrugSet(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugSet": drugSet,
- })
-
- }
-
- func (this *SelfDrugApiController) GetAllMedicalList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, err := service.GetAllMedicalList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drugName": list,
- })
- }
-
- func (this *SelfDrugApiController) GetStandName() {
-
- name := this.GetString("name")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- rullerlist, err := service.GetRulleName(orgId, name)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rullerlist": rullerlist,
- })
- }
-
- func (this *SelfDrugApiController) GetRullerList() {
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- rullerList, err := service.GetRulleList(orgId, id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rullerlist": rullerList,
- })
- }
-
- func (this *SelfDrugApiController) DeleteDrugNameById() {
-
- id, _ := this.GetInt64("id")
- drug_name := this.GetString("drug_name")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
-
- if errcode == gorm.ErrRecordNotFound {
- service.DeleteDrugNameById(id)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- }
-
- func (this *SelfDrugApiController) GetPatientDetail() {
-
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- patientDetail, err := service.GetPatientDetail(id, adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientDetail": patientDetail,
- })
- }
-
- //func (this *SelfDrugApiController) ToPatientDetail() {
- //
- // keyword := this.GetString("keyword")
- // adminUser := this.GetAdminUserInfo()
- // orgId := adminUser.CurrentOrgId
- // patient, err := service.ToSeachPatient(keyword, orgId)
- // if err != nil {
- // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- // return
- // }
- // this.ServeSuccessJSON(map[string]interface{}{
- // "patient": patient,
- // })
- //}
-
- func (this *SelfDrugApiController) GetSelfStockQuery() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- type_name, _ := this.GetInt64("type_name")
- keywords := this.GetString("keywords")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- startUnix := theTime.Unix()
- end_time := this.GetString("end_time")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- endTimeUnix := endTimes.Unix()
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- //统计入库数量
- stockQuery, total, err := service.GetSelfStockQuery(type_name, keywords, startUnix, endTimeUnix, orgId, limit, page)
- //统计出库数量
- stockOutQuery, err := service.GetSelfOutStockQuery(startUnix, endTimeUnix, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "stockQuery": stockQuery,
- "total": total,
- "stockOutQuery": stockOutQuery,
- })
- }
-
- func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
-
- keyword := this.GetString("keyword")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, err := service.PostSearchDrugWarehouseList(keyword, orgId, storehouse_id)
- manufacturerList, err := service.GetAllManufacturerList(orgId)
- dealerList, err := service.GetAllDealerList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugPrice() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
-
- tableData, _ := dataBody["tableData"].([]interface{})
- fmt.Println("999939433443", tableData)
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
-
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_name := items["drug_name"].(string)
- fmt.Println("drug_aname23232323232", drug_name)
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
- utils.ErrorLog("retail_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
-
- if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
- utils.ErrorLog("warehousing_order")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_order := items["warehousing_order"].(string)
-
- if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- number := items["number"].(string)
-
- if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
- utils.ErrorLog("dealer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dealer := items["dealer"].(string)
-
- if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
- utils.ErrorLog("manufacturer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- manufacturer := items["manufacturer"].(string)
-
- if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- specification_name := items["specification_name"].(string)
-
- if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
- utils.ErrorLog("remark")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- remark := items["remark"].(string)
-
- if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
- utils.ErrorLog("warehousing_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_unit := items["warehousing_unit"].(string)
-
- if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
- utils.ErrorLog("last_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
-
- if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
- utils.ErrorLog("new_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var startTime int64
- start_time := items["start_time"].(string)
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- orgId := this.GetAdminUserInfo().CurrentOrgId
- Creater := this.GetAdminUserInfo().AdminUser.Id
-
- drugAdjust := models.XtDrugAdjustPrice{
- DrugName: drug_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- LastPrice: last_price,
- RetailPrice: retail_price,
- NewPrice: new_price,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- DrugId: drug_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- Number: number,
- StartTime: startTime,
- Creater: Creater,
- Checker: 0,
- CheckerStatus: 2,
- CheckerTime: 0,
- }
-
- err := service.CreateDrugPrice(drugAdjust)
- fmt.Println(err)
- }
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) GetDrugPriceList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- orgId := this.GetAdminUserInfo().CurrentOrgId
- keyword := this.GetString("keyword")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- list, total, err := service.GetDrugPriceList(startTime, endTime, orgId, keyword, limit, page)
- doctorList, err := service.GetAllDoctorThree(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "doctorList": doctorList,
- })
- }
-
- func (this *SelfDrugApiController) SaveCheckDrugPrice() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- idstr := this.GetString("ids")
- ids := strings.Split(idstr, ",")
- check_time := this.GetString("check_time")
- var checkTime int64
- if len(check_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- checkTime = theTime.Unix()
- }
- checker, _ := this.GetInt64("checker")
- adjustPrice := models.XtDrugAdjustPrice{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
- fmt.Println("err", err)
- list, _ := service.GetDrugAdjuestPrice(ids)
- for _, item := range list {
- drug := models.BaseDrugLib{
- RetailPrice: item.NewPrice,
- LastPrice: item.NewPrice,
- }
- service.UpdateBaseDrugOne(drug, item.DrugId)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "adjustPrice": adjustPrice,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugDamage() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
-
- tableData, _ := dataBody["tableData"].([]interface{})
- fmt.Println("999939433443", tableData)
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
- utils.ErrorLog("retail_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
-
- if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
- utils.ErrorLog("warehousing_order")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_order := items["warehousing_order"].(string)
-
- if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- number := items["number"].(string)
-
- if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
- utils.ErrorLog("dealer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dealer := items["dealer"].(string)
-
- if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
- utils.ErrorLog("manufacturer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- manufacturer := items["manufacturer"].(string)
-
- if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- specification_name := items["specification_name"].(string)
-
- if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
- utils.ErrorLog("remark")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- remark := items["remark"].(string)
-
- if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
- utils.ErrorLog("warehousing_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_unit := items["warehousing_unit"].(string)
-
- if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
- utils.ErrorLog("last_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
-
- if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
- utils.ErrorLog("count")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- count := int64(items["count"].(float64))
-
- if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
- utils.ErrorLog("new_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var startTime int64
- start_time := items["start_time"].(string)
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- if items["warehousing_info_id"] == nil || reflect.TypeOf(items["warehousing_info_id"]).String() != "float64" {
- utils.ErrorLog("warehousing_info_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_info_id := int64(items["warehousing_info_id"].(float64))
-
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
- utils.ErrorLog("expiry_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiry_date := int64(items["expiry_date"].(float64))
-
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
- utils.ErrorLog("product_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- product_date := int64(items["product_date"].(float64))
-
- if items["drug_origin_place"] == nil || reflect.TypeOf(items["drug_origin_place"]).String() != "string" {
- utils.ErrorLog("drug_origin_place")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_origin_place := items["drug_origin_place"].(string)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- Creater := this.GetAdminUserInfo().AdminUser.Id
-
- if items["stock_max_number"] == nil || reflect.TypeOf(items["stock_max_number"]).String() != "float64" {
- utils.ErrorLog("stock_max_number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- stock_max_number := int64(items["stock_max_number"].(float64))
-
- if items["stock_min_number"] == nil || reflect.TypeOf(items["stock_min_number"]).String() != "float64" {
- utils.ErrorLog("stock_min_number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- stock_min_number := int64(items["stock_min_number"].(float64))
-
- if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
- utils.ErrorLog("total")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- total := items["total"].(string)
- drugDamage := models.XtDrugDamage{
- DrugName: drug_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- LastPrice: last_price,
- RetailPrice: retail_price,
- NewPrice: new_price,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- DrugId: drug_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- Number: number,
- StartTime: startTime,
- Creater: Creater,
- Checker: 0,
- CheckerStatus: 2,
- CheckerTime: 0,
- ExpiryDate: expiry_date,
- ProductDate: product_date,
- WarehousingInfoId: warehousing_info_id,
- DrugOriginPlace: drug_origin_place,
- StockMaxNumber: stock_max_number,
- StockMinNumber: stock_min_number,
- Total: total,
- }
-
- err := service.CreateDrugDamage(drugDamage)
- fmt.Println(err)
- }
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- }
-
- func (this *SelfDrugApiController) GetDrugDamageList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- orgId := this.GetAdminUserInfo().CurrentOrgId
- keyword := this.GetString("keyword")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
-
- list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page, storehouse_id)
-
- damagelist, _ := service.GetDrugDamageByOrgId(orgId)
- doctorList, err := service.GetAllDoctorThree(orgId)
-
- houseList, _ := service.GetAllStoreHouseList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "damagelist": damagelist,
- "doctorList": doctorList,
- "houseList": houseList,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugDamagePrice() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- idstr := this.GetString("ids")
- ids := strings.Split(idstr, ",")
- check_time := this.GetString("check_time")
- var checkTime int64
- if len(check_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- checkTime = theTime.Unix()
- }
- checker, _ := this.GetInt64("checker")
- damage := models.XtDrugDamage{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- err = service.UpdateDrugDamage(ids, damage)
- fmt.Println(err)
- list, _ := service.GetDrugDamage(ids)
- ctime := time.Now().Unix()
- adminUserInfo := this.GetAdminUserInfo()
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
- var manufacturer_id int64
- var dealer_id int64
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- warehouseOut := models.DrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehouseOutTime: time.Now().Unix(),
- Type: 1,
- }
- service.AddSigleDrugWarehouseOut(&warehouseOut)
- for _, item := range list {
- for _, it := range manufacturerList {
- if item.Manufacturer == it.ManufacturerName {
- manufacturer_id = it.ID
- }
- }
-
- for _, its := range dealerList {
- if its.DealerName == item.Dealer {
- dealer_id = its.ID
- }
- }
-
- warehouseOutInfo := models.XtDrugWarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- DrugId: item.DrugId,
- Count: item.Count,
- Price: item.RetailPrice,
- Status: 1,
- Ctime: ctime,
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 1,
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- RetailPrice: item.RetailPrice,
- CountUnit: item.WarehousingUnit,
- ExpiryDate: item.ExpiryDate,
- ProductDate: item.ProductDate,
- Number: item.Number,
- BatchNumber: item.BatchNumber,
- IsSys: 0,
- WarehouseInfoId: item.WarehousingInfoId,
- }
-
- drugflow := models.DrugFlow{
- WarehouseOutId: warehouseOut.ID,
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- DrugId: item.DrugId,
- Number: item.Number,
- ProductDate: item.ProductDate,
- ExpireDate: item.ExpiryDate,
- Count: item.Count,
- Price: item.RetailPrice,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- BatchNumber: item.BatchNumber,
- MaxUnit: item.WarehousingUnit,
- ConsumableType: 5,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- IsSys: 0,
- }
- service.CreateWareHouseOutInfo(&warehouseOutInfo)
- service.CreateDrugFlowOne(drugflow)
-
- info, _ := service.GetDrugByWarehouseInfo(item.WarehousingInfoId)
- //扣减库存
- warehouseInfo := models.XtDrugWarehouseInfo{
- StockMaxNumber: info.StockMaxNumber - info.StockMaxNumber,
- }
- service.UpdateDrugWarehouseingInfo(item.WarehousingInfoId, warehouseInfo)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "damage": damage,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugModifyPrice() {
-
- id, _ := this.GetInt64("id")
- detail, err := service.GetDrugModifyPrice(id)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *SelfDrugApiController) ModifyDrugPrice() {
-
- drug_name := this.GetString("drug_name")
- specification_name := this.GetString("specification_name")
- warehousing_unit := this.GetString("warehousing_unit")
- manufacturer := this.GetString("manufacturer")
- number := this.GetString("number")
- retailPrice := this.GetString("retail_price")
- retail_price, _ := strconv.ParseFloat(retailPrice, 64)
- newPrice := this.GetString("new_price")
- new_price, _ := strconv.ParseFloat(newPrice, 64)
- count, _ := this.GetInt64("count")
- remark := this.GetString("remark")
- id, _ := this.GetInt64("id")
- drug_id, _ := this.GetInt64("drug_id")
- adjustPrice := models.XtDrugAdjustPrice{
- DrugName: drug_name,
- Count: count,
- RetailPrice: retail_price,
- NewPrice: new_price,
- Remark: remark,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Manufacturer: manufacturer,
- Number: number,
- DrugId: drug_id,
- }
- err := service.ModifyDrugPrice(id, adjustPrice)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "adjustPrice": adjustPrice,
- })
- }
-
- func (this *SelfDrugApiController) GetModifyPricePrint() {
-
- ids := this.GetString("ids")
- idsSplit := strings.Split(ids, ",")
- list, err := service.GetModifyPricePrint(idsSplit)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugDamageDetail() {
-
- id, _ := this.GetInt64("id")
- detail, _ := service.GetDrugDamageDetail(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *SelfDrugApiController) ModifyDrugDamage() {
-
- id, _ := this.GetInt64("id")
- drug_id, _ := this.GetInt64("drug_id")
- drug_name := this.GetString("drug_name")
- drug_origin_place := this.GetString("drug_origin_place")
- lastPrice := this.GetString("last_price")
- last_price, _ := strconv.ParseFloat(lastPrice, 64)
- newPrice := this.GetString("new_price")
- new_price, _ := strconv.ParseFloat(newPrice, 64)
- manufacturer := this.GetString("manufacturer")
- number := this.GetString("number")
- retailPrice := this.GetString("retail_price")
- retail_price, _ := strconv.ParseFloat(retailPrice, 64)
- remark := this.GetString("remark")
- count, _ := this.GetInt64("count")
- warehousing_unit := this.GetString("warehousing_unit")
- stock_max_number, _ := this.GetInt64("stock_max_number")
- stock_min_number, _ := this.GetInt64("stock_min_number")
- warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
- damage := models.XtDrugDamage{
- DrugName: drug_name,
- SpecificationName: "",
- WarehousingUnit: warehousing_unit,
- Count: count,
- LastPrice: last_price,
- RetailPrice: retail_price,
- NewPrice: new_price,
- Manufacturer: manufacturer,
- Dealer: "",
- Remark: remark,
- DrugId: drug_id,
- Number: number,
- StockMaxNumber: stock_max_number,
- StockMinNumber: stock_min_number,
- WarehousingInfoId: warehousing_info_id,
- DrugOriginPlace: drug_origin_place,
- }
- err := service.ModifyDrugDamage(id, damage)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "damage": damage,
- })
- }
-
- func (this *SelfDrugApiController) DeleteDrugDamage() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteDrugDamage(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- }
-
- func (this *SelfDrugApiController) GetDrugDamagePrint() {
-
- idsSplit := this.GetString("ids")
- ids := strings.Split(idsSplit, ",")
- list, _ := service.GetDrugDamagePrint(ids)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetWarehoseInfoById() {
-
- id, _ := this.GetInt64("id")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetWarehoseInfoById(id, storehouse_id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugInventory() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
-
- tableData, _ := dataBody["tableData"].([]interface{})
-
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
-
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
- utils.ErrorLog("retail_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
-
- if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
- utils.ErrorLog("warehousing_order")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_order := items["warehousing_order"].(string)
-
- if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
- utils.ErrorLog("dealer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dealer := items["dealer"].(string)
-
- if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
- utils.ErrorLog("manufacturer")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- manufacturer := items["manufacturer"].(string)
-
- if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- specification_name := items["specification_name"].(string)
-
- if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
- utils.ErrorLog("remark")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- remark := items["remark"].(string)
-
- if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
- utils.ErrorLog("warehousing_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehousing_unit := items["warehousing_unit"].(string)
-
- if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
- utils.ErrorLog("last_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
-
- if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
- utils.ErrorLog("count")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- count := int64(items["count"].(float64))
-
- if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
- utils.ErrorLog("new_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var startTime int64
- start_time := items["start_time"].(string)
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
- utils.ErrorLog("product_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- product_date := int64(items["product_date"].(float64))
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
- utils.ErrorLog("expiry_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiry_date := int64(items["expiry_date"].(float64))
- orgId := this.GetAdminUserInfo().CurrentOrgId
- Creater := this.GetAdminUserInfo().AdminUser.Id
-
- if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- numbers := items["number"].(string)
-
- if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
- utils.ErrorLog("warehouse_info_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- warehouse_info_id := int64(items["warehouse_info_id"].(float64))
-
- if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
- utils.ErrorLog("total")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- total := items["total"].(string)
-
- drug_origin_place := items["drug_origin_place"].(string)
-
- min_count := int64(items["min_count"].(float64))
- min_unit := items["min_unit"].(string)
- inventory := models.XtDrugInventory{
-
- DrugName: drug_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- LastPrice: last_price,
- RetailPrice: retail_price,
- NewPrice: new_price,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- DrugId: drug_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- LicenseNumber: "",
- StartTime: startTime,
- Creater: Creater,
- Checker: 0,
- CheckerStatus: 2,
- CheckerTime: 0,
- ExpiryDate: expiry_date,
- ProductDate: product_date,
- Number: numbers,
- //BatchNumber: batch_number,
- Total: total,
- WarehouseInfoId: warehouse_info_id,
- DrugOriginPlace: drug_origin_place,
- MinUnit: min_unit,
- MinCount: min_count,
- }
- err = service.CreateDrugInventory(inventory)
- fmt.Println(err)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "msg",
- })
- }
-
- func (this *SelfDrugApiController) GetDrugInventoryList() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- orgId := this.GetAdminUserInfo().CurrentOrgId
- keyword := this.GetString("keyword")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
-
- doctorList, _ := service.GetAllDoctorThree(orgId)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "doctorList": doctorList,
- "houseList": houseList,
- "houseConfig": houseConfig,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugCheckInventory() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- idstr := this.GetString("ids")
- ids := strings.Split(idstr, ",")
- check_time := this.GetString("check_time")
- var checkTime int64
- if len(check_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- checkTime = theTime.Unix()
- }
- checker, _ := this.GetInt64("checker")
- inventory := models.XtDrugInventory{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- err = service.UpdateDrugInventory(ids, inventory)
- fmt.Println(err)
-
- list, _ := service.GetDrugInventoryListByIds(ids)
-
- adminUserInfo := this.GetAdminUserInfo()
- var stock_total int64
- var proof_count int64
- var maxNumber int64
- var minNumber int64
- for _, item := range list {
-
- //查询药品信息
- drug, _ := service.GetDrugDetailByDrugId(item.DrugId)
-
- //查询库存
- info, _ := service.GetDrugWareInfoByIdTwo(item.WarehouseInfoId)
- var max_count int64
- var min_count int64
- for _, it := range info {
- max_count += it.StockMaxNumber
- min_count += it.StockMinNumber
- }
-
- //获取最晚的库存数量
- lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
- firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
- stock_total = max_count*drug.MinNumber + min_count
- proof_count = item.Count*drug.MinNumber + item.MinCount
- fmt.Println("stock_total", stock_total)
- fmt.Println("proof_count", proof_count)
- //判断 如果库存数量 大于盘点库存,则出库
- if stock_total > proof_count {
- minNumber = (stock_total - proof_count) % drug.MinNumber
- maxNumber = (stock_total - proof_count) / drug.MinNumber
-
- ctime := time.Now().Unix()
-
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- warehouseOut := models.DrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehouseOutTime: ctime,
- Type: 1,
- }
- service.AddSigleDrugWarehouseOut(&warehouseOut)
- warehouse, _ := service.GetLastDrugWarehouseOut(adminUserInfo.CurrentOrgId)
- warehouseOutInfo := models.DrugWarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouse.ID,
- DrugId: item.DrugId,
- Count: maxNumber,
- Price: firstInfo.Price,
- TotalPrice: firstInfo.TotalPrice,
- Status: 1,
- Ctime: ctime,
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 1,
- Manufacturer: firstInfo.Manufacturer,
- Dealer: firstInfo.Dealer,
- RetailPrice: firstInfo.RetailPrice,
- RetailTotalPrice: firstInfo.RetailTotalPrice,
- CountUnit: drug.MaxUnit,
- ExpiryDate: firstInfo.ExpiryDate,
- ProductDate: firstInfo.ProductDate,
- Number: firstInfo.Number,
- BatchNumber: firstInfo.BatchNumber,
- IsSys: 0,
- WarehouseInfoId: firstInfo.ID,
- }
-
- drugflow := models.DrugFlow{
- WarehouseOutId: warehouseOut.ID,
- WarehouseOutOrderNumber: warehousing_out_order,
- DrugId: item.DrugId,
- Number: firstInfo.Number,
- ProductDate: firstInfo.ProductDate,
- ExpireDate: firstInfo.ExpiryDate,
- Count: maxNumber,
- Price: firstInfo.Price,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: firstInfo.Manufacturer,
- Dealer: firstInfo.Dealer,
- BatchNumber: firstInfo.BatchNumber,
- MaxUnit: drug.MaxUnit,
- ConsumableType: 2,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- IsSys: 0,
- }
- service.CreateDrugWarehouseOutInfo(warehouseOutInfo)
- service.CreateDrugFlowOne(drugflow)
-
- //扣减当前批次号的库存
- var total_count int64
-
- //查询当前批次库存的数量
- warehosueInfoList, _ := service.GetCurrentWarehosueInfo(item.WarehouseInfoId)
- fmt.Println(warehosueInfoList)
- for _, item := range warehosueInfoList {
- total_count += item.StockMaxNumber*drug.MinNumber + item.StockMinNumber
- }
- //判断当前批次库存 和 需要出库的数据
- //出库
- if proof_count <= total_count {
-
- //var total_count_one int64
- //获取当前批次号的库存
- //warehouseinfoOne, _ := service.GetCurrentWarehosueInfoOne(item.WarehouseInfoId)
- //total_count_one = warehouseinfoOne.StockMaxNumber * drug.MinNumber + warehouseinfoOne.StockMinNumber
-
- }
- //报错提示
- if proof_count > total_count {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- }
- }
-
- //判断 如果库存数量 小于于盘点库存,则入库
- fmt.Println("stock_total2332322323223", stock_total, proof_count)
- if stock_total < proof_count {
-
- maxNumber = (proof_count - stock_total) / drug.MinNumber
- minNumber = (proof_count - stock_total) % drug.MinNumber
- fmt.Println("min_number23233232323223322323", minNumber)
- ctime := time.Now().Unix()
-
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllWarehouseTotalOne(adminUserInfo.CurrentOrgId)
- total = total + 1
- fmt.Println("total2323232323232", total)
- warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
-
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
- warehousing := models.DrugWarehouse{
- WarehousingOrder: warehousing_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehousingTime: ctime,
- Type: 1,
- }
- service.AddSigleDrugWarehouse(&warehousing)
- warehouse, _ := service.GetLastDrugWarehouse(adminUserInfo.CurrentOrgId)
- warehouseInfo := models.DrugWarehouseInfo{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehouse.ID,
- DrugId: item.DrugId,
- Number: lastInfo.Number,
- ProductDate: lastInfo.ProductDate,
- ExpiryDate: lastInfo.ExpiryDate,
- WarehousingCount: maxNumber,
- Price: lastInfo.Price,
- TotalPrice: lastInfo.TotalPrice,
- Status: 1,
- Ctime: ctime,
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 1,
- Manufacturer: lastInfo.Manufacturer,
- Dealer: lastInfo.Dealer,
- StockMaxNumber: maxNumber,
- StockMinNumber: minNumber,
- RetailTotalPrice: lastInfo.RetailTotalPrice,
- BatchNumber: lastInfo.BatchNumber,
- MaxUnit: drug.MaxUnit,
- MinUnit: drug.MinUnit,
- WarehousingInfoId: item.WarehouseInfoId,
- }
-
- drugflow := models.DrugFlow{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehouse.ID,
- DrugId: item.DrugId,
- Number: lastInfo.Number,
- ProductDate: lastInfo.ProductDate,
- ExpireDate: lastInfo.ExpiryDate,
- Count: maxNumber,
- Price: lastInfo.Price,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: lastInfo.Manufacturer,
- Dealer: lastInfo.Dealer,
- BatchNumber: lastInfo.BatchNumber,
- MaxUnit: drug.MaxUnit,
- MinUnit: drug.MinUnit,
- ConsumableType: 1,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- IsSys: 0,
- }
-
- service.CreateDrugWarehouseInfo(warehouseInfo)
- service.CreateDrugFlowOne(drugflow)
-
- }
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- }
-
- func (this *SelfDrugApiController) GetDrugInventoryDetail() {
-
- id, _ := this.GetInt64("id")
- detail, err := service.GetDrugInventoryDetail(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *SelfDrugApiController) ModifyInventory() {
-
- id, _ := this.GetInt64("id")
- drug_id, _ := this.GetInt64("drug_id")
- drug_name := this.GetString("drug_name")
- specification_name := this.GetString("specification_name")
- retailPrice := this.GetString("retail_price")
- retail_price, _ := strconv.ParseFloat(retailPrice, 64)
- warehousing_order := this.GetString("warehousing_order")
- number := this.GetString("number")
- manufacturer := this.GetString("manufacturer")
- remark := this.GetString("remark")
- warehousing_unit := this.GetString("warehousing_unit")
- total := this.GetString("total")
- lastPrice := this.GetString("last_price")
- last_price, _ := strconv.ParseFloat(lastPrice, 64)
- count, _ := this.GetInt64("count")
- drug_origin_place := this.GetString("drug_origin_place")
-
- stock_max_number, _ := this.GetInt64("stock_max_number")
- stock_min_number, _ := this.GetInt64("stock_min_number")
- warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
- min_count, _ := this.GetInt64("min_count")
- min_unit := this.GetString("min_unit")
- inventory := models.XtDrugInventory{
- DrugName: drug_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- LastPrice: last_price,
- RetailPrice: retail_price,
- Manufacturer: manufacturer,
- Remark: remark,
- DrugId: drug_id,
- WarehousingOrder: warehousing_order,
- Number: number,
- Total: total,
- DrugOriginPlace: drug_origin_place,
- StockMaxNumber: stock_max_number,
- StockMinNumber: stock_min_number,
- WarehouseInfoId: warehouse_info_id,
- MinCount: min_count,
- MinUnit: min_unit,
- }
- err := service.ModifyDrugInventory(id, inventory)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "inventory": inventory,
- })
- }
-
- func (this *SelfDrugApiController) DeleteDrugInventory() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteDrugInventory(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- }
-
- func (this *SelfDrugApiController) GetDrugInventoryPrintList() {
-
- ids := this.GetString("ids")
-
- idssplit := strings.Split(ids, ",")
- list, err := service.GetDrugInventoryPrintList(idssplit)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
-
- keyword := this.GetString("keyword")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- appId := this.GetAdminUserInfo().CurrentAppId
- list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId, storehouse_id)
- inventoryList, _, _ := service.GetDrugInventoryDetailListTwo(keyword, page, limit, orgId, storehouse_id)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "doctorList": doctorList,
- "houseList": houseList,
- "inventoryList": inventoryList,
- })
- }
-
- func (this *SelfDrugApiController) SaveDrugProofInventory() {
-
- id, _ := this.GetInt64("id")
- warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
- warehousing_unit := this.GetString("warehousing_unit")
- remark := this.GetString("remark")
- proof_count, _ := this.GetInt64("proof_count")
-
- inventory := models.XtDrugInventory{
- WarehouseInfoId: warehouse_info_id,
- ProofCount: proof_count,
- WarehousingUnit: warehousing_unit,
- Remark: remark,
- }
- err := service.UpdateDrugProofInventory(id, &inventory)
- info := models.XtDrugWarehouseInfo{
- StockMaxNumber: proof_count,
- }
- service.UpdateDrugWarehouseInfoById(warehouse_info_id, &info)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "inventory": inventory,
- })
- }
-
- func (this *StockManagerApiController) GetDrugWarehouseInfoTotal() {
-
- id, _ := this.GetInt64("id")
- list, _ := service.GetDrugWarehouseInfoTotal(id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- //新改造
-
- func (this *SelfDrugApiController) SaveInventoryList() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
-
- tableData, _ := dataBody["tableData"].([]interface{})
-
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- fmt.Println("drug_name", drug_name)
- specification_name := items["specification_name"].(string)
- if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- max_unit := items["max_unit"].(string)
- if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
- utils.ErrorLog("max_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- min_unit := items["min_unit"].(string)
- if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
- utils.ErrorLog("min_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- drug_id := int64(items["drug_id"].(float64))
-
- min_number := int64(items["min_number"].(float64))
-
- stock_max_number := int64(items["stock_max_number"].(float64))
-
- stock_min_number := int64(items["stock_min_number"].(float64))
-
- last_stock_max_number := int64(items["last_stock_max_number"].(float64))
-
- last_stock_min_number := int64(items["last_stock_min_number"].(float64))
-
- warehousing_order := items["warehousing_order"].(string)
-
- price := items["price"].(float64)
-
- manufacturer_name := items["manufacturer_name"].(string)
-
- batch_number := items["batch_number"].(string)
-
- id := int64(items["id"].(float64))
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- type_id := int64(items["type"].(float64))
-
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
- utils.ErrorLog("expiry_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiry_date := int64(items["expiry_date"].(float64))
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- storehouse_id := int64(items["storehouse_id"].(float64))
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- timeNow := time.Now().Format("2006-01-02")
- locationTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeNow+" 00:00:00", loc)
- var consumable_type int64
- var consumable_count int64
- var ord_total int64
- var new_total int64
- var total int64
- ord_total = stock_max_number*min_number + stock_min_number
- new_total = last_stock_max_number*min_number + last_stock_min_number
- medical, _ := service.GetBaseDrugMedical(drug_id)
-
- //改变库存
- info := models.DrugWarehouseInfo{
- DrugId: drug_id,
- StockMaxNumber: last_stock_max_number,
- StockMinNumber: last_stock_min_number,
- WarehousingCount: last_stock_max_number,
- MaxUnit: max_unit,
- MinUnit: min_unit,
- }
- drugInfo, _ := service.GetCurrentWarehosueInfoOne(id)
-
- if drugInfo.MaxUnit == medical.MaxUnit {
- total = drugInfo.WarehousingCount * medical.MinNumber
- }
- if drugInfo.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- total = drugInfo.WarehousingCount
- }
- //如果库存数据大于盘点数据,则减去数量
- if ord_total > new_total {
- consumable_type = 11
- consumable_count = ord_total - new_total
-
- err = service.ModifyDrugWarehouseInfo(&info, id)
-
- }
- //如果库存数据小于盘点数据,则增加数量
- if ord_total < new_total && new_total <= total {
- consumable_type = 10
- consumable_count = new_total - ord_total
- err = service.ModifyDrugWarehouseInfo(&info, id)
-
- }
-
- if ord_total < new_total && new_total > total {
- consumable_type = 10
- consumable_count = new_total - ord_total
- err = service.ModifyDrugWarehouseInfoSix(&info, id)
-
- }
-
- //查询默认仓库
- houseConfig, _ := service.GetAllStoreHouseConfig(drugInfo.OrgId)
- //查询默认仓库剩余多少库存
- list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, drugInfo.OrgId, drugInfo.DrugId)
- var sum_count int64
- var sum_in_count int64
- for _, it := range list {
- baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
- if it.MaxUnit == baseDrug.MaxUnit {
- it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
- it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
- }
- sum_count += it.StockMaxNumber + it.StockMinNumber
- sum_in_count += it.WarehousingCount
- }
- service.UpdateMedicalSumCount(drugInfo.DrugId, sum_count, sum_in_count, drugInfo.OrgId)
-
- //更新剩余库存
- service.UpdateDrugStockCount(drugInfo.DrugId, drugInfo.OrgId, houseConfig.DrugStorehouseOut, sum_count)
- inventory := models.XtDrugInventory{
- DrugName: drug_name,
- SpecificationName: specification_name,
- WarehousingUnit: max_unit,
- Count: consumable_count,
- LastPrice: price,
- RetailPrice: 0,
- NewPrice: 0,
- Manufacturer: manufacturer_name,
- Dealer: "",
- Remark: "",
- DrugId: drug_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- LicenseNumber: "",
- StartTime: locationTime.Unix(),
- Creater: this.GetAdminUserInfo().AdminUser.Id,
- Checker: 0,
- CheckerStatus: 0,
- CheckerTime: 0,
- ExpiryDate: expiry_date,
- ProductDate: 0,
- Number: "",
- BatchNumber: batch_number,
- Total: "",
- DrugOriginPlace: "",
- WarehouseInfoId: id,
- ProofCount: 0,
- StockMaxNumber: stock_max_number,
- StockMinNumber: stock_min_number,
- MinCount: 0,
- MinUnit: min_unit,
- LastStockMaxNumber: last_stock_max_number,
- LastStockMinNumber: last_stock_min_number,
- InventoryType: consumable_type,
- Type: type_id,
- StorehouseId: storehouse_id,
- }
-
- err = service.CreateDrugInventory(inventory)
-
- flow := models.DrugFlow{
- WarehousingId: id,
- DrugId: drug_id,
- Number: "",
- BatchNumber: batch_number,
- Count: consumable_count,
- UserOrgId: orgId,
- PatientId: 0,
- SystemTime: locationTime.Unix(),
- ConsumableType: consumable_type,
- IsSys: 1,
- WarehousingOrder: warehousing_order,
- WarehouseOutId: 0,
- WarehouseOutOrderNumber: "",
- IsEdit: 0,
- CancelStockId: 0,
- CancelOrderNumber: "",
- Manufacturer: manufacturer,
- Dealer: 0,
- Creator: this.GetAdminUserInfo().AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: price,
- WarehousingDetailId: id,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ExpireDate: expiry_date,
- ProductDate: 0,
- MaxUnit: min_unit,
- MinUnit: min_unit,
- StorehouseId: storehouse_id,
- OverCount: sum_count,
- }
- if ord_total != new_total {
- service.CreateDrugFlowOne(flow)
- }
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "inventory": inventory,
- })
- }
- }
-
- newTableData, _ := dataBody["newTableData"].([]interface{})
-
- if len(newTableData) > 0 {
- for _, item := range newTableData {
- items := item.(map[string]interface{})
- drug_name := items["drug_name"].(string)
- if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- fmt.Println("drug_name", drug_name)
- specification_name := items["specification_name"].(string)
- if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- max_unit := items["max_unit"].(string)
- if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
- utils.ErrorLog("max_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- min_unit := items["min_unit"].(string)
- if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
- utils.ErrorLog("min_unit")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- drug_id := int64(items["drug_id"].(float64))
-
- stock_max_number := int64(items["stock_max_number"].(float64))
-
- stock_min_number := int64(items["stock_min_number"].(float64))
-
- last_stock_max_number := int64(items["last_stock_max_number"].(float64))
-
- last_stock_min_number := int64(items["last_stock_min_number"].(float64))
-
- warehousing_order := items["warehousing_order"].(string)
-
- price := items["price"].(float64)
-
- manufacturer_name := items["manufacturer_name"].(string)
-
- batch_number := items["batch_number"].(string)
-
- id := int64(items["id"].(float64))
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- type_id := int64(items["type"].(float64))
-
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
- utils.ErrorLog("expiry_date")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiry_date := int64(items["expiry_date"].(float64))
-
- product_date := int64(items["product_date"].(float64))
-
- storehouse_id := int64(items["storehouse_id"].(float64))
-
- warehousing_count := int64(items["warehousing_count"].(float64))
-
- warehouseing_unit := items["warehouseing_unit"].(string)
-
- creater := this.GetAdminUserInfo().AdminUser.Id
-
- var recordDateStr = time.Now().Format("2006-01-02")
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
-
- drugStockInventoryList := models.XtDrugStockInventoryList{
- DrugId: drug_id,
- WarehousingOrder: warehousing_order,
- WarehousingCount: warehousing_count,
- BatchNumber: batch_number,
- Price: price,
- StockMaxNumber: stock_max_number,
- StockMinNumber: stock_min_number,
- Reason: type_id,
- Creater: creater,
- RecordDate: recordDate.Unix(),
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- WarehouseInfoId: id,
- SpecificationName: specification_name,
- ManufacturerName: manufacturer_name,
- DrugName: drug_name,
- ExpiryDate: expiry_date,
- ProductDate: product_date,
- StorehouseId: storehouse_id,
- MaxUnit: max_unit,
- LastStockMaxNumber: last_stock_max_number,
- LastStockMinNumber: last_stock_min_number,
- WarehousingCountUnit: warehouseing_unit,
- MinUnit: min_unit,
- Status: 1,
- }
-
- //查询今日的药品有没有
- drugInvetory, _ := service.GetDrugStockInventoryList(drug_id, recordDate.Unix(), orgId)
-
- if drugInvetory.ID == 0 {
-
- service.CreatedDrugStockInventory(drugStockInventoryList)
- }
-
- if drugInvetory.ID > 0 {
- drugStockInventoryList.ID = drugInvetory.ID
- service.SaveDrugStockInventory(drugStockInventoryList)
- }
- }
- }
- }
-
- func (this *SelfDrugApiController) GetDamageByDrugId() {
-
- drug_id, _ := this.GetInt64("drug_id")
- warehousing_order := this.GetString("warehouseing_order")
- drug_type, _ := this.GetInt64("type")
- list, err := service.GetDamageByDrugId(drug_id, warehousing_order, drug_type)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetInventoryModeList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, err := service.GetInventoryModeList(orgId)
- manufacturerList, err := service.GetAllManufacturerList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- })
- }
-
- // 库存优化接口
- func (this *SelfDrugApiController) GetStorehouseList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, err := service.GetAllStoreHouseList(orgId)
- manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
- goodType, _ := service.GetAllNewGoodType(orgId)
- patientList, _ := service.GetAllpatientThirty(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取仓库失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "goodTypeList": goodType,
- "patientList": patientList,
- "dealerList": dealerList,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodNewQuery() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- storehouse_id, _ := this.GetInt64("storehouse_id")
- good_type, _ := this.GetInt64("good_type")
- keyword := this.GetString("keyword")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
-
- // 查询该机构所有耗材入库信息
- //goodList, _ := service.GetAllGoodListSeven(orgId)
- //
- //for _, it := range goodList {
- // var sum_total int64
- // //查询该耗材入库信息
- // warehouseinfo, _ := service.GetGoodInformationWarehouseInfo(it.ID, orgId)
- // for _, item := range warehouseinfo {
- // sum_total += item.StockCount
- // }
- // service.UpdateGoodInformation(it.ID, orgId, sum_total)
- //}
-
- var ids []int64
-
- if len(keyword) > 0 {
- manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturerList {
- ids = append(ids, it.ID)
- }
- }
-
- stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
- return
- }
- var medicalInsuranceLevel = "医保等级"
- medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
- medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "stockList": stockList,
- "medicalInsuranceLevelList": medicalInsuranceLevelList,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodWarehouseOutInfoByIdList() {
-
- good_id, _ := this.GetInt64("good_id")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- start_time := this.GetString("start_first_time")
- end_time := this.GetString("end_first_time")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- list, total, err := service.GetGoodWarehouseOutInfoByIdList(good_id, limit, page, orgId, startTime, endTime, storehouse_id)
- //flushList, _ := service.GetStockFlushByGoodId(good_id, orgId, startTime, endTime)
-
- //warehouseInfoByList, _ := service.GetGoodWarehouseInfoByList(good_id, orgId, startTime, endTime)
- //cancelStockInfoByList, _ := service.GetGoodCancelStockInfoByList(good_id, orgId, startTime, endTime)
- //warehouseOutByList,_ := service.GetGoodWarehouseOutInfoByIdListTwenty(good_id, limit, page, orgId, startTime, endTime)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查寻出库信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- //"warehouseInfoByList":warehouseInfoByList,
- //"cancelStockInfoByList":cancelStockInfoByList,
- //"warehouseOutByList":warehouseOutByList,
- //"flushList":flushList,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodPatientList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- keyword := this.GetString("keyword")
- list, err := service.GetGoodPatientList(orgId, keyword)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *SelfDrugApiController) GetWarehouseOutDetailByPatientId() {
-
- patient_id, _ := this.GetInt64("patient_id")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- list, total, err := service.GetWarehouseOutDetailByPatientIdOne(orgId, patient_id, startTime, endTime, limit, page)
- outlist, _ := service.GetWarehouseOutDetailByPatientId(orgId, patient_id, startTime, endTime)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "outlist": outlist,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodExpiryDateQuery() {
-
- storehouse_id, _ := this.GetInt64("storehouse_id")
- expiry_type, _ := this.GetInt64("expiry_type")
- keyword := this.GetString("keyword")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- start_time := this.GetString("start_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var endTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- fmt.Scan("parseDateErr", parseDateErr)
- nowtime := recordDate.Unix()
-
- var ids []int64
- var goodIds []int64
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- goodList, _ := service.GetGoodNameByword(orgId, keyword)
- for _, it := range goodList {
- goodIds = append(goodIds, it.ID)
- }
- list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "nowtime": nowtime,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
-
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var goodIds []int64
- infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
- for _, it := range infoList {
- goodIds = append(goodIds, it.GoodId)
- }
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
- storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
- for _, item := range list {
-
- //获取期初结余数量
- infoList, _ := service.GetStartGoodWarehouseInfoList(item.ID, orgId, startTime)
- for _, it := range infoList {
- item.WarehousingInfoStart = append(item.WarehousingInfoStart, it)
- }
-
- //获取期末结余数量
- warehouseInfoList, _ := service.GetEndGoodWarehouseInfoList(item.ID, orgId, endTime)
- for _, it := range warehouseInfoList {
- item.WarehousingInfoEnd = append(item.WarehousingInfoEnd, it)
- }
-
- //获取期间增加
- goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range goodWarehouseInfoList {
- item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
- }
-
- //获取本期增加
- WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range WarehouseInfoFlowList {
- item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
- }
- //获取本期减少
- reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range reduceWarehouseInfoList {
- item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
- }
-
- //获取期中减少退库
- lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range lowInfo {
- item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
- }
- //
- outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
- for _, it := range outInfo {
- item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
- }
-
- //获取期初结余
- info, _ := service.FindeStartFlowInfo(item.ID, orgId, startTime)
- for _, it := range info {
- item.StartFlowInfo = append(item.StartFlowInfo, it)
- }
- //获取期初结余
- flowOutInfo, _ := service.FindeStartFlowOutInfo(item.ID, orgId, startTime)
- for _, it := range flowOutInfo {
- item.StartOutFlowInfo = append(item.StartOutFlowInfo, it)
- }
-
- //获取期初退库
- cancelInfo, _ := service.FindeStartCancelInfo(item.ID, orgId, startTime)
- for _, it := range cancelInfo {
- item.StartCancelFlowInfo = append(item.StartCancelFlowInfo, it)
- }
-
- //获取期末结余
- flowInfo, _ := service.FindEndStartFlowInfo(item.ID, orgId, endTime)
- for _, it := range flowInfo {
- item.EndFlowInfo = append(item.EndFlowInfo, it)
- }
-
- //获取期末出库
- lowOutInfo, _ := service.FindeEndFLowOutInfo(item.ID, orgId, endTime)
- for _, it := range lowOutInfo {
- item.EndFlowOutInfo = append(item.EndFlowOutInfo, it)
- }
-
- //获取期末退库
- endCancelInfo, _ := service.FindEndCancelInfo(item.ID, orgId, endTime)
- for _, it := range endCancelInfo {
- item.EndCancelFLowInfo = append(item.EndCancelFLowInfo, it)
- }
-
- //期初盘赢
- inventory, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, startTime)
- for _, it := range inventory {
- item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
- }
- //期初盘亏
- stockInventory, _ := service.FindStartStockInventoryLosses(item.ID, orgId, startTime)
- for _, it := range stockInventory {
- item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
- }
-
- //期末盘盈
- inventoryProfit, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, endTime)
- for _, it := range inventoryProfit {
- item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
- }
- //期末盘亏
- inventoryLosses, _ := service.FindStartStockInventoryLosses(item.ID, orgId, endTime)
- for _, it := range inventoryLosses {
- item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
- }
-
- //期中盘盈
- profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
- //期中盘亏
- losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range losses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
- }
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugWarehouseOutDetailByPatientId() {
-
- patient_id, _ := this.GetInt64("patient_id")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- list, total, _ := service.GetDrugWarehouseOutDetailByPatientIdOne(patient_id, orgId, startTime, endTime, page, limit)
- outlist, _ := service.GetDrugWarehouseOutDetailByPatientId(patient_id, orgId, startTime, endTime)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "outlist": outlist,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugExpiryDateQuery() {
- storehouse_id, _ := this.GetInt64("storehouse_id")
- expiry_type, _ := this.GetInt64("expiry_type")
- keyword := this.GetString("keyword")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- start_time := this.GetString("start_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var endTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- fmt.Scan("parseDateErr", parseDateErr)
- nowtime := recordDate.Unix()
-
- var ids []int64
- var goodIds []int64
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- drugList, _ := service.GetDrugNameByword(orgId, keyword)
- for _, it := range drugList {
- goodIds = append(goodIds, it.ID)
- }
- list, total, err := service.GetDrugExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "nowtime": nowtime,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (this *SelfDrugApiController) GetPurchaseDrugQuery() {
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var startTime int64
-
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var infoIds []int64
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
- for _, it := range infoList {
- infoIds = append(infoIds, it.DrugId)
- }
- manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
- list, total, err := service.GetDrugPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
-
- for _, item := range list {
-
- //获取期初结余入库数量
- startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)
- for _, it := range startDrugInfo {
- item.DrugWarehouseInfoStart = append(item.DrugWarehouseInfoStart, it)
- }
-
- //获取期初结余出库数量
- flowOutList, _ := service.GetDrugFlowOut(item.ID, orgId, startTime)
- for _, it := range flowOutList {
- item.DrugWarehouseOutInfoStart = append(item.DrugWarehouseOutInfoStart, it)
- }
-
- //获取期初结余退库数量
- cancelInfo, _ := service.GetStartDrugFlowCancelInfo(item.ID, orgId, startTime)
- for _, it := range cancelInfo {
- item.WareStartStockCancelInfo = append(item.WareStartStockCancelInfo, it)
- }
-
- //获取期末结余入库数量
- drugwarehouseinfoend, _ := service.DrugWarehouseInfoEnd(item.ID, orgId, endTime)
- for _, it := range drugwarehouseinfoend {
- item.DrugWarehouseInfoEnd = append(item.DrugWarehouseInfoEnd, it)
- }
-
- //获取期末出库结余
- endDrugInfo, _ := service.DrugWarehouseOutInfoEnd(item.ID, orgId, endTime)
- for _, it := range endDrugInfo {
- item.DrugWarehouseOutInfoEnd = append(item.DrugWarehouseOutInfoEnd, it)
- }
-
- //获取期末退库数量
- flowCancelInfo, _ := service.GetEndDrugFlowCancelInfo(item.ID, orgId, endTime)
- for _, it := range flowCancelInfo {
- item.WareEndStockCancelInfo = append(item.WareEndStockCancelInfo, it)
- }
-
- //期中增加
- drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
- for _, it := range drugWarehouse {
- item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
- }
-
- //期中减少
- outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range outInfo {
- item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
- }
-
- //期中退库
- cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range cancelstartInfo {
- item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
- }
-
- //获取期初盘盈
- startProfit, _ := service.GetDrugFlowStartProfit(item.ID, orgId, startTime)
- for _, it := range startProfit {
- item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
- }
- //获取期初盘亏
- startLosses, _ := service.GetDrugFlowStartLosses(item.ID, orgId, startTime)
- for _, it := range startLosses {
- item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
- }
- //获取期末盘盈
- endProfit, _ := service.GetDrugFlowEndProfit(item.ID, orgId, endTime)
- for _, it := range endProfit {
- item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
- }
- //获取期末盘亏
- losses, _ := service.GetDrugFlowEndLosses(item.ID, orgId, endTime)
- for _, it := range losses {
- item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
- }
-
- //获取期中盘盈
- profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
-
- //获取期中盘亏
- endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
- for _, it := range endLosses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
- }
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugNewQuery() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- storehouse_id, _ := this.GetInt64("storehouse_id")
- good_type, _ := this.GetInt64("good_type")
- keyword := this.GetString("keyword")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var goodIds []int64
-
- if len(keyword) > 0 {
- manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturerList {
- ids = append(ids, it.ID)
- }
- }
- //查询药品库信息
- //drug, _ := service.GetBaseDrugName(orgId)
- //
- //for _, it := range drug {
- // var sum_count int64
- // var limit_count int64
- // drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
- // for _, item := range drugInfo {
- //
- // sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
- // }
- // stockInt, _ := strconv.ParseInt(it.DrugStockLimit, 10, 64)
- // limit_count = stockInt * it.MinNumber
- // service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
- //}
-
- if storehouse_id > 0 {
- infoList, _ := service.GetDrugWarehouseInfoByOrgId(orgId, storehouse_id)
- for _, it := range infoList {
- goodIds = append(goodIds, it.DrugId)
- }
- }
-
- countList, total, err := service.GetDrugStockCountList(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
- return
- }
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- var medicalInsuranceLevel = "医保等级"
- medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
- medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "drugTypeList": drugTypeList,
- "countList": countList,
- "medicalInsuranceLevelList": medicalInsuranceLevelList,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugWarehouseInfoById() {
-
- drug_id, _ := this.GetInt64("drug_id")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- start_time := this.GetString("start_first_time")
- end_time := this.GetString("end_first_time")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- list, total, err := service.GetDrugWarehouseOutInfoByIdList(drug_id, limit, page, orgId, startTime, endTime, storehouse_id)
- flushList, _ := service.GetDrugFlowFlush(drug_id, orgId, startTime, endTime)
- flushOne, _ := service.GetDrugFlowFlushOne(drug_id, orgId, startTime, endTime)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查寻出库信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "flushList": flushList,
- "flushListOne": flushOne,
- })
- }
-
- func (this *SelfDrugApiController) GetSendGoodInformation() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- fmt.Println("orgid", orgId)
- list, _ := service.GetWarehouseOutInfo(10485)
-
- for _, it := range list {
- service.UpdateWarehosueOutInfo(it.ID, it.WarehouseOutTime)
- }
-
- //获取入库数据
- //list, _ := service.GetSendGoodInformation(10265)
- //
- ////project, _ := service.GetHisPrescriptionList(10265)
- //
- //for _, it := range list {
- // service.UpdateGoodFlow(it.ID, it.PackingPrice)
- //}
-
- //for _, it := range list {
- // //查询是否有数据
- // _, errcode := service.GetStockFlush(it.StorehouseId, it.GoodId, it.OrgId)
- // //获取总退库数量
- // var cancel_count int64
- // var out_count int64
- // var act_count int64
- // //退库总数量
- // cancellist, _ := service.GetAllCancelCount(it.StorehouseId, it.GoodId, it.OrgId)
- // for _, item := range cancellist {
- // cancel_count += item.Count
- // }
- // //出库总数量
- // outlist, _ := service.GetAllStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
- // for _, item := range outlist {
- // out_count += item.Count
- // }
- //
- // //实际出库总数量
- // actlist, _ := service.GetActStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
- // for _, item := range actlist {
- // act_count += item.Count
- // }
- //
- // if errcode == gorm.ErrRecordNotFound {
- // good := models.XtGoodStockCount{
- // UserOrgId: it.OrgId,
- // GoodId: it.GoodId,
- // StorehouseId: it.StorehouseId,
- // Status: 1,
- // Ctime: time.Now().Unix(),
- // Mtime: 0,
- // StockInCount: it.WarehousingCount,
- // StockOutCount: out_count - cancel_count,
- // StockCancelCount: cancel_count,
- // FlushCount: it.StockCount,
- // StockActOutCount: act_count,
- // }
- // service.CreateGoodCountSix(good)
- // }
- // if errcode == nil {
- // service.UpdateGoodCount(it.WarehousingCount, it.StockCount, out_count, it.StorehouseId, it.GoodId, it.OrgId, cancel_count, act_count)
- // }
- //}
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- }
-
- func (this *SelfDrugApiController) GetDrugInitDetailList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- //获取所有的入库仓库
- list, _ := service.GetDrugWarehouseInfoStorehouseList(orgId)
- for _, item := range list {
- //查询该药品该仓库是否有数据
- drug, _ := service.GetDrugStockCout(item.DrugId, item.StorehouseId, item.OrgId)
-
- //查询该仓库该药品的入库数量
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
-
- var sum_in_count int64
- var flush_count int64
- var sum_out_count int64
- var cancel_out_count int64
- //查询入库数量和剩余库存
- infolist, _ := service.GetDrugWarehouseInfoByStorehouseId(item.StorehouseId, item.DrugId, item.OrgId)
- for _, it := range infolist {
- if it.MaxUnit == medical.MaxUnit {
- it.WarehousingCount = it.WarehousingCount * medical.MinNumber
- it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
- }
- sum_in_count += it.WarehousingCount
- flush_count += it.StockMaxNumber + it.StockMinNumber
- }
-
- //获取出库数量
- outinfolist, _ := service.GetDrugFlowStockOutCount(item.StorehouseId, item.DrugId, item.OrgId)
- for _, it := range outinfolist {
- if it.MaxUnit == medical.MaxUnit {
- it.Count = it.Count * medical.MinNumber
- }
- sum_out_count += it.Count
- }
-
- //获取退库数量
- cancelinfolist, _ := service.GetDrugFlowStockCancelCount(item.StorehouseId, item.DrugId, item.OrgId)
- for _, it := range cancelinfolist {
- if it.MaxUnit == medical.MaxUnit {
- it.Count = it.Count * medical.MinNumber
- }
- cancel_out_count += it.Count
- }
-
- //新增
- if drug.ID == 0 {
- drugstock := models.XtDrugStockCount{
- UserOrgId: orgId,
- StorehouseId: item.StorehouseId,
- SumInCount: sum_in_count,
- SumOutCount: sum_out_count - cancel_out_count,
- SumCancelCount: cancel_out_count,
- DrugId: item.DrugId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- FlushCount: flush_count,
- SumActOutCount: sum_out_count,
- }
- service.CreateDrugStockCount(drugstock)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- }
-
- func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
-
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
-
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var goodIds []int64
- //infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
- //for _, it := range infoList {
- // goodIds = append(goodIds, it.GoodId)
- //}
-
- if len(keyword) > 0 {
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- }
-
- manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
-
- var medicalInsuranceLevel = "医保等级"
- medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
- medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
-
- if orgId == 10265 {
- //storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
-
- list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
-
- for _, item := range list {
-
- //获取期初结余
- low, _ := service.GetStartLastFLowTwenty(item.ID, orgId, startTime)
-
- item.GoodStartFlowInfo = low
-
- //获取期末结余
- flow, _ := service.GetEndLastFlowTwenty(item.ID, orgId, endTime)
-
- item.GoodEndFlowInfo = flow
-
- //获取期间增加
- goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoListTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range goodWarehouseInfoList {
- item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
- }
-
- //获取本期增加
- WarehouseInfoFlowList, _ := service.GetAddStartFlowTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range WarehouseInfoFlowList {
- item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
- }
- //获取本期减少
- reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoListTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range reduceWarehouseInfoList {
- item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
- }
-
- //获取期中减少退库
- lowInfo, _ := service.GetStartEndCancelFLowInfoTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range lowInfo {
- item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
- }
- //
- outInfo, _ := service.FindeWarehouseOutInfoTwenty(item.ID, orgId, startTime)
- for _, it := range outInfo {
- item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
- }
-
- //期中盘盈
- profit, _ := service.FindeEndStokInventoryProfitTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
- //期中盘亏
- losses, _ := service.FindeEndStockInventoryLossesTwenty(item.ID, orgId, startTime, endTime)
- for _, it := range losses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
- }
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "medicalInsuranceLevelList": medicalInsuranceLevelList,
- })
- }
-
- if orgId != 10265 {
- list, total, err := service.GetGoodNewPurchaseStockQueryOne(good_type, keyword, page, limit, orgId, ids, goodIds)
- storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
- for _, item := range list {
-
- //获取期初结余
- low, _ := service.GetStartLastFLow(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
-
- item.GoodStartFlowInfo = low
-
- //获取期末结余
- flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime, storeConfig.StorehouseOutInfo)
-
- item.GoodEndFlowInfo = flow
-
- //获取期间增加
- goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range goodWarehouseInfoList {
- item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
- }
-
- //获取本期增加
- WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range WarehouseInfoFlowList {
- item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
- }
- //获取本期减少
- reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range reduceWarehouseInfoList {
- item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
- }
-
- //获取期中减少退库
- lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range lowInfo {
- item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
- }
- //
- outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
- for _, it := range outInfo {
- item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
- }
-
- //期中盘盈
- profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
- //期中盘亏
- losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range losses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
-
- //获取期初结余
- balanceList, _ := service.GetInitBalanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range balanceList {
- item.StWarehousingInfoTwo = append(item.StWarehousingInfoTwo, it)
- }
-
- //期间减少
- banceOutList, _ := service.GetInitOutBanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- //banceOutList, _ := service.GetInitOutBanceTenty(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range banceOutList {
- item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
- }
-
- //期间盘盈
- infoFlow, _ := service.GetInitInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range infoFlow {
- item.WareStartInStockFlow = append(item.WareStartInStockFlow, it)
- }
-
- //期间盘亏
- outInfoFlow, _ := service.GetInitOutInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range outInfoFlow {
- item.WareStartOutStockFlow = append(item.WareStartOutStockFlow, it)
- }
-
- }
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "medicalInsuranceLevelList": medicalInsuranceLevelList,
- })
- }
-
- }
-
- func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
-
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var startTime int64
-
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var infoIds []int64
-
- if len(keyword) > 0 {
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- }
-
- //infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
- //for _, it := range infoList {
- // infoIds = append(infoIds, it.DrugId)
- //}
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- list, total, err := service.GetDrugNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
-
- for _, item := range list {
-
- //获取期初结余
- flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
-
- item.DrugStatFlow = flow
-
- //获取期末结余
- endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
-
- item.DrugEndFlow = endFlow
-
- //期中增加
- drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
- for _, it := range drugWarehouse {
- item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
- }
-
- //期中减少
- outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range outInfo {
- item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
- }
-
- //期中退库
- cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range cancelstartInfo {
- item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
- }
-
- //获取期中盘盈
- profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
-
- //获取期中盘亏
- endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
- for _, it := range endLosses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
-
- if orgId != 10215 && orgId != 10265 {
- //获取入库
- infoFLow, _ := service.GetNewDrugFlowInWarehouseInfo(item.ID, orgId, startTime)
-
- for _, it := range infoFLow {
- item.NewDrugFlowInWarehouseInfo = append(item.NewDrugFlowInWarehouseInfo, it)
- }
- //获取盘盈
- infoProfitFlow, _ := service.GetNewDrugFlowPofitWarehouseInfo(item.ID, orgId, startTime)
-
- for _, it := range infoProfitFlow {
- item.NewDrugFlowPofitWarehouseInfo = append(item.NewDrugFlowPofitWarehouseInfo, it)
- }
- //获取出库
- infoOutFlow, _ := service.GetNewDrugFlowOutWarehouseInfo(item.ID, orgId, startTime)
- for _, it := range infoOutFlow {
- item.NewDrugFlowOutWarehouseInfo = append(item.NewDrugFlowOutWarehouseInfo, it)
- }
-
- //获取退库
- infoCacelFlow, _ := service.GetNewDrugFlowCacelWarehouseInfo(item.ID, orgId, startTime)
- for _, it := range infoCacelFlow {
- item.NewDrugFlowNoCancelWarehouseInfo = append(item.NewDrugFlowNoCancelWarehouseInfo, it)
- }
-
- //获取盘亏
- infoNoPofitFlow, _ := service.GetNewDrugFlowNoPofitWarehouseInfo(item.ID, orgId, startTime)
- for _, it := range infoNoPofitFlow {
- item.NewDrugFlowNoPofitWarehouseInfo = append(item.NewDrugFlowNoPofitWarehouseInfo, it)
- }
- }
-
- }
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (this *SelfDrugApiController) GetGoodOverCount() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetAllStockCount(orgId)
- for _, item := range list {
- flow, _ := service.GetLastStockFlow(item.GoodId)
- service.ModifyStockFlowById(flow.ID, item.FlushCount)
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) GetDrugOverCount() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetAllDrugCount(orgId)
- for _, item := range list {
- service.GetLastDrugFlow(item.DrugId)
- service.ModifyDrugFlowById(item.ID, item.FlushCount)
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *SelfDrugApiController) GetDrugInventoryWarehouseInfoList() {
-
- storehouse_id, _ := this.GetInt64("storehouse_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetDrugInventoryWarehouseInfoList(orgId, storehouse_id)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (this *SelfDrugApiController) GetInventoryDetailPrintList() {
- keyword := this.GetString("keyword")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- storehouse_id, _ := this.GetInt64("storehouse_id")
- ids := this.GetString("ids")
- idSplit := strings.Split(ids, ",")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, total, err := service.GetDrugInventoryDetailMapList(keyword, page, limit, orgId, storehouse_id, idSplit)
- inventoryList, _, _ := service.GetDrugInventoryDetailListTwo(keyword, page, limit, orgId, storehouse_id)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- doctorList, _ := service.GetAllDoctorThree(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- "doctorList": doctorList,
- "houseList": houseList,
- "inventoryList": inventoryList,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugFlowDetailById() {
-
- drug_id, _ := this.GetInt64("drug_id")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetDrugFlowDetailById(drug_id, orgId)
-
- drugMedical, _ := service.GetBaseDrugMedical(drug_id)
-
- for index, _ := range list {
- if list[index].ConsumableType == 3 || list[index].ConsumableType == 2 || list[index].ConsumableType == 11 || list[index].ConsumableType == 12 || list[index].ConsumableType == 15 {
- var count int64
- if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
- list[index].Count = list[index].Count * drugMedical.MinNumber
- }
-
- if index == 0 {
- count = list[index].FlushOverCount - list[index].Count
- service.UpdateDrugOverCount(list[index+1].ID, count)
- }
-
- if index >= 1 {
- lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
- count = lastStockFlow.FlushOverCount - list[index].Count
- service.UpdateDrugOverCount(list[index].ID, count)
- }
-
- }
- if list[index].ConsumableType == 7 || list[index].ConsumableType == 4 || list[index].ConsumableType == 1 || list[index].ConsumableType == 10 || list[index].ConsumableType == 13 {
- if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
- list[index].Count = list[index].Count * drugMedical.MinNumber
- }
- if index == 0 {
- var count int64
- count = list[index].FlushOverCount + list[index].Count
- service.UpdateDrugOverCount(list[index+1].ID, count)
- }
-
- if index >= 1 {
- var count int64
- lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
- count = lastStockFlow.FlushOverCount + list[index].Count
- service.UpdateDrugOverCount(list[index].ID, count)
- }
-
- }
-
- }
- }
-
- func (this *SelfDrugApiController) GetPurchaseDrugQueryList() {
-
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var startTime int64
-
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var infoIds []int64
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
- for _, it := range infoList {
- infoIds = append(infoIds, it.DrugId)
- }
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- list, total, err := service.GetDrugNewPurchaseStockQueryList(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
-
- for _, item := range list {
-
- //获取期初结余
- flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
-
- item.DrugStatFlow = flow
-
- //获取期末结余
- endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
-
- item.DrugEndFlow = endFlow
- //获取期初结余入库数量
-
- //期中增加
- drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
- for _, it := range drugWarehouse {
- item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
- }
-
- //期中减少
- outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range outInfo {
- item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
- }
-
- //期中退库
- cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
- for _, it := range cancelstartInfo {
- item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
- }
-
- //获取期中盘盈
- profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
-
- //获取期中盘亏
- endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
- for _, it := range endLosses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
- }
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (this *SelfDrugApiController) GetPurchaseStockQueryList() {
-
- good_type, _ := this.GetInt64("good_type")
-
- keyword := this.GetString("keyword")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
-
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- var ids []int64
- var goodIds []int64
- infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
- for _, it := range infoList {
- goodIds = append(goodIds, it.GoodId)
- }
-
- manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
- for _, it := range manufacturers {
- ids = append(ids, it.ID)
- }
- manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
-
- list, total, err := service.GetPurchaseStockQueryList(good_type, keyword, page, limit, orgId, ids, goodIds)
- storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
- for _, item := range list {
-
- //获取期初结余
- low, _ := service.GetStartLastFLow(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
-
- item.GoodStartFlowInfo = low
-
- //获取期末结余
- flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime, storeConfig.StorehouseOutInfo)
-
- item.GoodEndFlowInfo = flow
-
- //获取期间增加
- goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range goodWarehouseInfoList {
- item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
- }
-
- //获取本期增加
- WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
-
- for _, it := range WarehouseInfoFlowList {
- item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
- }
- //获取本期减少
- reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range reduceWarehouseInfoList {
- item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
- }
-
- //获取期中减少退库
- lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range lowInfo {
- item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
- }
- //
- outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
- for _, it := range outInfo {
- item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
- }
-
- //期中盘盈
- profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range profit {
- item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
- }
- //期中盘亏
- losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
- for _, it := range losses {
- item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
- }
-
- //获取期初结余
- //service.GetNewOverInCount(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
- }
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "total": total,
- })
-
- }
-
- func (this *SelfDrugApiController) GetCheckDrugBatchList() {
-
- drug_id, _ := this.GetInt64("drug_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- advicelist, _ := service.GetHisAdviceGroupList(drug_id, orgId)
-
- outInfo, _ := service.GetDrugWarehousOutInfo(drug_id, orgId)
-
- outInfoOne, _ := service.GetDrugWarehousOutInfoOne(drug_id, orgId)
-
- baseDrugList, _ := service.GetDrugByGoodId(drug_id)
-
- drugflow, _ := service.GetCheckDrugFlow(drug_id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "advicelist": advicelist,
- "outInfo": outInfo,
- "outInfoOne": outInfoOne,
- "baseDrugList": baseDrugList,
- "drugflow": drugflow,
- })
- }
-
- func (this *SelfDrugApiController) GetCheckGoodBatchList() {
-
- id, _ := this.GetInt64("id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- projectList, _ := service.GetCheckGoodBatchList(id, orgId)
-
- warehouseList, _ := service.GetCheckGoodWarehouseList(id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "projectList": projectList,
- "warehouseList": warehouseList,
- })
- }
-
- func (this *SelfDrugApiController) GetDrugPatientName() {
-
- drug_id, _ := this.GetInt64("drug_id")
-
- sys_record_time, _ := this.GetInt64("sys_record_time")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- advicelist, _ := service.GetHisAdviceListBySysRrecordTime(drug_id, sys_record_time, orgId)
-
- outInfor, _ := service.GetDrugWarehouseOutInfoBySysRecordTime(drug_id, sys_record_time, orgId)
-
- patients, _ := service.GetAllpatient(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "advicelist": advicelist,
- "outInfor": outInfor,
- "patients": patients,
- })
-
- }
-
- func (this *SelfDrugApiController) GetAllSelfDrugInfoList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- drugInfoList, _ := service.GetAllSelfDrugInfoList(orgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
-
- dealerList, _ := service.GetAllDealerList(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "drugInfoList": drugInfoList,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (this *SelfDrugApiController) GetAllPatientList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- patient, _ := service.GetAllPatientListByUserOrg(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *SelfDrugApiController) PostSearchSelfDrugList() {
-
- keyword := this.GetString("keyword")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- drugList, _ := service.PostSearchSelfDrugList(keyword, orgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
-
- dealerList, _ := service.GetAllDealerList(orgId)
-
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "list": drugList,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (c *SelfDrugApiController) PostSelfDrugWarehouse() {
-
- patient_id, _ := c.GetInt64("patient_id")
- warehousing_time := c.GetString("warehousing_time")
- warehousing_id, _ := c.GetInt64("warehousing_id")
- adminUserInfo := c.GetAdminUserInfo()
-
- warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
-
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
-
- // 在函数结束时处理事务回滚
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindSelfAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
- total = total + 1
-
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
-
- warehousing := models.XtSelfDrugWarehouse{
- ID: warehousing_id,
- WarehousingOrder: warehousing_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Status: 1,
- WarehousingTime: warehousingDate.Unix(),
- Type: 0,
- StorehouseId: 0,
- IsCheck: 2,
- PatientId: patient_id,
- }
- if warehousing_id == 0 {
- service.AddSelfDrugWarehouse(&warehousing, tx)
- }
- if warehousing_id > 0 {
- service.UpdateSelfDrugWarehouse(&warehousing, tx)
- }
- info, _ := service.FindLastSelfWarehousing(adminUserInfo.CurrentOrgId, patient_id, tx)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var warehousingInfo []*models.XtSelfDrugWarehouseInfo
- if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["stockIn"].([]interface{})
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
-
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
- utils.ErrorLog("warehousing_count")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
-
- var productDates int64
- var expiryDates int64
-
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
- expiryDates = 0
- } else {
- if len(items["expiry_date"].(string)) == 0 {
- expiryDates = 0
-
- } else {
- expiryDate, _ := items["expiry_date"].(string)
- expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
- expiryDates = expiry_date.Unix()
-
- }
-
- }
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
- productDates = 0
- } else {
- if len(items["product_date"].(string)) == 0 {
- productDates = 0
-
- } else {
- productDate, _ := items["product_date"].(string)
- product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
- productDates = product_date.Unix()
- }
-
- }
-
- number, _ := items["number"].(string)
-
- batch_number, _ := items["batch_number"].(string)
-
- if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
- utils.ErrorLog("max_unit")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- max_unit, _ := items["max_unit"].(string)
-
- if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
- utils.ErrorLog("min_unit")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- min_unit, _ := items["min_unit"].(string)
-
- var remark string
- if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
- remark = ""
- } else {
- remark = items["remark"].(string)
- }
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- dealer := int64(items["dealer"].(float64))
-
- warehouseInfo := &models.XtSelfDrugWarehouseInfo{
- ID: id,
- WarehousingOrder: warehousing_order,
- WarehousingId: info.ID,
- DrugId: drug_id,
- Number: number,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- WarehousingCount: warehousing_count,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 0,
- Manufacturer: manufacturer,
- Dealer: dealer,
- StockMaxNumber: 0,
- RetailTotalPrice: 0,
- BatchNumber: batch_number,
- MaxUnit: max_unit,
- MinUnit: min_unit,
- RetailPrice: 0,
- StorehouseId: 0,
- IsCheck: 2,
- StockMinNumber: 0,
- PatientId: patient_id,
- IsSys: 0,
- RecordDate: warehousingDate.Unix(),
- }
- warehousingInfo = append(warehousingInfo, warehouseInfo)
- }
- }
- }
-
- for _, item := range warehousingInfo {
- if item.ID == 0 {
- service.CreatedSlefWarehouseing(item, tx)
- }
- if item.ID > 0 {
- service.UpdateSelfWarehouseing(item, tx)
- }
- }
-
- list, _ := service.FindSelfDrugWarehouseInfoListById(info.ID, adminUserInfo.CurrentOrgId, patient_id, tx)
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "warehousingInfo": warehousingInfo,
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- "info": info,
- })
-
- }
-
- func (c *SelfDrugApiController) GetAllSelfDrugWarehouseInfoList() {
-
- keyword := c.GetString("keyword")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- patient_id, _ := c.GetInt64("patient_id")
- baseList, _ := service.GetAllBaseDrugListByKeyWord(keyword, orgId)
- var ids []int64
- for _, item := range baseList {
- ids = append(ids, item.ID)
- }
- infoList, _ := service.GetAllSelfDrugWarehouseInfoList(ids, orgId, patient_id)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "infoList": infoList,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (c *SelfDrugApiController) GetSelfDrugWarehouseInfoByID() {
-
- id, _ := c.GetInt64("id")
- info, _ := service.GetSelfDrugWarehouseInfoByIDOne(id)
- warehouseInfo, _ := service.GetSelfDrugWarehouseInfo(id)
- orgId := c.GetAdminUserInfo().CurrentOrgId
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "info": info,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- "warehouseInfo": warehouseInfo,
- })
- }
-
- func (c *SelfDrugApiController) ModifySelfDrugWarehouse() {
-
- patient_id, _ := c.GetInt64("patient_id")
- warehousing_time := c.GetString("warehousing_time")
- warehousing_id, _ := c.GetInt64("warehousing_id")
- adminUserInfo := c.GetAdminUserInfo()
- warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
-
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
-
- // 在函数结束时处理事务回滚
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindSelfAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
- total = total + 1
-
- warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
-
- info, _ := service.FindLastSelfWarehousing(adminUserInfo.CurrentOrgId, patient_id, tx)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var warehousingInfo []*models.XtSelfDrugWarehouseInfo
- if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["stockIn"].([]interface{})
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
-
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
- utils.ErrorLog("warehousing_count")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
-
- var productDates int64
- var expiryDates int64
-
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
- expiryDates = 0
- } else {
- if len(items["expiry_date"].(string)) == 0 {
- expiryDates = 0
-
- } else {
- expiryDate, _ := items["expiry_date"].(string)
- expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
- expiryDates = expiry_date.Unix()
-
- }
-
- }
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
- productDates = 0
- } else {
- if len(items["product_date"].(string)) == 0 {
- productDates = 0
-
- } else {
- productDate, _ := items["product_date"].(string)
- product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
- productDates = product_date.Unix()
- }
-
- }
-
- number, _ := items["number"].(string)
-
- batch_number, _ := items["batch_number"].(string)
-
- if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
- utils.ErrorLog("max_unit")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- max_unit, _ := items["max_unit"].(string)
-
- if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
- utils.ErrorLog("min_unit")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- min_unit, _ := items["min_unit"].(string)
-
- var remark string
- if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
- remark = ""
- } else {
- remark = items["remark"].(string)
- }
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- dealer := int64(items["dealer"].(float64))
-
- warehouseInfo := &models.XtSelfDrugWarehouseInfo{
- ID: id,
- WarehousingOrder: warehousing_order,
- WarehousingId: warehousing_id,
- DrugId: drug_id,
- Number: number,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- WarehousingCount: warehousing_count,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 0,
- Manufacturer: manufacturer,
- Dealer: dealer,
- StockMaxNumber: 0,
- RetailTotalPrice: 0,
- BatchNumber: batch_number,
- MaxUnit: max_unit,
- MinUnit: min_unit,
- RetailPrice: 0,
- StorehouseId: 0,
- IsCheck: 2,
- StockMinNumber: 0,
- PatientId: patient_id,
- IsSys: 0,
- RecordDate: warehousingDate.Unix(),
- }
- warehousingInfo = append(warehousingInfo, warehouseInfo)
- }
- }
- }
-
- for _, item := range warehousingInfo {
- if item.ID == 0 {
- service.CreatedSlefWarehouseing(item, tx)
- }
- if item.ID > 0 {
- service.UpdateSelfWarehouseing(item, tx)
- }
- }
-
- list, _ := service.FindSelfDrugWarehouseInfoListById(warehousing_id, adminUserInfo.CurrentOrgId, patient_id, tx)
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "warehousingInfo": warehousingInfo,
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- "info": info,
- })
- }
-
- func (c *SelfDrugApiController) DeleteSelfDrugWarehouse() {
-
- id, _ := c.GetInt64("id")
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- service.DeleteSelfDrugWarehouse(id, tx)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
-
- func (c *SelfDrugApiController) TocheckSelfWarehouseingInfo() {
-
- id, _ := c.GetInt64("warehousing_id")
- patient_id, _ := c.GetInt64("patient_id")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- checker := c.GetAdminUserInfo().AdminUser.Id
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- //更改核对状态
- service.CheckSelfWarehousingInfo(id, orgId, checker, tx)
- info, _ := service.GetSelfWarehouseInfoByWarehouseInfo(id, patient_id, orgId, tx)
- if len(info) > 0 {
- for _, item := range info {
- medical, _ := service.GetSelfBaseDrugMedical(item.DrugId, tx)
-
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
-
- //新增库存
- service.AddSelfDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
-
- }
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
-
- //新增库存
- service.AddSelfDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
-
- }
-
- if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
-
- //新增库存
- service.AddSelfDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID, tx)
-
- }
-
- Creator := c.GetAdminUserInfo().AdminUser.Id
-
- //查询默认仓库剩余多少库存
- list, _ := service.GetDrugSumCountByPatient(patient_id, item.OrgId, item.DrugId, tx)
- var sum_count int64
- var sum_in_count int64
- for _, it := range list {
- baseDrug, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- if it.MaxUnit == baseDrug.MaxUnit {
- it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
- it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
- }
- sum_count += it.StockMaxNumber + it.StockMinNumber
- sum_in_count += it.WarehousingCount
- }
-
- flow := &models.XtSelfDrugFlow{
- WarehousingId: id,
- DrugId: item.DrugId,
- Number: item.Number,
- BatchNumber: item.BatchNumber,
- Count: item.WarehousingCount,
- UserOrgId: item.OrgId,
- PatientId: item.PatientId,
- SystemTime: time.Now().Unix(),
- ConsumableType: 1,
- IsSys: 0,
- WarehousingOrder: item.WarehousingOrder,
- WarehouseOutId: 0,
- WarehouseOutOrderNumber: "",
- IsEdit: 0,
- CancelStockId: 0,
- CancelOrderNumber: "",
- Manufacturer: item.Manufacturer,
- Dealer: item.Dealer,
- Creator: Creator,
- UpdateCreator: Creator,
- Status: 1,
- Ctime: item.Ctime,
- Mtime: 0,
- Price: item.Price,
- WarehousingDetailId: item.ID,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ExpireDate: item.ExpiryDate,
- ProductDate: item.ProductDate,
- MaxUnit: item.MaxUnit,
- MinUnit: item.MinUnit,
- StorehouseId: item.StorehouseId,
- OverCount: sum_count,
- OperateTime: time.Now().Unix(),
- }
- service.CreateSelfDrugFlow(flow, tx)
-
- drugInfolist, _ := service.GetSelfDrugSumCountByStorehouseId(item.PatientId, item.OrgId, item.DrugId, tx)
-
- var total_count int64 // 入库总数量
- var over_count int64 //剩余库存
- for _, it := range drugInfolist {
- baseDrug, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- if it.MaxUnit == baseDrug.MaxUnit {
- it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
- it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
- }
- }
- for _, it := range drugInfolist {
- total_count += it.WarehousingCount
- over_count += it.StockMaxNumber + it.StockMinNumber
- }
- //查询该仓库是否有默认数据
- selfDrugStock, _ := service.GetSelfDrugStockCount(item.PatientId, item.DrugId, item.OrgId, tx)
-
- if selfDrugStock.ID == 0 {
- drugStock := models.XtSelfDrugStockCount{
- UserOrgId: item.OrgId,
- PatientId: item.PatientId,
- SumInCount: total_count,
- SumOutCount: 0,
- SumCancelCount: 0,
- DrugId: item.DrugId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- FlushCount: over_count,
- SumActOutCount: 0,
- }
- service.CreateSelfDrugStockSum(drugStock, tx)
-
- }
- if selfDrugStock.ID > 0 {
- service.UpdateSelfDrugStockSum(item.PatientId, item.DrugId, item.OrgId, total_count, over_count, tx)
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": info,
- })
- }
- }
-
- func (c *SelfDrugApiController) GetSelfDrugBatchNumber() {
-
- id, _ := c.GetInt64("id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetSelfDrugBatchNumber(id, orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- patient_id, _ := c.GetInt64("patient_id")
- warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
-
- ctime := time.Now().Unix()
- adminUserInfo := c.GetAdminUserInfo()
-
- warehousing_out_time := c.GetString("warehousing_out_time")
-
- warehousingOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_out_time)
-
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", warehousingOutDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.CurrentOrgId, tx)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
-
- creater := adminUserInfo.AdminUser.Id
- //创建一个出库单
- warehouseOut := models.XtSelfDrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehouseOutTime: warehousingOutDate.Unix(),
- Type: 0,
- PatientId: patient_id,
- IsCheck: 2,
- }
-
- if warehouse_out_id == 0 {
- service.AddSelfSigleDrugWarehouseOut(&warehouseOut, tx)
- }
- if warehouse_out_id > 0 {
- service.UpdateSelfSingleDrugWarehouseOut(warehouse_out_id, patient_id, tx)
- }
- lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOut(adminUserInfo.CurrentOrgId, tx)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //出库单详情
- var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
- //把前端的参数加工为出库单详情
- if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["stockOut"].([]interface{})
-
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
-
- items := item.(map[string]interface{})
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
- utils.ErrorLog("count")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
-
- remark := items["remark"].(string)
- max_unit := items["max_unit"].(string)
- dealer := int64(items["dealer"].(float64))
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- batch_number := items["batch_number"].(string)
-
- warehouse_info_id := int64(items["warehouse_info_id"].(float64))
- var productDates int64
- var expiryDates int64
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
- expiryDates = 0
- } else {
- if len(items["expiry_date"].(string)) == 0 {
- expiryDates = 0
-
- } else {
- expiryDate, _ := items["expiry_date"].(string)
- expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
- expiryDates = expiry_date.Unix()
-
- }
-
- }
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
- productDates = 0
- } else {
- if len(items["product_date"].(string)) == 0 {
- productDates = 0
-
- } else {
- productDate, _ := items["product_date"].(string)
- product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
- productDates = product_date.Unix()
- }
- }
-
- stock_count, _ := items["stock_count"].(string)
-
- id := int64(items["id"].(float64))
-
- class_type, _ := items["class_type"].(string)
-
- warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
- ID: id,
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: lastWarehouseOut.ID,
- DrugId: drug_id,
- Count: count,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: warehousingOutDate.Unix(),
- Mtime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 0,
- Manufacturer: manufacturer,
- Dealer: dealer,
- RetailPrice: 0,
- RetailTotalPrice: 0,
- CountUnit: max_unit,
- ExpiryDate: expiryDates,
- ProductDate: productDates,
- Number: "",
- BatchNumber: batch_number,
- IsSys: 0,
- WarehouseInfoId: warehouse_info_id,
- AdminUserId: 0,
- StockCount: stock_count,
- IsCheck: 2,
- SysRecordTime: warehousingOutDate.Unix(),
- PatientId: patient_id,
- ClassType: class_type,
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- }
- }
- }
-
- //调用出库逻辑
- for _, item := range warehousingOutInfo {
- if item.ID == 0 {
- errOne := service.AddSelfSigleDrugWarehouseOutInfo(item, tx)
- fmt.Println(errOne)
- }
- if item.ID > 0 {
- service.UpdatedSelfDrugWarehouseInfo(item, item.ID, tx)
- }
-
- }
-
- list, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
-
- warehousingOutInfoList, _ := service.GetSelfDrugWarehouseOutListById(lastWarehouseOut.ID, adminUserInfo.CurrentOrgId, tx)
-
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug_name": "",
- "dose": "",
- "dose_unit": "",
- "min_number": "",
- "min_unit": "",
- "max_unit": "",
- "dealerList": list,
- "manufacturerList": manufacturerList,
- "warehousingOutInfo": warehousingOutInfoList,
- "warehouseOut": lastWarehouseOut,
- "drugTypeList": drugTypeList,
- })
- return
- }
-
- func (c *SelfDrugApiController) GetAllSelfDrugWarehouseOutList() {
-
- keyword := c.GetString("keyword")
-
- patient_id, _ := c.GetInt64("patient_id")
-
- start_time := c.GetString("start_time")
-
- end_time := c.GetString("end_time")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
- baseList, _ := service.GetAllBaseDrugListByKeyWord(keyword, orgId)
- var ids []int64
- for _, item := range baseList {
- ids = append(ids, item.ID)
- }
- outInfo, _ := service.GetAllSelfDrugWarehouseOutList(ids, patient_id, startTime, endTime, orgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "outInfo": outInfo,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- })
- }
-
- func (c *SelfDrugApiController) DeleteSelfWarehouseOut() {
-
- id, _ := c.GetInt64("id")
-
- service.DeleteSelfWarehouseOut(id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
-
- return
- }
-
- func (c *SelfDrugApiController) GetSelfDrugWarehouseOutById() {
-
- id, _ := c.GetInt64("id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- outInfo, _ := service.GetSelfDrugWarehouseOutById(id)
- outOne, _ := service.GetSelfDrugWarehouseOutOne(id)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- patients, _ := service.GetAllpatient(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "outInfo": outInfo,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- "patients": patients,
- "outOne": outOne,
- })
- }
-
- func (c *SelfDrugApiController) ModifySelfDrugWarehouseOut() {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- patient_id, _ := c.GetInt64("patient_id")
- fmt.Println("patinet_id=-------------------------------", patient_id)
- warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
- fmt.Println("patinet_id=-------------------------------", warehouse_out_id)
- ctime := time.Now().Unix()
- adminUserInfo := c.GetAdminUserInfo()
-
- lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutOne(adminUserInfo.CurrentOrgId, tx)
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //出库单详情
- var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
- //把前端的参数加工为出库单详情
- if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["stockOut"].([]interface{})
-
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
-
- items := item.(map[string]interface{})
-
- if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
- utils.ErrorLog("drug_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drug_id := int64(items["drug_id"].(float64))
-
- if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
- utils.ErrorLog("count")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
-
- remark := items["remark"].(string)
- max_unit := items["max_unit"].(string)
- dealer := int64(items["dealer"].(float64))
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- batch_number := items["batch_number"].(string)
-
- warehouse_info_id := int64(items["warehouse_info_id"].(float64))
- var productDates int64
- var expiryDates int64
- if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
- expiryDates = 0
- } else {
- if len(items["expiry_date"].(string)) == 0 {
- expiryDates = 0
-
- } else {
- expiryDate, _ := items["expiry_date"].(string)
- expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
- expiryDates = expiry_date.Unix()
-
- }
-
- }
- if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
- productDates = 0
- } else {
- if len(items["product_date"].(string)) == 0 {
- productDates = 0
-
- } else {
- productDate, _ := items["product_date"].(string)
- product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
- productDates = product_date.Unix()
- }
- }
-
- stock_count, _ := items["stock_count"].(string)
-
- id := int64(items["id"].(float64))
-
- class_type, _ := items["class_type"].(string)
-
- warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
- ID: id,
- WarehouseOutOrderNumber: lastWarehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: lastWarehouseOut.ID,
- DrugId: drug_id,
- Count: count,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: lastWarehouseOut.WarehouseOutTime,
- Mtime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 0,
- Manufacturer: manufacturer,
- Dealer: dealer,
- RetailPrice: 0,
- RetailTotalPrice: 0,
- CountUnit: max_unit,
- ExpiryDate: expiryDates,
- ProductDate: productDates,
- Number: "",
- BatchNumber: batch_number,
- IsSys: 0,
- WarehouseInfoId: warehouse_info_id,
- AdminUserId: 0,
- StockCount: stock_count,
- IsCheck: 2,
- SysRecordTime: lastWarehouseOut.WarehouseOutTime,
- PatientId: patient_id,
- ClassType: class_type,
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- }
- }
- }
-
- //调用出库逻辑
- for _, item := range warehousingOutInfo {
- if item.ID == 0 {
- errOne := service.AddSelfSigleDrugWarehouseOutInfo(item, tx)
- fmt.Println(errOne)
- }
- if item.ID > 0 {
- service.UpdatedSelfDrugWarehouseInfo(item, item.ID, tx)
- }
-
- }
-
- list, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
-
- warehousingOutInfoList, _ := service.GetSelfDrugWarehouseOutListById(warehouse_out_id, adminUserInfo.CurrentOrgId, tx)
-
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug_name": "",
- "dose": "",
- "dose_unit": "",
- "min_number": "",
- "min_unit": "",
- "max_unit": "",
- "dealerList": list,
- "manufacturerList": manufacturerList,
- "warehousingOutInfo": warehousingOutInfoList,
- "warehouseOut": lastWarehouseOut,
- "drugTypeList": drugTypeList,
- })
- return
- }
-
- func (c *SelfDrugApiController) GetSelfDrugQuery() {
-
- keyword := c.GetString("keyword")
- var goodIds []int64
- org_id := c.GetAdminUserInfo().CurrentOrgId
- drugList, _ := service.GetDrugNameBywordOne(org_id, keyword)
- orgId := c.GetAdminUserInfo().CurrentOrgId
- for _, it := range drugList {
- goodIds = append(goodIds, it.ID)
- }
- list, total, _ := service.GetSelfDrugQuery(orgId, goodIds)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, org_id)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drugTypeList": drugTypeList,
- })
- return
- }
-
- func (c *SelfDrugApiController) CheckSelfDrugOutQuery() {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
-
- //patient_id, _ := c.GetInt64("patient_id")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- warehousingOutInfoList, _ := service.GetSelfDrugWarehouseOutListByIdOne(warehouse_out_id, orgId, tx)
- drugWarehouseOut, _ := service.GetSelfDrugWarehouseOutByLastId(warehouse_out_id, tx)
-
- for _, it := range warehousingOutInfoList {
- var total_count int64
- var out_count int64
- //查询剩余库存
- stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
- drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
-
- for _, item := range stockInfo {
- if item.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
- item.StockMaxNumber = item.StockMaxNumber * drup.MinNumber
- }
-
- total_count += item.StockMaxNumber + item.StockMinNumber
- }
-
- //出库数量累加
- if it.CountUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
- out_count = it.Count * drup.MinNumber
- }
-
- if it.CountUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
- out_count = it.Count
- }
-
- if it.CountUnit == drup.MinUnit && drup.MaxUnit == drup.MinUnit {
- out_count = it.Count
- }
-
- if out_count > total_count {
- c.ServeSuccessJSON(map[string]interface{}{
- "warehousingOutInfoList": warehousingOutInfoList,
- "drug_name": drup.DrugName,
- "dose": drup.Dose,
- "dose_unit": drup.DoseUnit,
- "min_number": drup.MinNumber,
- "min_unit": drup.MinUnit,
- "max_unit": drup.MaxUnit,
- "msg": 2,
- })
- return
- }
- }
-
- warehousingOutInfoListThree, _ := service.GetSelfDrugWarehouseOutListByIdOne(warehouse_out_id, orgId, tx)
- for _, it := range warehousingOutInfoListThree {
- medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
- //出库逻辑
- service.AutoSelfDrugDeliverInfoFourtyThree(orgId, it.Count, &drugWarehouseOut, &drup, it, it.CountUnit, tx)
-
- //查询剩余库存
- stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
- }
-
- out := models.XtSelfDrugWarehouseOut{
- IsCheck: 1,
- }
- //更新审核状态
- service.UpdateSelfCheckDrugOut(out, warehouse_out_id, tx)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "warehousingOutInfoList": warehousingOutInfoList,
- "drug_name": "",
- "dose": "",
- "dose_unit": "",
- "min_number": "",
- "min_unit": "",
- "max_unit": "",
- "msg": 1,
- })
- }
-
- func (c *SelfDrugApiController) ReturnCheckSelfOutDrugQuery() {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
-
- warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
-
- out := models.XtSelfDrugWarehouseOut{
- IsCheck: 2,
- }
- service.UpdateSelfCheckDrugOut(out, warehouse_out_id, tx)
-
- outInfo := models.XtSelfDrugWarehouseOutInfo{
- IsCheck: 2,
- }
- service.UpdateSelfCheckDrugOutInfoList(outInfo, warehouse_out_id, tx)
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetSelfDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
-
- //调用出库逻辑
- for _, item := range list {
- medical, _ := service.GetSelfBaseDrugMedical(item.DrugId, tx)
- if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- service.UpdateSelfDrugMaxNumber(item.Count, item.WarehouseInfoId, tx)
- service.DeleteSelfDrugOutFlow(item.ID, item.OrgId, tx)
- drugInfoList, _ := service.FindSelfDrugWarehouseInfoList(item.DrugId, item.OrgId, tx)
- var drug_max_number int64
- var drug_min_number int64
- for _, item := range drugInfoList {
- drug_max_number += item.StockMaxNumber
- drug_min_number += item.StockMinNumber
- }
- }
- if item.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
- service.UpdateSelfDrugMaxNumber(item.Count, item.WarehouseInfoId, tx)
-
- service.DeleteSelfDrugOutFlow(item.ID, item.OrgId, tx)
- }
- if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
-
- service.UpdateSelfDrugMinNumber(item.Count, item.WarehouseInfoId, tx)
-
- service.DeleteSelfDrugOutFlow(item.ID, item.OrgId, tx)
- }
-
- //出库数量累加
- var out_count int64
- if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- out_count = item.Count * medical.MinNumber
- }
-
- if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- out_count = item.Count
- }
-
- if item.CountUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- out_count = item.Count
- }
- //增加出库数量
- service.ReduceSelfDrugCount(item.DrugId, item.OrgId, item.PatientId, out_count, tx)
-
- //查询该药品剩余库存
- infolist, _ := service.FindSelfDrugWarehouseInfoFlushCountByStorehouse(item.DrugId, item.OrgId, item.PatientId, tx)
- var over_count int64
- for _, its := range infolist {
- baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
-
- if its.MaxUnit == baseDrug.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
- }
- over_count += its.StockMaxNumber + its.StockMinNumber
- }
-
- service.UpdateSelfDrugStockCount(item.DrugId, item.OrgId, item.PatientId, over_count, tx)
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "out": out,
- })
- }
-
- func (c *SelfDrugApiController) ReturnSelfCheckWarehouse() {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
-
- warehousing_id, _ := c.GetInt64("warehousing_id")
- patient_id, _ := c.GetInt64("patient_id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetSelfWarehousingInfoByList(warehousing_id, orgId, tx)
- for _, item := range list {
- //查询该药品是否有出库数据
- outInfo, _ := service.GetSelfDrugWarehouseOutByWarehouseInfoId(item.ID, item.DrugId, item.OrgId, tx)
- if len(outInfo) > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCheckGoodParamWrong)
- return
- }
-
- }
- for _, item := range list {
- //删除流水
- service.UpdateSelfWarehousingInfoFlow(item.WarehousingId, orgId, tx)
- medical, _ := service.GetSelfBaseDrugMedical(item.DrugId, tx)
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- //新增库存
- service.AddSelfDrugReturnWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
- }
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
- //新增库存
- service.AddSelfDrugReturnWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
- }
- if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- //新增库存
- service.AddSelfDrugReturnWarehouseStockMinNumber(item.WarehousingCount, item.ID, tx)
- }
-
- var total_count int64
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- total_count = item.WarehousingCount * medical.MinNumber
- }
- if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- total_count = item.WarehousingCount
- }
- if item.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- total_count = item.WarehousingCount * medical.MinNumber
- }
- drugInfolist, _ := service.GetSelfDrugSumCountByStorehouseId(patient_id, item.OrgId, item.DrugId, tx)
- var over_count int64 //剩余库存
- for _, it := range drugInfolist {
- if it.MaxUnit == medical.MaxUnit {
- it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
- }
- }
- for _, it := range drugInfolist {
- over_count += it.StockMaxNumber*medical.MinNumber + it.StockMinNumber
- }
- //扣减库存
- service.ReduceSelfDrugStockCount(patient_id, item.DrugId, item.OrgId, total_count, over_count, tx)
-
- }
- //更新审核
- err := service.ReturnSelfCheckWarehouseingInfo(warehousing_id, orgId, tx)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "反审核成功!",
- })
- return
- }
- }
-
- func (c *SelfDrugApiController) GetSelfDrugFlow() {
-
- drug_id, _ := c.GetInt64("drug_id")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- list, total, _ := service.GetSelfDrugFlow(drug_id, startTime, endTime, orgId, page, limit, patient_id)
- drug, _ := service.GetSelfBasedrugByIdOne(drug_id, orgId)
- patients, _ := service.GetAllpatient(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "drug": drug,
- "patients": patients,
- })
- }
-
- func (c *SelfDrugApiController) GetSelfDrugBatchNumberList() {
-
- drug_id, _ := c.GetInt64("drug_id")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, total, _ := service.GetSelfDrugBatchNumberList(drug_id, startTime, endTime, orgId, page, limit, patient_id)
- drug, _ := service.GetSelfBasedrugByIdOne(drug_id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "drug": drug,
- })
- }
-
- func (c *SelfDrugApiController) GetAllSelfDrugWarehouse() {
-
- keyword := c.GetString("keyword")
-
- start_time := c.GetString("start_time")
-
- end_time := c.GetString("end_time")
-
- patient_id, _ := c.GetInt64("patient_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- check_type, _ := c.GetInt64("check_type")
-
- limit, _ := c.GetInt64("limit")
-
- page, _ := c.GetInt64("page")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- appId := c.GetAdminUserInfo().CurrentAppId
-
- list, total, _ := service.GetAllSelfDrugWarehouse(keyword, startTime, endTime, check_type, orgId, page, limit, patient_id)
-
- doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "doctorList": doctorList,
- })
- }
-
- func (c *SelfDrugApiController) DeleteSelfWarehouse() {
-
- id, _ := c.GetInt64("id")
-
- service.DeleteSelfWarehouse(id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "ok": "msg",
- })
- }
-
- func (c *SelfDrugApiController) GetAllSelfDrugWarehouseOut() {
-
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- keyword := c.GetString("keyword")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- appId := c.GetAdminUserInfo().CurrentAppId
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- check_type, _ := c.GetInt64("check_type")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, total, _ := service.GetAllSelfDrugWarehouseOut(startTime, endTime, orgId, page, limit, patient_id, keyword, check_type)
- fmt.Println("list==================", list)
- doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "doctorList": doctorList,
- })
-
- }
-
- func (c *SelfDrugApiController) DeleteSelfWarehouseOutList() {
-
- id, _ := c.GetInt64("id")
-
- service.DeleteSelfWarehouseOutList(id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "ok": "msg",
- })
- }
-
- func (c *SelfDrugApiController) GetSelfDrugWarehouseOutDetailByPatientId() {
-
- patient_id, _ := c.GetInt64("patient_id")
-
- page, _ := c.GetInt64("page")
-
- limit, _ := c.GetInt64("limit")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, total, _ := service.GetSelfDrugWarehouseOutDetailByPatientId(patient_id, page, limit, orgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (c *SelfDrugApiController) GetDrugInventoryRecordList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
- keyword := c.GetString("keyword")
- storehouse_id, _ := c.GetInt64("storehouse_id")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, total, _ := service.GetDrugInventoryRecordList(limit, page, keyword, storehouse_id, startTime, endTime, orgId)
-
- houseList, _ := service.GetAllStoreHouseList(orgId)
-
- appId := c.GetAdminUserInfo().CurrentAppId
- doclist, _ := service.GetAllDoctorListSix(orgId, appId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "houseList": houseList,
- "doclist": doclist,
- })
- }
-
- func (c *SelfDrugApiController) GetDrugInventoryRecordPrintList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
- keyword := c.GetString("keyword")
- storehouse_id, _ := c.GetInt64("storehouse_id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- ids := c.GetString("ids")
- idSplit := strings.Split(ids, ",")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, total, _ := service.GetDrugInventoryRecordPrintList(limit, page, keyword, storehouse_id, orgId, startTime, endTime, idSplit)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- appId := c.GetAdminUserInfo().CurrentAppId
- doclist, _ := service.GetAllDoctorListSix(orgId, appId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "houseList": houseList,
- "doclist": doclist,
- })
- }
-
- func (c *SelfDrugApiController) GetDrugInventoryModePrintList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetInventoryModeList(orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
-
- //查询本月入库
- infoList, _ := service.GetDrugWarehosueInfoList(orgId, startTime, endTime)
-
- //查询本月出库
- outList, _ := service.GetDrugWarhouseHouseOutInfo(orgId, startTime, endTime)
-
- //查询本月退库
- cancelOutInfo, _ := service.GetDrugWarehouseCancelOutInfo(orgId, startTime, endTime)
-
- drugList, _ := service.GetAllDrugList(orgId)
-
- warehouseInfoFlow, _ := service.GetDrugMonthWarehouseInfo(orgId, startTime)
-
- warehouseOutFlow, _ := service.GetDrugMonthWarehouseOutInfo(orgId, startTime)
-
- cancelFlow, _ := service.GetDrugMonthCancelOutInfo(orgId, startTime)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "outList": outList,
- "infoList": infoList,
- "drugList": drugList,
- "warehouseInfoFlow": warehouseInfoFlow,
- "warehouseOutFlow": warehouseOutFlow,
- "cancelFlow": cancelFlow,
- "cancelOutInfo": cancelOutInfo,
- })
- }
|