123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138 |
- package controllers
-
- import (
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "reflect"
- "strconv"
- "strings"
- "time"
- )
-
- type StockManagerApiController struct {
- BaseAuthAPIController
- }
-
- func StockManagerApiRegistRouters() {
-
- //入库管理和其他入库管理相关接口
- beego.Router("/api/warehouse/create", &StockManagerApiController{}, "post:CreateWarehouse")
- beego.Router("/api/warehouse/list", &StockManagerApiController{}, "get:GetWarehouseList")
- beego.Router("/api/warehouse/delete", &StockManagerApiController{}, "post:DeleteWarehouse")
- beego.Router("/api/warehouseinfo/delete", &StockManagerApiController{}, "post:DeleteWarehouseInfo")
- beego.Router("/api/warehouseinfo/list", &StockManagerApiController{}, "get:GetWarehouseInfoList")
- beego.Router("/api/warehouse/edit", &StockManagerApiController{}, "post:EditWarehouse")
-
- //退货管理和其他退货管理相关接口
- beego.Router("/api/salesreturn/create", &StockManagerApiController{}, "post:CreateSalesReturn")
- beego.Router("/api/salesreturn/delete", &StockManagerApiController{}, "post:DeleteSalesReturn")
- beego.Router("/api/salesreturninfo/delete", &StockManagerApiController{}, "post:DeleteSalesReturnInfo")
- beego.Router("/api/salesreturninfo/list", &StockManagerApiController{}, "get:GetSalesReturnInfoList")
- beego.Router("/api/salesreturn/list", &StockManagerApiController{}, "get:GetSalesReturnList")
- beego.Router("/api/salesreturn/edit", &StockManagerApiController{}, "post:EditReturnInfo")
-
- //出库管理和其他出库管理相关接口
- beego.Router("/api/warehouseout/create", &StockManagerApiController{}, "post:CreateWarehouseOut")
- beego.Router("/api/warehouseout/delete", &StockManagerApiController{}, "post:DeleteWarehouseOut")
- beego.Router("/api/warehouseoutinfo/delete", &StockManagerApiController{}, "post:DeleteWarehouseOutInfo")
- beego.Router("/api/warehouseout/list", &StockManagerApiController{}, "get:GetWarehouseOutList")
- beego.Router("/api/warehouseout/edit", &StockManagerApiController{}, "post:EditWarehouseOut")
- beego.Router("/api/warehouseout/info", &StockManagerApiController{}, "get:GetWarehouseOutInfoList")
-
- //出库退库管理和其他出库退库管理相关接口
- beego.Router("/api/cancelstock/create", &StockManagerApiController{}, "post:CreateCancelStock")
- beego.Router("/api/cancelstock/list", &StockManagerApiController{}, "get:GetCancelStockList")
- beego.Router("/api/cancelstock/info", &StockManagerApiController{}, "get:GetCancelStockInfoList")
- beego.Router("/api/cancelstock/delete", &StockManagerApiController{}, "post:DeleteCancelStock")
- beego.Router("/api/cancelstockinfo/delete", &StockManagerApiController{}, "post:DeleteCancelStockInfo")
- beego.Router("/api/cancelstockinfo/edit", &StockManagerApiController{}, "post:EditCancelStock")
- beego.Router("/api/cancelstockinfo/config", &StockManagerApiController{}, "get:GetCancelStockConfig")
-
- //库存相关全局配置
- beego.Router("/api/stock/config", &StockManagerApiController{}, "get:GetAllConfig")
- beego.Router("/api/return/config", &StockManagerApiController{}, "get:GetAllSalesReturnConfig")
-
- //库存查询
- beego.Router("/api/stock/query", &StockManagerApiController{}, "get:GetQueryInfo")
-
- beego.Router("/api/stock/detail", &StockManagerApiController{}, "get:GetDetailInfo")
-
- beego.Router("/api/warehouseout/user", &StockManagerApiController{}, "get:GetUserDetailInfo")
-
- beego.Router("/api/warehouseout/postsearchstock", &StockManagerApiController{}, "Get:PostSearchStock")
-
- beego.Router("/api/warehouseout/getoutstocktotalcount", &StockManagerApiController{}, "Get:GetOutStockTotalCount")
-
- beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
-
- beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
-
- beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
-
- beego.Router("/api/good/getwarehouseorderinfolist", &StockManagerApiController{}, "Get:GetWarehouseOrderInfolist")
-
- beego.Router("/api/good/postsearchgoodlist", &StockManagerApiController{}, "Get:PostSearchGoodList")
-
- beego.Router("/api/good/getallstocklist", &StockManagerApiController{}, "Get:GetAllStockList")
-
- beego.Router("/api/stock/getstocklistbyid", &StockManagerApiController{}, "Get:GetStockListById")
- beego.Router("/api/stock/getstockoutlist", &StockManagerApiController{}, "Get:GetStockOutList")
-
- beego.Router("/api/good/getstockdrugcount", &StockManagerApiController{}, "Get:GetStockDrugCount")
-
- beego.Router("/api/good/getorderdetialbyorderid", &StockManagerApiController{}, "Get:GetOrderDetialByOrderId")
- beego.Router("/api/good/getorderdetaibyid", &StockManagerApiController{}, "Get:GetOrderDetailById")
- beego.Router("/api/good/getsingleoutorderdetail", &StockManagerApiController{}, "Get:GetSingleOutOrderDetail")
- beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
- beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
- beego.Router("/api/stock/getsinglecancelorder", &StockManagerApiController{}, "Get:GetSingleCancelOrder")
- beego.Router("/api/stock/getcancelstockorderprint", &StockManagerApiController{}, "Get:GetCancelStockOrderPrint")
- beego.Router("/api/stock/getstockbatchnumber", &StockManagerApiController{}, "Get:GetStockBatchNumber")
-
- beego.Router("/api/stock/getstockflow", &StockManagerApiController{}, "Get:GetStockFlow")
-
- beego.Router("/api/cancel/getcancelexportlist", &StockManagerApiController{}, "Get:GetCancelExportList")
-
- //耗材调价
- beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
- beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
- beego.Router("/api/stock/getallstockprice", &StockManagerApiController{}, "Get:GetAllStockPrice")
- beego.Router("/api/stock/savecheckedprice", &StockManagerApiController{}, "Get:SaveCheckPrice")
- beego.Router("/api/stock/getadjustpriceinfo", &StockManagerApiController{}, "Get:GetAdjustPriceById")
- beego.Router("/api/stock/savereportstock", &StockManagerApiController{}, "Post:SaveReportStock")
- beego.Router("/api/stock/getreportstocklist", &StockManagerApiController{}, "Get:GetReportStockList")
- beego.Router("/api/stock/savecheckdamage", &StockManagerApiController{}, "Get:SaveCheckDamage")
- beego.Router("/api/stock/saveinventory", &StockManagerApiController{}, "Post:SaveInventory")
- beego.Router("/api/stock/getinventorylist", &StockManagerApiController{}, "Get:GetInventorylist")
- beego.Router("/api/stock/savecheckinventory", &StockManagerApiController{}, "Get:SaveCheckInventory")
- beego.Router("/api/stock/getmodifypriceDetail", &StockManagerApiController{}, "Get:GetModifyPriceDetail")
- beego.Router("/api/stock/updatestockprice", &StockManagerApiController{}, "Get:UpdateStockPrice")
- beego.Router("/api/stock/deletestockprice", &StockManagerApiController{}, "Get:DeleteStockPrice")
- beego.Router("/api/stock/getstockdamagedetal", &StockManagerApiController{}, "Get:GetStockDamageDetail")
- beego.Router("/api/sotck/modifyprice", &StockManagerApiController{}, "Get:ModifyPrice")
- beego.Router("/api/stock/deletestockdamage", &StockManagerApiController{}, "Get:DeleteDamage")
- beego.Router("/api/stock/getstockdamagebyid", &StockManagerApiController{}, "Get:GetStockDamageById")
- beego.Router("api/sotck/getinventorydetail", &StockManagerApiController{}, "Get:GetInventoryDetail")
- beego.Router("/api/stock/modifyinventory", &StockManagerApiController{}, "Get:ModifyInventory")
- beego.Router("/api/stock/deleteinventory", &StockManagerApiController{}, "Get:DeleteInventory")
- beego.Router("/api/stock/getinventorydetaillist", &StockManagerApiController{}, "Get:GetInventoryDetailList")
- beego.Router("/api/stock/getinventoryprintlist", &StockManagerApiController{}, "Get:GetInventoryPrintList")
- beego.Router("/api/stock/getinventorydetailprintlist", &StockManagerApiController{}, "Get:GetInventoryDetailPrintList")
- beego.Router("/api/drug/deletedrugprice", &StockManagerApiController{}, "Get:DeleteDrugPrice")
- beego.Router("/api/stock/getgoodwarehouselist", &StockManagerApiController{}, "Get:GetGoodWarehouseList")
- beego.Router("/api/stock/proofinventory", &StockManagerApiController{}, "Get:ProofInventory")
- beego.Router("/api/stock/getwarehousetotal", &StockManagerApiController{}, "Get:GetWarehouseTotal")
-
- }
-
- func (c *StockManagerApiController) CreateWarehouse() {
-
- warehousing_time := c.GetString("warehousing_time")
-
- types, _ := c.GetInt64("type", 0)
-
- ctime := time.Now().Unix()
- 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
- }
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
- total = total + 1
- warehousing_order := "RKD" + 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.Warehousing{
- WarehousingOrder: warehousing_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehousingTime: warehousingDate.Unix(),
- Type: types,
- }
- service.AddSigleWarehouse(&warehousing)
- 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.WarehousingInfo
-
- var stockFlow []*models.VmStockFlow
- 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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_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)
-
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
- total := float64(warehousing_count) * price
-
- 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)
-
- remark, _ := items["remark"].(string)
-
- manufacturer := int64(items["manufacturer"].(float64))
- dealer := int64(items["dealer"].(float64))
-
- license_number, _ := items["license_number"].(string)
- //入库单表格
- warehouseInfo := &models.WarehousingInfo{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehousing.ID,
- GoodId: good_id,
- Number: number,
- GoodTypeId: good_type_id,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- WarehousingCount: warehousing_count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer,
- StockCount: warehousing_count,
- Dealer: dealer,
- LicenseNumber: license_number,
- }
- warehousingInfo = append(warehousingInfo, warehouseInfo)
-
- flow := &models.VmStockFlow{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehousing.ID,
- GoodId: good_id,
- Number: number,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- Count: warehousing_count,
- Price: price,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: manufacturer,
- Dealer: dealer,
- LicenseNumber: license_number,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- SystemTime: operation_time,
- ConsumableType: 1,
- WarehousingDetailId: warehouseInfo.ID,
- }
- stockFlow = append(stockFlow, flow)
- }
- }
- }
-
- //入库单创建成功
- errs := service.CreateWarehousingInfo(warehousingInfo)
-
- //创建入库单流水
- service.CreateStockFlow(stockFlow)
-
- info, _ := service.FindLastWarehousingInfo(warehousing.WarehousingOrder)
-
- for _, item := range warehousingInfo {
- goodInfo, _ := service.GetGoodInformationByGoodId(item.GoodId)
- str := strconv.FormatInt(item.WarehousingCount, 10)
- minFloat, _ := strconv.ParseFloat(str, 64)
-
- good := models.GoodInfo{
- Total: minFloat + goodInfo.Total,
- }
- //更该库存
- parseDateErr := service.UpdateGoodInfoList(good, goodInfo.ID)
- break
- fmt.Println(parseDateErr)
- }
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "入库成功",
- "warehousing_order": warehousing_order,
- "info": info,
- })
-
- }
- func (c *StockManagerApiController) GetWarehouseList() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- types, _ := c.GetInt64("type", 0)
- keywords := c.GetString("keywords")
- 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()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- var ids []int64
- var goodids []int64
- //查询商品名称
- if len(keywords) > 0 {
- //查询商品名称
- list, _ := service.GetGoodInforByGoodName(keywords, adminUserInfo.CurrentOrgId)
- for _, item := range list {
- goodids = append(goodids, item.ID)
- //入库详情但里面查询
- }
- if len(goodids) > 0 {
- info, _ := service.GetWarehoureOrderInfoByGoodId(goodids, startTime, endTime, adminUserInfo.CurrentOrgId)
- for _, it := range info {
- ids = append(ids, it.WarehousingId)
- }
- }
- }
-
- warehouseList, total, err := service.FindAllWarehousingList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": warehouseList,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *StockManagerApiController) GetWarehouseInfoList() {
-
- id := c.GetString("id")
- idArray := strings.Split(id, ",")
- warehousing, err := service.FindWarehousingByIdOne(idArray)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- var ids []int64
-
- for _, item := range warehousing {
- ids = append(ids, item.ID)
- }
-
- warehousingInfo, err := service.FindWarehousingInfoByIdOne(ids)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "info": warehousingInfo,
- "warehousing": warehousing,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *StockManagerApiController) EditWarehouse() {
- warehousing_time := c.GetString("warehousing_time")
- id, _ := c.GetInt64("id", 0)
- types, _ := c.GetInt64("type", 0)
-
- if id == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- ctime := time.Now().Unix()
- mtime := time.Now().Unix()
- 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
- }
-
- warehouse, _ := service.FindWarehousingById(id)
-
- warehousing := models.Warehousing{
- WarehousingOrder: warehouse.WarehousingOrder,
- OrgId: adminUserInfo.CurrentOrgId,
- Modifier: adminUserInfo.AdminUser.Id,
- Mtime: mtime,
- Status: 1,
- WarehousingTime: warehousingDate.Unix(),
- Type: warehouse.Type,
- }
-
- service.EditWarehousing(warehousing)
-
- 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.WarehousingInfo
- var upDateWarehousingInfo []*models.WarehousingInfo
- var stockFlow []*models.VmStockFlow
-
- 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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_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)
-
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
- total := float64(warehousing_count) * price
-
- 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)
-
- remark, _ := items["remark"].(string)
-
- manufacturer := int64(items["manufacturer"].(float64))
- dealer := int64(items["dealer"].(float64))
- license_number, _ := items["license_number"].(string)
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if id == 0 {
- warehouseInfo := &models.WarehousingInfo{
- WarehousingOrder: warehouse.WarehousingOrder,
- WarehousingId: warehouse.ID,
- GoodId: good_id,
- Number: number,
- GoodTypeId: good_type_id,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- WarehousingCount: warehousing_count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer,
- Dealer: dealer,
- StockCount: warehousing_count,
- LicenseNumber: license_number,
- }
- warehousingInfo = append(warehousingInfo, warehouseInfo)
-
- flow := &models.VmStockFlow{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehousing.ID,
- GoodId: good_id,
- Number: number,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- Count: warehousing_count,
- Price: price,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: manufacturer,
- Dealer: dealer,
- LicenseNumber: license_number,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- SystemTime: ctime,
- ConsumableType: 1,
- WarehousingDetailId: warehouseInfo.ID,
- }
-
- stockFlow = append(stockFlow, flow)
-
- } else {
- fmt.Println("id23233232323232323232323223", id)
- warehouseInfo := &models.WarehousingInfo{
- ID: id,
- WarehousingOrder: warehouse.WarehousingOrder,
- WarehousingId: warehouse.ID,
- GoodId: good_id,
- Number: number,
- GoodTypeId: good_type_id,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- WarehousingCount: warehousing_count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer,
- Dealer: dealer,
- LicenseNumber: license_number,
- }
- upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
-
- flow := &models.VmStockFlow{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: id,
- GoodId: good_id,
- Number: number,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- Count: warehousing_count,
- Price: price,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: manufacturer,
- Dealer: dealer,
- LicenseNumber: license_number,
- IsEdit: 2,
- Creator: adminUserInfo.AdminUser.Id,
- SystemTime: ctime,
- ConsumableType: 1,
- WarehousingDetailId: warehouseInfo.ID,
- }
-
- stockFlow = append(stockFlow, flow)
- }
- }
- }
- }
- var errs error
- if len(warehousingInfo) > 0 {
- errs = service.CreateWarehousingInfo(warehousingInfo)
- service.CreateStockFlow(stockFlow)
- }
-
- if len(upDateWarehousingInfo) > 0 {
-
- for _, item := range upDateWarehousingInfo {
-
- var total int64
- var all_total int64
- //获取该批次该型号的库存
- info, _ := service.GetLastWarehousingByIdOne(item.ID, item.GoodId)
- fmt.Println("oooooooooo", info.WarehousingCount)
- //判断 该批次的入库数量
- total = item.WarehousingCount - info.WarehousingCount
- fmt.Println("total232323322332232332", total)
- all_total = info.StockCount + total
-
- item.StockCount = all_total
- fmt.Println("hhhhhhhhhhhhh", item.StockCount)
-
- errs = service.UpDateWarehousingInfo(item)
- }
- }
-
- if len(stockFlow) > 0 {
- for _, item := range stockFlow {
- flow := models.VmStockFlow{
- Count: item.Count,
- }
- parseDateErr := service.UpdateStockFlow(flow, item.GoodId, item.WarehousingId)
- fmt.Println(parseDateErr)
- }
- }
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "编辑成功",
- })
-
- }
- func (c *StockManagerApiController) DeleteWarehouse() {
- ids := c.GetString("ids")
-
- if len(ids) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idArray := strings.Split(ids, ",")
- err := service.DeleteWarehouse(idArray)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
- }
- func (c *StockManagerApiController) DeleteWarehouseInfo() {
- id, _ := c.GetInt64("id", 0)
-
- if id == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err := service.UpDateWarehouseStatus(id)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
-
- }
-
- func (c *StockManagerApiController) CreateSalesReturn() {
- dealer_id, _ := c.GetInt64("dealer_id", 0)
- manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
- sales_return_time := c.GetString("time")
- types, _ := c.GetInt64("type", 0)
-
- salesReturnDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", sales_return_time)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", salesReturnDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
- ctime := time.Now().Unix()
-
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllSalesReturnTotal(adminUserInfo.CurrentOrgId)
- total = total + 1
- orderNumber := "THD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
-
- salesReturn := models.SalesReturn{
- OrderNumber: orderNumber,
- OperaTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- ReturnTime: salesReturnDate.Unix(),
- Dealer: dealer_id,
- Manufacturer: manufacturer_id,
- Type: types,
- }
-
- service.AddSigleSalesReturn(&salesReturn)
-
- 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 salesReturnInfos []*models.SalesReturnInfo
-
- if dataBody["salesReturn"] != nil && reflect.TypeOf(dataBody["salesReturn"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["salesReturn"].([]interface{})
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
-
- if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_id"].(float64))
- return_count, _ := items["return_count"].(string)
- if len(return_count) == 0 {
- utils.ErrorLog("len(return_count) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
-
- return
- }
-
- count, _ := strconv.ParseInt(return_count, 10, 64)
- price, _ := strconv.ParseFloat(items["price"].(string), 10)
- total := float64(count) * price
-
- salesReturnInfo := &models.SalesReturnInfo{
- OrderNumber: salesReturn.OrderNumber,
- SalesReturnId: salesReturn.ID,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Price: price,
- Total: total,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- }
-
- salesReturnInfos = append(salesReturnInfos, salesReturnInfo)
-
- }
- }
- }
- errs := service.CreateSalesReturnInfo(salesReturnInfos)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退货成功",
- })
-
- }
- func (c *StockManagerApiController) GetSalesReturnList() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- types, _ := c.GetInt64("type", 0)
- keywords := c.GetString("keywords")
-
- 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 {
- 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()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- returnList, total, err := service.FindAllReturnList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": returnList,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (this *StockManagerApiController) DeleteSalesReturn() {
- ids := this.GetString("ids")
-
- if len(ids) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idArray := strings.Split(ids, ",")
- err := service.DeleteSalesReturn(idArray)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
- }
- func (this *StockManagerApiController) DeleteSalesReturnInfo() {
- id, _ := this.GetInt64("id", 0)
- fmt.Println(id)
- if id == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err := service.UpDateSaleReturnStatus(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
-
- }
- func (this *StockManagerApiController) GetSalesReturnInfoList() {
- id, _ := this.GetInt64("id", 0)
- list, _ := service.FindAllSalesReturnInfoById(id)
- salesReturn, _ := service.FindAllSalesReturnById(id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "salesReturn": salesReturn,
- })
-
- }
- func (c *StockManagerApiController) EditReturnInfo() {
- return_time := c.GetString("return_time")
- id, _ := c.GetInt64("id", 0)
- types, _ := c.GetInt64("type", 0)
- manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
- dealer_id, _ := c.GetInt64("dealer_id", 0)
-
- if id == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- ctime := time.Now().Unix()
- mtime := time.Now().Unix()
- adminUserInfo := c.GetAdminUserInfo()
-
- returnDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", return_time)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", returnDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- salesReturns, _ := service.FindSalesReturnById(id)
-
- sales := models.SalesReturn{
- ID: salesReturns.ID,
- Mtime: mtime,
- ReturnTime: returnDate.Unix(),
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- }
-
- service.EditSaleReturn(sales)
-
- 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 returnInfos []*models.SalesReturnInfo
- var upDateReturnInfos []*models.SalesReturnInfo
-
- if dataBody["salesReturn"] != nil && reflect.TypeOf(dataBody["salesReturn"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["salesReturn"].([]interface{})
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
-
- if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_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)
-
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if id == 0 {
- returnInfo := &models.SalesReturnInfo{
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- OrderNumber: sales.OrderNumber,
- SalesReturnId: sales.ID,
- Mtime: time.Now().Unix(),
- Type: types,
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- }
- returnInfos = append(returnInfos, returnInfo)
-
- } else {
- returnInfo := &models.SalesReturnInfo{
- ID: id,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- OrderNumber: sales.OrderNumber,
- SalesReturnId: sales.ID,
- Mtime: time.Now().Unix(),
- Type: types,
- Manufacturer: manufacturer_id,
- Dealer: dealer_id,
- }
- upDateReturnInfos = append(upDateReturnInfos, returnInfo)
- }
- }
- }
- }
- var errs error
- if len(returnInfos) > 0 {
- errs = service.CreateSalesReturnInfo(returnInfos)
- }
-
- if len(upDateReturnInfos) > 0 {
- for _, item := range upDateReturnInfos {
- errs = service.UpDateSalesReturnInfo(item)
- }
- }
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "编辑成功",
- })
-
- }
-
- func (c *StockManagerApiController) CreateWarehouseOut() {
-
- types, _ := c.GetInt64("type", 0)
-
- 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.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)
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- warehouseOut := models.WarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehouseOutTime: warehousingOutDate.Unix(),
- Type: types,
- }
-
- 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.WarehouseOutInfo
- var beforePrepares []*models.DialysisBeforePrepareGoods
- var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
-
- 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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_id"].(float64))
-
- if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
- utils.ErrorLog("count")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
-
- count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
-
- total := float64(count) * price
- remark := items["remark"].(string)
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- dealer := int64(items["dealer"].(float64))
- number := items["number"].(string)
-
- expiry_date := items["expiry_date"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var expiryDate int64
- if len(expiry_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiryDate = theTime.Unix()
- }
-
- product_date := items["product_date"].(string)
-
- var productDate int64
- if len(product_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- productDate = theTime.Unix()
- }
- license_number := items["license_number"].(string)
- warehouseOutInfo := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer,
- Number: number,
- ExpiryDate: expiryDate,
- ProductDate: productDate,
- Dealer: dealer,
- LicenseNumber: license_number,
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- prepareGoods := &models.DialysisBeforePrepareGoods{
- GoodTypeId: good_type_id,
- GoodId: good_id,
- Count: count,
- }
-
- beforePrepares = append(beforePrepares, prepareGoods)
-
- newPrepareGoods := &models.NewDialysisBeforePrepareGoods{
- GoodTypeId: good_type_id,
- GoodId: good_id,
- Count: count,
- }
- newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
- }
- }
- }
-
- //出库逻辑
- for _, item := range warehousingOutInfo {
- //查询库存
- warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
- fmt.Println("库存数量组吗", warehouse.Count)
- if item.Count > warehouse.Count {
- goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "good_name": goodObj.GoodName,
- "specification_name": goodObj.SpecificationName,
- })
- return
- } else {
-
- _, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
- if errcodes == gorm.ErrRecordNotFound {
- service.AddSigleWarehouseOut(&warehouseOut)
- }
- parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count, creater)
- if parseDateErr != nil {
- utils.ErrorLog(parseDateErr.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "good_name": "",
- "specification_name": "",
- })
- }
-
- }
-
- //errs := service.CreateWarehousingOutInfo(warehousingOutInfo)
- //info, _ := service.FindLastWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
-
- }
- func (c *StockManagerApiController) GetWarehouseOutList() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- types, _ := c.GetInt64("type", 0)
- keywords := c.GetString("keywords")
-
- 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 {
- 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()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- var ids []int64
- var goodids []int64
- if len(keywords) > 0 {
- //查询商品名称
- list, _ := service.GetGoodInforByGoodName(keywords, adminUserInfo.CurrentOrgId)
- for _, item := range list {
- goodids = append(goodids, item.ID)
- }
-
- if len(goodids) > 0 {
- //出库详情但里面查询
- info, _ := service.GetWarehoureOrderOutByGoodId(goodids, startTime, endTime, adminUserInfo.CurrentOrgId)
- for _, it := range info {
- ids = append(ids, it.WarehouseOutId)
- }
- }
-
- }
- warehouseOutList, total, err := service.FindAllWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids)
- fmt.Println(err)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": warehouseOutList,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *StockManagerApiController) DeleteWarehouseOut() {
- ids := c.GetString("ids")
-
- if len(ids) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idArray := strings.Split(ids, ",")
- err := service.DeleteWarehouseOut(idArray)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
- }
- func (this *StockManagerApiController) DeleteWarehouseOutInfo() {
- id, _ := this.GetInt64("id", 0)
- fmt.Println(id)
- if id == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err := service.UpDateWarehouseOutStatus(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
-
- }
- func (c *StockManagerApiController) GetWarehouseOutInfoList() {
- id, _ := c.GetInt64("id", 0)
- warehouseOutInfo, _ := service.FindWarehouseOutInfoById(id)
- warehouseOut, _ := service.FindWareHouseOutById(id)
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- wareoutList, _ := service.GetWareOutInfoById(id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": warehouseOutInfo,
- "info": warehouseOut,
- "wareoutList": wareoutList,
- })
-
- }
- func (c *StockManagerApiController) EditWarehouseOut() {
- warehouse_out_time := c.GetString("warehouse_out_time")
-
- id, _ := c.GetInt64("id", 0)
- types, _ := c.GetInt64("type", 0)
-
- if id == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- ctime := time.Now().Unix()
- mtime := time.Now().Unix()
- adminUserInfo := c.GetAdminUserInfo()
-
- warehouseOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehouse_out_time)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", warehouseOutDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- warehouseOut, _ := service.FindWareHouseOutById(id)
-
- tempWarehouseOut := models.WarehouseOut{
- ID: warehouseOut.ID,
- Mtime: mtime,
- WarehouseOutTime: warehouseOutDate.Unix(),
- }
-
- service.EditWarehouseOut(tempWarehouseOut)
-
- 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.WarehouseOutInfo
- var upDateWarehouseOutInfos []*models.WarehouseOutInfo
-
- if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
- thisStockOut, _ := dataBody["stockOut"].([]interface{})
- if len(thisStockOut) > 0 {
- for _, item := range thisStockOut {
- items := item.(map[string]interface{})
-
- if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_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)
-
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
-
- total := float64(count) * price
- remark := items["remark"].(string)
-
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- manufacturer := int64(items["manufacturer"].(float64))
-
- dealer := int64(items["dealer"].(float64))
-
- number := items["number"].(string)
-
- license_number := items["license_number"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- expiry_date := items["expiry_date"].(string)
-
- var expiryDate int64
- if len(expiry_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- expiryDate = theTime.Unix()
- }
-
- product_date := items["product_date"].(string)
-
- warehouse_info_id := int64(items["warehouse_info_id"].(float64))
-
- var productDate int64
- if len(product_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- productDate = theTime.Unix()
- }
-
- if id == 0 {
- warehouseOutInfo := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- IsSys: 0,
- SysRecordTime: 0,
- Number: number,
- ExpiryDate: expiryDate,
- ProductDate: productDate,
- Dealer: dealer,
- Manufacturer: manufacturer,
- LicenseNumber: license_number,
- ConsumableType: 1,
- WarehouseInfotId: warehouse_info_id,
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- } else {
- if items["is_sys"] == nil || reflect.TypeOf(items["is_sys"]).String() != "float64" {
- utils.ErrorLog("is_sys")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- is_sys := int64(items["is_sys"].(float64))
-
- if items["sys_record_time"] == nil || reflect.TypeOf(items["sys_record_time"]).String() != "float64" {
- utils.ErrorLog("sys_record_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- sys_record_time := int64(items["sys_record_time"].(float64))
-
- warehouseOutInfo := &models.WarehouseOutInfo{
- ID: id,
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Price: price,
- TotalPrice: total,
- Status: 1,
- Ctime: ctime,
- Remark: remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Mtime: time.Now().Unix(),
- Type: types,
- Manufacturer: manufacturer,
- IsSys: is_sys,
- SysRecordTime: sys_record_time,
- Number: number,
- ExpiryDate: expiryDate,
- ProductDate: productDate,
- Dealer: dealer,
- LicenseNumber: license_number,
- ConsumableType: 2,
- WarehouseInfotId: warehouse_info_id,
- }
- upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
- }
- }
- }
- }
- var errs error
- if len(warehousingOutInfo) > 0 {
-
- errs = service.CreateWarehousingOutInfo(warehousingOutInfo)
- }
-
- if len(upDateWarehouseOutInfos) > 0 {
- for _, item := range upDateWarehouseOutInfos {
-
- //1.查询该耗材该批次的最后一次出库记录
- lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, adminUserInfo.CurrentOrgId)
- fmt.Println("lastGood", lastGood.Count)
- fmt.Println("item2323232", item.Count)
-
- // 退库的库存和该耗材该批次最后一次出库数量进行比较
- //如果退库数量大于 最后一次批次的数量(要么要进行出库)
-
- if item.Count > lastGood.Count {
-
- //查询该耗材是否还有库存
- warehouseinfo, _ := service.GetTotalCountByGoodId(item.GoodId)
- fmt.Println("hhhhhh23h2323232", warehouseinfo.StockCount)
- //无库存
- if warehouseinfo.StockCount <= 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "5",
- })
- return
- }
-
- //有库存,进行出库,调用出库接口
- if warehouseinfo.StockCount > 0 {
- var total int64
- var stock_cout int64
- var total_count int64
- //计算和最后一次出库数据的差
- total = item.Count - lastGood.Count
- fmt.Println("total22323232", total)
- //获取该耗材该批次的剩余库存量
- info, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
- fmt.Println("info2232323232323", info)
- //判断该批次的剩余库存 和出库的库存进行比较
- //如果出库的库存大于该批次的剩余库存,那么需要出库下一批次的库存
-
- if item.Count > info.StockCount {
- //计算出库和该批次相差的库存
- total_count = item.Count - info.StockCount
- //清空本批次次库存
- service.DeleteWarehouseInfo(item.WarehouseInfotId)
- //调用出库逻辑
- service.ConsumablesDeliveryTwo(item.OrgId, item, total_count)
- }
- //如果出库的库存小于或等于于该批次的剩余库存,那么需要该批次出库
- if item.Count <= info.StockCount {
- stock_cout = lastGood.Count + total
- fmt.Println("232323223232323232323232", stock_cout)
- //扣减库存
- warehouse := models.WarehousingInfo{
- StockCount: info.StockCount - total,
- }
- errs := service.UpdateWarehousingInfo(warehouse, info.ID)
-
- warehouseOutInfo := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: id,
- WarehouseInfotId: item.WarehouseInfotId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Remark: item.Remark,
- OrgId: item.OrgId,
- Type: 1,
- Manufacturer: item.Manufacturer,
- Dealer: item.Dealer,
- IsSys: 0,
- SysRecordTime: item.SysRecordTime,
- GoodTypeId: item.GoodTypeId,
- GoodId: item.GoodId,
- ExpiryDate: item.ExpiryDate,
- ProductDate: item.ProductDate,
- Number: item.Number,
- Price: item.Price,
- LicenseNumber: item.LicenseNumber,
- Count: item.Count,
- ConsumableType: 2,
- }
-
- //查询是否存在
- _, errcode := service.GetWarehouseOutInfoIsExist(item.ID)
- if errcode == gorm.ErrRecordNotFound {
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
- if errOne != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- } else if errcode == nil {
- service.UpDateWarehouseOutInfo(item)
- }
-
- }
- }
- }
-
- var last_count int64
- var all_total int64
- var stock_total int64
- //如果退库数量小于最后一次批次的数量(要么要进行退库)
- if item.Count < lastGood.Count {
- fmt.Println("hh232323h2h3hh23hh23hh2h3h23")
- //退库数量和最后一次出库数据进行计算
- last_count = lastGood.Count - item.Count
- fmt.Println("last_count", last_count)
- //获取该耗材该批次的剩余库存量
- infoInfo, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
-
- //退库数量和最后一次出库数据进行计算的差 加上 剩余库存的数量与 该批次的入库数量进行比较
- all_total = last_count + infoInfo.StockCount
- fmt.Println("all_total", all_total)
- //如果库存大于总数量,则退回到这个批次
- fmt.Println("inf232323", infoInfo.WarehousingCount)
-
- if infoInfo.WarehousingCount > all_total {
- stock_total = last_count + infoInfo.StockCount
- fmt.Println("经历323232323232232", last_count, stock_total)
- //退回该批次,计算数量
- warehousingInfoOne := models.WarehousingInfo{
- StockCount: stock_total,
- ID: item.WarehouseInfotId,
- OrgId: item.OrgId,
- }
- fmt.Println("********************", warehousingInfoOne, item.WarehouseInfotId)
- parseDateErr := service.UpdateWarehousingInfo(warehousingInfoOne, item.WarehouseInfotId)
- fmt.Println("parseDateErr2323232322323", parseDateErr)
- //插入一条新纪录
- warehouseOutInfoThree := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
- WarehouseOutId: id,
- WarehouseInfotId: item.WarehouseInfotId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Remark: item.Remark,
- OrgId: item.OrgId,
- Type: 1,
- Manufacturer: item.Manufacturer,
- Dealer: item.Dealer,
- IsSys: 0,
- GoodTypeId: item.GoodTypeId,
- GoodId: item.GoodId,
- ExpiryDate: item.ExpiryDate,
- ProductDate: item.ProductDate,
- Number: item.Number,
- Price: item.Price,
- LicenseNumber: item.LicenseNumber,
- ConsumableType: 2,
- Count: item.Count,
- }
- //查询是否存在
- _, errcode := service.GetWarehouseOutInfoIsExist(item.ID)
- if errcode == gorm.ErrRecordNotFound {
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfoThree)
- if errOne != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- } else if errcode == nil {
- service.UpDateWarehouseOutInfo(item)
- }
- }
-
- //如果库存小于总数量,则报错提醒,该批次的退库数据大于入库数据了无法退库,则需要退库到另一个批次
- if infoInfo.WarehousingCount < all_total {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "6",
- })
- return
- }
- }
-
- if item.Count == lastGood.Count {
- errs = service.UpDateWarehouseOutInfo(item)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- }
-
- }
- }
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
-
- }
-
- func (c *StockManagerApiController) CreateCancelStock() {
-
- cancel_stock_time := c.GetString("time")
- types, _ := c.GetInt64("type", 0)
-
- cancelStockDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", cancel_stock_time)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", cancelStockDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- ctime := time.Now().Unix()
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllCancelStockTotal(adminUserInfo.CurrentOrgId)
- total = total + 1
- orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
-
- cancelStock := models.CancelStock{
- OrderNumber: orderNumber,
- OperaTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- ReturnTime: cancelStockDate.Unix(),
- Type: types,
- }
- service.AddSigleCancelStock(&cancelStock)
- 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 cancelStockInfos []*models.CancelStockInfo
- var stockFLow []*models.VmStockFlow
- if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
- thisStockIn, _ := dataBody["cancelStock"].([]interface{})
- if len(thisStockIn) > 0 {
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
-
- if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_id"].(float64))
-
- return_count, _ := items["return_count"].(string)
- if len(return_count) == 0 {
- utils.ErrorLog("len(return_count) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
-
- return
- }
-
- count, _ := strconv.ParseInt(return_count, 10, 64)
-
- number := items["number"].(string)
-
- register_account := items["register_account"].(string)
-
- manufacturer, _ := items["manufacturer"].(string)
-
- dealer, _ := items["dealer"].(string)
-
- warehouse_info_id := int64(items["warehouse_info_id"].(float64))
-
- 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()
-
- }
- }
-
- var productDates int64
- 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()
-
- }
- }
-
- remark := items["remark"].(string)
-
- retail_prices := items["price"].(string)
- price, _ := strconv.ParseFloat(retail_prices, 64)
- cancelStockInfo := &models.CancelStockInfo{
- OrderNumber: cancelStock.OrderNumber,
- CancelStockId: cancelStock.ID,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: types,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Number: number,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- RegisterAccount: register_account,
- Remark: remark,
- Price: price,
- WarehouseInfoId: warehouse_info_id,
- }
- cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
-
- flow := &models.VmStockFlow{
- WarehousingId: 0,
- GoodId: good_id,
- Number: number,
- LicenseNumber: "",
- Count: count,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: 0,
- SystemTime: time.Now().Unix(),
- ConsumableType: 4,
- IsSys: 0,
- WarehousingOrder: "",
- WarehouseOutId: 0,
- WarehouseOutOrderNumber: "",
- IsEdit: 0,
- CancelStockId: cancelStock.ID,
- CancelOrderNumber: cancelStock.OrderNumber,
- Manufacturer: 0,
- Dealer: 0,
- Creator: adminUserInfo.AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: price,
- WarehousingDetailId: 0,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- }
- stockFLow = append(stockFLow, flow)
- }
- }
- }
-
- for _, item := range cancelStockInfos {
-
- ////查找该耗材是否有出库记录
- //_, errcode := service.GetWarehoureOutOrderInfo(item.GoodId, item.OrgId)
- //if errcode == gorm.ErrRecordNotFound {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "1",
- // })
- // return
- //}
-
- //统计该耗材的出库数量
- info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
- fmt.Println("2333223323322332233223322323", item.Count, info.Count)
- if item.Count > info.Count {
- service.UpdateCancelInfo(item.CancelStockId)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- })
- return
- }
-
- //查询该批次入库的值
- infolist, _ := service.GetWarehouseInfoByIdSeven(item.WarehouseInfoId)
-
- if item.Count > infolist.WarehousingCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "4",
- })
- return
- }
-
- if item.Count <= infolist.WarehousingCount {
-
- errs := service.CreateCancelStockInfo(cancelStockInfos)
- if len(stockFLow) > 0 {
- service.CreateStockFlow(stockFLow)
- }
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
- return
- }
-
- //查询该批次的剩余库存
- wareouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
- if (wareouseinfo.StockCount + item.Count) > wareouseinfo.WarehousingCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "5",
- })
- return
- }
- //更改入库数量
- errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
-
- //查询该耗材的入库记录
- //list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
- ////调用退库的方法
- //parseDateErr := service.UpdateCancelOut(list, item.Count)
- //fmt.Println("999999999999", parseDateErr)
- break
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- })
- return
-
- }
- func (c *StockManagerApiController) GetCancelStockInfoList() {
- id, _ := c.GetInt64("id", 0)
-
- cancelStockInfoList, _ := service.FindCancelStockInfoById(id)
- info, _ := service.FindCancelStockById(id, c.GetAdminUserInfo().CurrentOrgId)
- manufacturerList, _ := service.GetAllManufacturerList(c.GetAdminUserInfo().CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(c.GetAdminUserInfo().CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": cancelStockInfoList,
- "info": info,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
-
- }
- func (c *StockManagerApiController) GetCancelStockList() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- types, _ := c.GetInt64("type", 0)
- keywords := c.GetString("keywords")
-
- 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 {
- 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()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- returnList, total, err := service.FindAllCancelList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": returnList,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (this *StockManagerApiController) DeleteCancelStock() {
- ids := this.GetString("ids")
-
- if len(ids) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idArray := strings.Split(ids, ",")
- err := service.DeleteCancelStock(idArray)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
- }
- func (this *StockManagerApiController) DeleteCancelStockInfo() {
- id, _ := this.GetInt64("id", 0)
- fmt.Println(id)
- if id == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err := service.UpDateCancleStockStatus(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
-
- }
- func (c *StockManagerApiController) EditCancelStock() {
- cancel_time := c.GetString("cancel_time")
- id, _ := c.GetInt64("id", 0)
-
- if id == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- ctime := time.Now().Unix()
- mtime := time.Now().Unix()
- adminUserInfo := c.GetAdminUserInfo()
-
- cancelDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", cancel_time)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", cancelDate, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- cancelStock, _ := service.FindCancelStockById(id, c.GetAdminUserInfo().CurrentOrgId)
-
- tempCancelStock := models.CancelStock{
- ID: cancelStock.ID,
- Mtime: mtime,
- ReturnTime: cancelDate.Unix(),
- }
-
- service.EditCancelStock(tempCancelStock)
-
- 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 cancelStockInfos []*models.CancelStockInfo
- var upDateCancelStockInfos []*models.CancelStockInfo
- var stockFlow []*models.VmStockFlow
- if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
- thisCancelStock, _ := dataBody["cancelStock"].([]interface{})
- if len(thisCancelStock) > 0 {
- for _, item := range thisCancelStock {
- items := item.(map[string]interface{})
-
- if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_id"].(float64))
-
- if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
- utils.ErrorLog("good_type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_type_id := int64(items["good_type_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)
-
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
- number := items["number"].(string)
-
- register_account := items["register_account"].(string)
-
- manufacturer, _ := items["manufacturer"].(string)
-
- dealer, _ := items["dealer"].(string)
-
- remark := items["remark"].(string)
-
- var productDates int64
- 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()
-
- }
-
- }
- 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["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
- if id == 0 {
- cancelStockInfo := &models.CancelStockInfo{
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- OrderNumber: cancelStock.OrderNumber,
- CancelStockId: cancelStock.ID,
- Mtime: time.Now().Unix(),
- Number: number,
- RegisterAccount: register_account,
- Manufacturer: manufacturer,
- Dealer: dealer,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- Remark: remark,
- Price: price,
- }
- cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
-
- flow := &models.VmStockFlow{
- WarehousingId: 0,
- GoodId: good_id,
- Number: number,
- LicenseNumber: "",
- Count: count,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: 0,
- SystemTime: time.Now().Unix(),
- ConsumableType: 4,
- IsSys: 0,
- WarehousingOrder: "",
- WarehouseOutId: 0,
- WarehouseOutOrderNumber: "",
- IsEdit: 2,
- CancelStockId: cancelStock.ID,
- CancelOrderNumber: cancelStock.OrderNumber,
- Manufacturer: 0,
- Dealer: 0,
- Creator: adminUserInfo.AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: price,
- WarehousingDetailId: 0,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- }
-
- stockFlow = append(stockFlow, flow)
-
- } else {
- cancelStockInfo := &models.CancelStockInfo{
- ID: id,
- GoodId: good_id,
- GoodTypeId: good_type_id,
- Count: count,
- Status: 1,
- Ctime: ctime,
- OrgId: adminUserInfo.CurrentOrgId,
- OrderNumber: cancelStock.OrderNumber,
- CancelStockId: cancelStock.ID,
- Mtime: time.Now().Unix(),
- Number: number,
- RegisterAccount: register_account,
- Manufacturer: manufacturer,
- Dealer: dealer,
- ProductDate: productDates,
- ExpiryDate: expiryDates,
- Remark: remark,
- Price: price,
- }
- upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
-
- flow := &models.VmStockFlow{
- WarehousingId: 0,
- GoodId: good_id,
- Number: number,
- LicenseNumber: "",
- Count: count,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: 0,
- SystemTime: time.Now().Unix(),
- ConsumableType: 4,
- IsSys: 0,
- WarehousingOrder: "",
- WarehouseOutId: 0,
- WarehouseOutOrderNumber: "",
- IsEdit: 2,
- CancelStockId: cancelStock.ID,
- CancelOrderNumber: cancelStock.OrderNumber,
- Manufacturer: 0,
- Dealer: 0,
- Creator: adminUserInfo.AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: price,
- WarehousingDetailId: 0,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ProductDate: productDates,
- ExpireDate: expiryDates,
- }
-
- stockFlow = append(stockFlow, flow)
- }
- }
- }
- }
- var errs error
- fmt.Println("出库22322333223", cancelStockInfos)
- fmt.Println("更新23232323232323233", upDateCancelStockInfos)
- if len(cancelStockInfos) > 0 {
-
- for _, item := range cancelStockInfos {
- //统计该耗材的出库数量
- info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
- if item.Count > info.Count {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- })
- return
- }
- //查询该批次入库的值
- infolist, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
-
- if item.Count > infolist.WarehousingCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "4",
- })
- return
- }
-
- if item.Count <= infolist.WarehousingCount {
-
- errs := service.CreateCancelStockInfo(cancelStockInfos)
- if len(stockFlow) > 0 {
- service.CreateStockFlow(stockFlow)
- }
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
- return
- }
-
- //更改入库数量
- errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
-
- break
- }
-
- }
- }
-
- if len(upDateCancelStockInfos) > 0 {
- for _, item := range upDateCancelStockInfos {
-
- //获取该批次最后一套出库记录
- info, _ := service.GetLastCancelInfo(item.WarehouseInfoId, item.GoodId)
- fmt.Println("info232332322332233223", info.Count, item.Count)
- //比较出库数量和最后一次出库数据大小
- //退库(加)
- if item.Count < info.Count {
- var total = info.Count - item.Count
- errs = service.UpDateCancelStockInfo(item)
-
- service.CreateStockFlow(stockFlow)
- warehouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
- if (warehouseinfo.StockCount + total) > warehouseinfo.StockCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "5",
- })
- return
- }
- parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total)
- if parseDateErr != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- break
- }
- }
- //(减)
- if item.Count > info.Count {
- errs = service.UpDateCancelStockInfo(item)
- service.CreateStockFlow(stockFlow)
- //查询该批次入库的值
- infolist, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
- if item.Count > infolist.WarehousingCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "4",
- })
- return
- }
- if item.Count <= infolist.WarehousingCount {
- var total_count = info.Count - item.Count
-
- parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total_count)
- if parseDateErr != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
- }
- }
- }
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- })
- }
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- })
-
- }
- func (this *StockManagerApiController) GetCancelStockConfig() {
- types, _ := this.GetInt64("type", 0)
- adminUserInfo := this.GetAdminUserInfo()
- warehouseOutInfoList, _ := service.FindAllWarehouseOutInfo(adminUserInfo.CurrentOrgId, types)
- this.ServeSuccessJSON(map[string]interface{}{
- "warehouseOutInfoList": warehouseOutInfoList,
- })
- }
-
- func (c *StockManagerApiController) GetQueryInfo() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- keyword := c.GetString("keyword")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- type_name, _ := c.GetInt64("type_name")
- 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()
- }
- adminUserInfo := c.GetAdminUserInfo()
- list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, startTime, endTime, type_name)
- info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
-
- infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId, "")
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "info": info,
- "infomationList": infomationList,
- "orgid": adminUserInfo.CurrentOrgId,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *StockManagerApiController) SearchWarehouse() {
- keywords := c.GetString("keywords")
- adminUserInfo := c.GetAdminUserInfo()
- warehouseList, total, err := service.FindAllWarehouseByKeyword(adminUserInfo.CurrentOrgId, 1, 10, keywords)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": warehouseList,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *StockManagerApiController) GetAllConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- manufacturer, _ := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
- dealer, _ := service.FindAllDealer(adminUserInfo.CurrentOrgId)
- goodType, _ := service.FindAllGoodType(adminUserInfo.CurrentOrgId)
- goodInfo, _ := service.FindAllGoodInfo(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturer,
- "dealer": dealer,
- "goodType": goodType,
- "goodInfo": goodInfo,
- })
- }
- func (this *StockManagerApiController) GetAllSalesReturnConfig() {
- types, _ := this.GetInt64("type", 0)
- adminUserInfo := this.GetAdminUserInfo()
- warehouseInfoList, _ := service.FindAllWarehouseInfo(adminUserInfo.CurrentOrgId, types)
- this.ServeSuccessJSON(map[string]interface{}{
- "warehouseInfoList": warehouseInfoList,
- })
- }
-
- func (this *StockManagerApiController) GetDetailInfo() {
-
- page, _ := this.GetInt64("page", 0)
- limit, _ := this.GetInt64("limit", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- types, _ := this.GetInt64("type", 0)
-
- keywords := this.GetString("keywords")
- manufacturer, _ := this.GetInt64("manufacturer", 0)
- order_type, _ := this.GetInt64("order_type", 0)
- dealer, _ := this.GetInt64("dealer", 0)
-
- 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()
- }
-
- adminUserInfo := this.GetAdminUserInfo()
-
- var list []*models.WarehousingInfo
- var list1 []*models.WarehouseOutInfo
- var list2 []*models.SalesReturnInfo
- var list3 []*models.CancelStockInfo
-
- var total int64
- var err error
- var total_price float64
-
- if types == 1 {
- list, total, err = service.FindStockInDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
- _, total_price = service.GetStockInDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "total_price": total_price,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- } else if types == 2 {
- list1, total, err = service.FindStockOutDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
- _, total_price = service.GetStockOutDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list1,
- "total": total,
- "total_price": total_price,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- } else if types == 3 {
- list2, total, err = service.FindSalesReturnDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list2,
- "total": total,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- } else if types == 4 {
- list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list3,
- "total": total,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- }
-
- func (this *StockManagerApiController) GetUserDetailInfo() {
- order_id, _ := this.GetInt64("id")
- if order_id <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := this.GetAdminUserInfo()
- userDetails, err, total := service.FindUserDetailById(adminUserInfo.CurrentOrgId, order_id)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": userDetails,
- "total": total,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (this *StockManagerApiController) PostSearchStock() {
-
- keyword := this.GetString("keyword")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- stock, err := service.PostSearchStock(keyword, orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "stock": stock,
- })
- }
-
- func (this *StockManagerApiController) GetOutStockTotalCount() {
-
- warehouseOutTime, _ := this.GetInt64("warehouse_out_time")
- adminUserInfo := this.GetAdminUserInfo()
- stockCount, err := service.GetOutStockTotalCount(warehouseOutTime, adminUserInfo.CurrentOrgId)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "stockCount": stockCount,
- })
- }
-
- func (this *StockManagerApiController) AddGoodInformation() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
- var goods []*models.GoodInfo
- var total_goods []interface{}
- tempGoods := dataBody["goods"].([]interface{})
-
- total_goods = tempGoods
- for index, goodMap := range tempGoods {
- goodNameM := goodMap.(map[string]interface{})
-
- var good models.GoodInfo
-
- if goodNameM["good_name"] == nil || reflect.TypeOf(goodNameM["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- return
- }
-
- good_name, _ := goodNameM["good_name"].(string)
- if len(good_name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的耗材名称不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- good.GoodName = good_name
-
- // 获取数据字典数据
- var good_kind_id int64
- var name = "耗材种类"
- config, _ := service.GetDrugDataConfig(0, name)
-
- good_kind := goodNameM["good_kind"].(string)
-
- if len(good_kind) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的耗材种类不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- if len(good_kind) != 0 {
- _, errcodegoodkind := service.IsExistDicConfig(config.ID, good_kind, orgId)
- lastConfig, _ := service.GetLastDicConfig(config.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: config.ID,
- Module: "system",
- OrgId: orgId,
- Name: good_kind,
- FieldName: "",
- Value: lastConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUserInfo.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- if errcodegoodkind == gorm.ErrRecordNotFound {
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- dataConfig, _ := service.GetParentDataConfig(config.ID, orgId)
- for _, it := range dataConfig {
- if good_kind == it.Name {
- fmt.Println(it.Name)
- good_kind_id = int64(it.Value)
- }
- }
- good.GoodKind = good_kind_id
-
- good_type := goodNameM["type_name"].(string)
- if len(good_type) == 0 {
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的耗材类型不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- if len(good_type) != 0 {
- _, errcodegoodtype := service.GetGoodType(good_type, orgId)
- if errcodegoodtype == gorm.ErrRecordNotFound {
- goodsType := models.GoodsType{
- TypeName: good_type,
- Remark: "",
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Creater: adminUserInfo.AdminUser.Id,
- Modifier: 0,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Type: 0,
- Number: 0,
- OutStock: 0,
- StockAttribute: 1,
- }
- service.CreatedGoodType(&goodsType)
- }
- }
-
- goodType, _ := service.GetAllGoodType(orgId)
- var good_type_id int64
- for _, it := range goodType {
- if good_type == it.TypeName {
- good_type_id = it.ID
- }
- }
- good.GoodTypeId = good_type_id
-
- medical_insurance_level := goodNameM["medical_insurance_level"].(string)
- if len(medical_insurance_level) <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的医保等级不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- var medical_insurance_id int64
- var medicalInsurance = "医保等级"
- medicalInsuranceDataConfig, _ := service.GetDrugDataConfig(0, medicalInsurance)
-
- if len(medical_insurance_level) != 0 {
- _, errcodemedicalInsurance := service.IsExistDicConfig(medicalInsuranceDataConfig.ID, medical_insurance_level, orgId)
- if errcodemedicalInsurance == gorm.ErrRecordNotFound {
- mediConfigOne, _ := service.GetLastDicConfig(medicalInsuranceDataConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: medicalInsuranceDataConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: medical_insurance_level,
- FieldName: "",
- Value: mediConfigOne.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUserInfo.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- medicalInsuranceList, _ := service.GetParentDataConfig(medicalInsuranceDataConfig.ID, orgId)
- for _, it := range medicalInsuranceList {
- if medical_insurance_level == it.Name {
- medical_insurance_id = int64(it.Value)
- }
- }
- good.MedicalInsuranceLevel = medical_insurance_id
-
- if goodNameM["specification_name"] == nil || reflect.TypeOf(goodNameM["specification_name"]).String() != "string" {
- utils.ErrorLog("specification_name")
- return
- }
- specification_name := goodNameM["specification_name"].(string)
- if len(specification_name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "规格型号不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- good.SpecificationName = specification_name
-
- var manufacturer_id int64
- manufacturer := goodNameM["manufacturer"].(string)
- if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的生产厂商不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- if len(manufacturer) != 0 {
- _, errcodes := service.GetManufacturerName(orgId, manufacturer)
- manu := models.Manufacturer{
- ManufacturerName: manufacturer,
- Status: 1,
- OrgId: orgId,
- Creater: adminUserInfo.AdminUser.Id,
- }
- if errcodes == gorm.ErrRecordNotFound {
-
- service.CreateManufacturer(&manu)
-
- }
- }
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- for _, it := range manufacturerList {
- if manufacturer == it.ManufacturerName {
- manufacturer_id = it.ID
- }
- }
-
- good.Manufacturer = manufacturer_id
-
- if goodNameM["unit_id"] == nil || reflect.TypeOf(goodNameM["unit_id"]).String() != "float64" {
- utils.ErrorLog("unit_id")
- return
- }
-
- unit_id := int64(goodNameM["unit_id"].(float64))
- if unit_id <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- good.GoodUnit = unit_id
-
- retail_prices := goodNameM["retail_price"].(string)
- retail_price, _ := strconv.ParseFloat(retail_prices, 64)
- if retail_price <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的价格不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- good.RetailPrice = retail_price
-
- if goodNameM["stock_warn_count"] == nil || reflect.TypeOf(goodNameM["stock_warn_count"]).String() != "float64" {
- utils.ErrorLog("stock_warn_count")
- return
- }
-
- stock_warn_count := int64(goodNameM["stock_warn_count"].(float64))
- if stock_warn_count <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的库存警戒不能为空或内容与系统不匹配",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- good.StockWarnCount = stock_warn_count
-
- var dealer_id int64
- dealerName := goodNameM["dealer"].(string)
-
- fmt.Println("经销商", dealerName)
- dealer := models.Dealer{
- OrgId: orgId,
- Status: 1,
- DealerName: dealerName,
- Creater: adminUserInfo.AdminUser.Id,
- Ctime: time.Now().Unix(),
- }
- if len(dealerName) != 0 {
- _, errcodedealer := service.GetDealerByName(orgId, dealerName)
-
- if errcodedealer == gorm.ErrRecordNotFound {
- service.CreateDealer(&dealer)
- }
- }
-
- dealerList, _ := service.GetAllDealerList(orgId)
- for _, it := range dealerList {
- if dealerName == it.DealerName {
- dealer_id = it.ID
- }
- }
-
- good.Dealer = dealer_id
- if goodNameM["pinyin"] == nil || reflect.TypeOf(goodNameM["pinyin"]).String() != "string" {
- utils.ErrorLog("pinyin")
- return
- }
- pinyin := goodNameM["pinyin"].(string)
-
- good.Pinyin = pinyin
-
- if goodNameM["wubi"] == nil || reflect.TypeOf(goodNameM["wubi"]).String() != "string" {
- utils.ErrorLog("wubi")
- return
- }
- wubi := goodNameM["wubi"].(string)
-
- good.Wubi = wubi
-
- buy_prices := goodNameM["buy_price"].(string)
- buy_price, _ := strconv.ParseFloat(buy_prices, 64)
- good.BuyPrice = buy_price
-
- if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
- utils.ErrorLog("social_security_directory_code")
- return
- }
- social_security_directory_code := goodNameM["social_security_directory_code"].(string)
-
- good.SocialSecurityDirectoryCode = social_security_directory_code
-
- if goodNameM["is_special_diseases"] == nil || reflect.TypeOf(goodNameM["is_special_diseases"]).String() != "float64" {
- utils.ErrorLog("is_special_diseases")
- return
- }
-
- is_special_diseases := int64(goodNameM["is_special_diseases"].(float64))
- good.IsSpecialDiseases = is_special_diseases
-
- if goodNameM["is_record"] == nil || reflect.TypeOf(goodNameM["is_record"]).String() != "float64" {
- utils.ErrorLog("is_record")
- return
- }
-
- is_record := int64(goodNameM["is_record"].(float64))
- good.IsRecord = is_record
-
- if goodNameM["good_status"] == nil || reflect.TypeOf(goodNameM["good_status"]).String() != "string" {
- utils.ErrorLog("good_status")
- return
- }
- good_status := goodNameM["good_status"].(string)
- good.GoodStatus = good_status
-
- if goodNameM["medical_insurance_number"] == nil || reflect.TypeOf(goodNameM["medical_insurance_number"]).String() != "string" {
- utils.ErrorLog("medical_insurance_number")
- return
- }
- medical_insurance_number := goodNameM["medical_insurance_number"].(string)
- good.MedicalInsuranceNumber = medical_insurance_number
-
- if goodNameM["production_type"] == nil || reflect.TypeOf(goodNameM["production_type"]).String() != "string" {
- utils.ErrorLog("production_type")
- return
- }
- production_type := goodNameM["production_type"].(string)
- good.ProductionType = production_type
-
- if goodNameM["remark"] == nil || reflect.TypeOf(goodNameM["remark"]).String() != "string" {
- utils.ErrorLog("remark")
- return
- }
- remark := goodNameM["remark"].(string)
- good.Remark = remark
-
- statistics_category := goodNameM["statistics_category"].(string)
-
- var categoryName = "统计分类"
- var statistic_id int64
- drugDataConfig, _ := service.GetDrugDataConfig(0, categoryName)
-
- if len(statistics_category) != 0 {
- _, errcodecagegory := service.IsExistDicConfig(drugDataConfig.ID, statistics_category, orgId)
-
- if errcodecagegory == gorm.ErrRecordNotFound {
- dicConfigThree, _ := service.GetLastDicConfig(drugDataConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: drugDataConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: statistics_category,
- FieldName: "",
- Value: dicConfigThree.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUserInfo.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- parentDataConfig, _ := service.GetParentDataConfig(drugDataConfig.ID, orgId)
-
- for _, it := range parentDataConfig {
- if statistics_category == it.Name {
- statistic_id = int64(it.Value)
- }
- }
-
- good.StatisticsCategory = statistic_id
-
- special_medical := goodNameM["special_medical"].(string)
- good.SpecialMedical = special_medical
- goods = append(goods, &good)
-
- }
-
- export_time := time.Now().Unix()
- errLogs, _ := service.FindPatientExportLogTwo(this.GetAdminUserInfo().CurrentOrgId, export_time)
- if len(goods) > 0 {
-
- for _, item := range goods {
-
- goodInfo := models.GoodInfo{
- GoodName: item.GoodName,
- SpecificationName: item.SpecificationName,
- GoodKind: item.GoodKind,
- GoodTypeId: item.GoodTypeId,
- Dealer: item.Dealer,
- GoodUnit: item.GoodUnit,
- IsRecord: item.IsRecord,
- IsSpecialDiseases: item.IsSpecialDiseases,
- Manufacturer: item.Manufacturer,
- Pinyin: item.Pinyin,
- GoodStatus: item.GoodStatus,
- ProductionType: item.ProductionType,
- Remark: item.Remark,
- RetailPrice: item.RetailPrice,
- SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
- SpecialMedical: item.SpecialMedical,
- Wubi: item.Wubi,
- StockWarnCount: item.StockWarnCount,
- MedicalInsuranceLevel: item.MedicalInsuranceLevel,
- OrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- StatisticsCategory: item.StatisticsCategory,
- GoodCode: item.GoodCode,
- BuyPrice: item.BuyPrice,
- MedicalInsuranceNumber: item.MedicalInsuranceNumber,
- }
-
- //查询同种耗材名称同种类型同种规格的耗材是否存在
- _, errcodegood := service.GetGoodsInformaitonIsExist(item.GoodName, item.GoodTypeId, item.SpecificationName, orgId)
-
- if errcodegood == gorm.ErrRecordNotFound {
- service.CreateGoodsInfomation(&goodInfo)
- } else if errcodegood == nil {
- service.UpdateGoodsInformation(&goodInfo, item.GoodName, item.GoodTypeId, item.SpecificationName, orgId)
- }
-
- log := models.ExportLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(goods)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(goods),
- "fail_num": int64(len(errLogs)),
- })
- }
- } else {
- log := models.ExportLog{
- LogType: 5,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(goods)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(goods),
- "fail_num": int64(len(errLogs)),
- })
- }
- }
-
- func (this *StockManagerApiController) AddDrugInformation() {
- adminUser := this.GetAdminUserInfo()
- orgId := adminUser.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
- var drugList []*models.BaseDrugLib
- var total_goods []interface{}
- tempDrugs := dataBody["drugs"].([]interface{})
-
- total_goods = tempDrugs
- for index, drugMap := range tempDrugs {
-
- goodNameM := drugMap.(map[string]interface{})
- var drug models.BaseDrugLib
- if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- return
- }
-
- drug_name, _ := goodNameM["drug_name"].(string)
- if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的药品名称不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.DrugName = drug_name
-
- if goodNameM["min_number"] == nil || reflect.TypeOf(goodNameM["min_number"]).String() != "string" {
- utils.ErrorLog("min_number")
- return
- }
-
- min_number, _ := goodNameM["min_number"].(string)
- minNumber, _ := strconv.ParseInt(min_number, 10, 64)
- if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的拆零不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.MinNumber = minNumber
-
- min_unit := goodNameM["min_unit"].(string)
- if len(min_unit) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的拆零单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.MinUnit = min_unit
-
- dose := goodNameM["dose"].(float64)
- if dose < 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.Dose = dose
-
- max_unit_id := goodNameM["max_unit"].(string)
- if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的剂量单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.MaxUnit = max_unit_id
-
- max_unit := goodNameM["max_unit"].(string)
- if len(max_unit) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的包装单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.MaxUnit = max_unit
-
- delivery_way := goodNameM["delivery_way"].(string)
- if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.DeliveryWay = delivery_way
-
- execution_frequency := goodNameM["execution_frequency"].(string)
- if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.ExecutionFrequency = execution_frequency
-
- drug_day := goodNameM["drug_day"].(string)
- if len(drug_day) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.DrugDay = drug_day
-
- drug_type := goodNameM["drug_type"].(string)
- if len(drug_type) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的药品类型不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- var drug_type_id int64
- var drugType = "药品类型"
-
- drugconfig, _ := service.GetDrugDataConfig(0, drugType)
- if len(drug_type) != 0 {
- _, errcodes := service.IsExistDicConfig(drugconfig.ID, drug_type, orgId)
- if errcodes == gorm.ErrRecordNotFound {
- //获取该型号最后一条数据型号
- config, _ := service.GetLastDicConfig(drugconfig.ID, orgId)
-
- dataconfig := models.DictDataconfig{
- ParentId: drugconfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: drug_type,
- FieldName: "",
- Value: config.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- drugTypeList, _ := service.GetParentDataConfig(drugconfig.ID, orgId)
- for _, it := range drugTypeList {
- if drug_type == it.Name {
- drug_type_id = int64(it.Value)
- }
- }
-
- drug.DrugType = drug_type_id
-
- drug_stock_limit, _ := goodNameM["drug_stock_limit"].(string)
- if len(drug_stock_limit) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的库存警戒不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.DrugStockLimit = drug_stock_limit
-
- drug_origin_place, _ := goodNameM["drug_origin_place"].(string)
- if len(drug_origin_place) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的产地不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.DrugOriginPlace = drug_origin_place
-
- drug_dosage_form := goodNameM["drug_dosage_form"].(string)
-
- if len(drug_dosage_form) == 0 {
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的药品剂型不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- var drug_dosage = "药品剂型"
- var drug_dosage_form_id int64
- drugDosageconfig, _ := service.GetDrugDataConfig(0, drug_dosage)
- if len(drug_dosage_form) != 0 {
- _, errcodess := service.IsExistDicConfig(drugDosageconfig.ID, drug_dosage_form, orgId)
- if errcodess == gorm.ErrRecordNotFound {
- configOne, _ := service.GetLastDicConfig(drugDosageconfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: drugDosageconfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: drug_dosage_form,
- FieldName: "",
- Value: configOne.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- drugDosageList, _ := service.GetParentDataConfig(drugDosageconfig.ID, orgId)
- for _, it := range drugDosageList {
- if drug_dosage_form == it.Name {
- drug_dosage_form_id = int64(it.Value)
- }
- }
-
- drug.DrugDosageForm = drug_dosage_form_id
-
- medical_insurance_level := goodNameM["medical_insurance_level"].(string)
- var medical_insurance_level_id int64
- if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的医保等级不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- var medicalInsuranceName = "医保等级"
- medicalInsuranceConfig, _ := service.GetDrugDataConfig(0, medicalInsuranceName)
- if len(medical_insurance_level) != 0 {
- _, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
- if errcodemedical == gorm.ErrRecordNotFound {
- medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: medicalInsuranceConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: medical_insurance_level,
- FieldName: "",
- Value: medConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- medicalInsuranceList, _ := service.GetParentDataConfig(medicalInsuranceConfig.ID, orgId)
- for _, it := range medicalInsuranceList {
- if medical_insurance_level == it.Name {
- medical_insurance_level_id = int64(it.Value)
- }
- }
- drug.MedicalInsuranceLevel = medical_insurance_level_id
-
- unit_matrixing := goodNameM["unit_matrixing"].(string)
- if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.UnitMatrixing = unit_matrixing
- retail_prices := goodNameM["retail_price"].(string)
- retail_price, _ := strconv.ParseFloat(retail_prices, 64)
-
- if retail_price <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的拆零售价不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.RetailPrice = retail_price
-
- packing_prices := goodNameM["packing_price"].(string)
- packing_price, _ := strconv.ParseFloat(packing_prices, 64)
-
- if packing_price <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的包装零售价不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.RetailPrice = retail_price
-
- last_prices := goodNameM["last_price"].(string)
- last_price, _ := strconv.ParseFloat(last_prices, 64)
- if last_price <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的进货价不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- drug.LastPrice = last_price
-
- drug_classify := goodNameM["drug_classify"].(string)
-
- if len(drug_classify) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的药物分类不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- var drugClassify = "药物分类"
- var drug_classify_id int64
- drugClassifyConfig, _ := service.GetDrugDataConfig(0, drugClassify)
-
- if len(drug_classify) != 0 {
- _, errcodesClass := service.IsExistDicConfig(drugClassifyConfig.ID, drug_classify, orgId)
- if errcodesClass == gorm.ErrRecordNotFound {
- drugClassConfig, _ := service.GetLastDicConfig(drugClassifyConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: drugClassifyConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: drug_classify,
- FieldName: "",
- Value: drugClassConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- drugClassList, _ := service.GetParentDataConfig(drugClassifyConfig.ID, orgId)
- for _, it := range drugClassList {
- if drug_classify == it.Name {
- drug_classify_id = int64(it.Value)
- }
- }
-
- drug_dose := goodNameM["drug_dose"].(string)
-
- if len(drug_dose) == 0 {
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
- drug.DrugDose = drugDoses
-
- var units = "单位"
- var unit_id int64
- drugDoseUnit := goodNameM["drug_dose_unit"].(string)
-
- if len(drugDoseUnit) == 0 {
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- dataConfig, _ := service.GetDataConfigIsExist(0, units)
- if len(drugDoseUnit) != 0 {
- _, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
- if errcodedataconfig == gorm.ErrRecordNotFound {
- childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
- dataconfig := models.Dataconfig{
- ParentId: dataConfig.ID,
- Module: "hemodialysis",
- OrgId: orgId,
- Name: drugDoseUnit,
- FieldName: "",
- Value: childConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- FieldType: 0,
- }
- service.CreateDataConfig(&dataconfig)
- }
- }
- list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
- for _, it := range list {
- if drugDoseUnit == it.Name {
- unit_id = int64(it.Value)
- }
- }
- drug.DrugDoseUnit = unit_id
-
- drug.DrugClassify = strconv.FormatInt(drug_classify_id, 10)
-
- manufacturer := goodNameM["manufacturer"].(string)
- if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+2) + "行" + "的生产商不能为空或内容与系统不匹配",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- if len(manufacturer) != 0 {
- _, errcodema := service.GetManufacturerName(orgId, manufacturer)
- if errcodema == gorm.ErrRecordNotFound {
- manufactur := models.Manufacturer{
- OrgId: orgId,
- Status: 1,
- ManufacturerName: manufacturer,
- Ctime: time.Now().Unix(),
- Creater: adminUser.AdminUser.Id,
- }
- service.CreateManufacturer(&manufactur)
- }
- }
-
- var manufacturer_id int64
-
- manufacturList, _ := service.GetAllManufacturerList(orgId)
- for _, it := range manufacturList {
- if manufacturer == it.ManufacturerName {
- manufacturer_id = it.ID
- }
- }
-
- drug.Manufacturer = manufacturer_id
-
- dealer := goodNameM["dealer"].(string)
- if len(dealer) != 0 {
- _, errcodesdealer := service.GetDealerByName(orgId, dealer)
- if errcodesdealer == gorm.ErrRecordNotFound {
- dealerconfig := models.Dealer{
- DealerName: dealer,
- Status: 1,
- OrgId: orgId,
- Ctime: time.Now().Unix(),
- Creater: adminUser.AdminUser.Id,
- }
- service.CreateDealer(&dealerconfig)
- }
- }
-
- var dealer_id int64
- dealerList, _ := service.GetAllDealerList(orgId)
- for _, it := range dealerList {
- if dealer == it.DealerName {
- dealer_id = it.ID
- }
- }
- drug.Dealer = dealer_id
-
- lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
-
- drug.LmtUsedFlag = lmt_used_flags
-
- if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
- utils.ErrorLog("drug_alias")
- return
- }
-
- drug_alias, _ := goodNameM["drug_alias"].(string)
-
- drug.DrugAlias = drug_alias
-
- drug_category := goodNameM["drug_category"].(string)
-
- var drugCategory = "药品类别"
- var drug_category_id int64
-
- drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
-
- if len(drug_category) != 0 {
- _, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
- if drugcategoryerrcodes == gorm.ErrRecordNotFound {
- drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: drugCategoryConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: drug_category,
- FieldName: "",
- Value: drugCategoryConfigSix.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
- fmt.Println("drugCategoryList", drugCategoryList)
- for _, it := range drugCategoryList {
- if drug_category == it.Name {
- drug_category_id = int64(it.Value)
- }
- }
-
- drug.DrugCategory = drug_category_id
-
- statistics_category := goodNameM["statistics_category"].(string)
-
- var statisticsCategory = "统计分类"
- var statistics_category_id int64
-
- statistcConfig, _ := service.GetDrugDataConfig(0, statisticsCategory)
- if len(statistics_category) != 0 {
- _, errcodestatistc := service.IsExistDicConfig(statistcConfig.ID, statistics_category, orgId)
- if errcodestatistc == gorm.ErrRecordNotFound {
- staConfig, _ := service.GetLastDicConfig(statistcConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: statistcConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: statistics_category,
- FieldName: "",
- Value: staConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
-
- }
-
- statisticsCategoryList, _ := service.GetParentDataConfig(statistcConfig.ID, orgId)
- for _, it := range statisticsCategoryList {
- if statistics_category == it.Name {
- statistics_category_id = int64(it.Value)
- }
- }
- drug.StatisticsCategory = statistics_category_id
-
- number := goodNameM["number"].(string)
- drug.Number = number
- hosp_appr_flag := int64(goodNameM["hosp_appr_flag"].(float64))
- drug.HospApprFlag = hosp_appr_flag
- medical_insurance_number := goodNameM["medical_insurance_number"].(string)
- drug.MedicalInsuranceNumber = medical_insurance_number
-
- pharmacology_category := goodNameM["pharmacology_category"].(string)
-
- var pharmacology = "药理分类"
- var pharmacology_category_id int64
- pharmacologyConfig, _ := service.GetDrugDataConfig(0, pharmacology)
- if len(pharmacology_category) != 0 {
- _, errcodespharmacology := service.IsExistDicConfig(pharmacologyConfig.ID, pharmacology_category, orgId)
- if errcodespharmacology == gorm.ErrRecordNotFound {
- dicConfig, _ := service.GetLastDicConfig(pharmacologyConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: pharmacologyConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: pharmacology_category,
- FieldName: "",
- Value: dicConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- pharmacologyList, _ := service.GetParentDataConfig(pharmacologyConfig.ID, orgId)
- for _, it := range pharmacologyList {
- if pharmacology_category == it.Name {
- pharmacology_category_id = int64(it.Value)
- }
- }
- drug.PharmacologyCategory = pharmacology_category_id
-
- code := goodNameM["code"].(string)
- drug.Code = code
- is_special_diseases := int64(goodNameM["is_special_diseases"].(float64))
- drug.IsSpecialDiseases = is_special_diseases
- is_record := int64(goodNameM["is_record"].(float64))
- drug.IsRecord = is_record
- prescription_mark := int64(goodNameM["prescription_mark"].(float64))
- drug.PrescriptionMark = prescription_mark
- social_security_directory_code := goodNameM["social_security_directory_code"].(string)
- drug.SocialSecurityDirectoryCode = social_security_directory_code
- record_date := goodNameM["record_date"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- drug.RecordDate = theTime.Unix()
- drug_remark := goodNameM["drug_remark"].(string)
- drug.DrugRemark = drug_remark
- drug_status := goodNameM["drug_status"].(string)
- drug.DrugStatus = drug_status
- limit_remark := goodNameM["limit_remark"].(string)
- drug.LimitRemark = limit_remark
-
- drug_control := goodNameM["drug_control"].(string)
-
- var drugControl = "开药控制"
- var drug_control_id int64
-
- drugContorlConfig, _ := service.GetDrugDataConfig(0, drugControl)
- if len(drug_control) != 0 {
- _, errcodesdrugcontrol := service.IsExistDicConfig(drugContorlConfig.ID, drug_control, orgId)
- if errcodesdrugcontrol == gorm.ErrRecordNotFound {
- drugContorlConfigOne, _ := service.GetLastDicConfig(drugContorlConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: drugContorlConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: drug_control,
- FieldName: "",
- Value: drugContorlConfigOne.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- drugContorlList, _ := service.GetParentDataConfig(drugContorlConfig.ID, orgId)
- for _, it := range drugContorlList {
- if drug_control == it.Name {
- drug_control_id = int64(it.Value)
- }
- }
- drug.DrugControl = drug_control_id
-
- drugList = append(drugList, &drug)
- }
-
- export_time := time.Now().Unix()
- errLogs, _ := service.FindPatientExportLogOne(this.GetAdminUserInfo().CurrentOrgId, export_time)
-
- if len(drugList) > 0 {
- for _, item := range drugList {
-
- goodInfo := models.BaseDrugLib{
- DrugName: item.DrugName,
- DrugAlias: item.DrugAlias,
- DrugSpec: item.DrugSpec,
- DrugType: item.DrugType,
- DrugStockLimit: item.DrugStockLimit,
- DrugOriginPlace: item.DrugOriginPlace,
- DrugDosageForm: item.DrugDosageForm,
- MedicalInsuranceLevel: item.MedicalInsuranceLevel,
- MaxUnit: item.MaxUnit,
- MinUnit: item.MinUnit,
- UnitMatrixing: item.UnitMatrixing,
- RetailPrice: item.RetailPrice,
- LastPrice: item.LastPrice,
- DrugClassify: item.DrugClassify,
- Manufacturer: item.Manufacturer,
- Dealer: item.Dealer,
- OrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Pinyin: item.Pinyin,
- Wubi: item.Wubi,
- DrugAliasPinyin: item.DrugAliasPinyin,
- DrugAliasWubi: item.DrugAliasWubi,
- DrugControl: item.DrugControl,
- Number: item.Number,
- HospApprFlag: item.HospApprFlag,
- MedicalInsuranceNumber: item.MedicalInsuranceNumber,
- PharmacologyCategory: item.PharmacologyCategory,
- StatisticsCategory: item.StatisticsCategory,
- Code: item.Code,
- IsSpecialDiseases: item.IsSpecialDiseases,
- IsRecord: item.IsRecord,
- PrescriptionMark: item.PrescriptionMark,
- SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
- RecordDate: item.RecordDate,
- DrugRemark: item.DrugRemark,
- DrugStatus: item.DrugStatus,
- LimitRemark: item.LimitRemark,
- DrugCategory: item.DrugCategory,
- DrugDose: item.DrugDose,
- DrugDoseUnit: item.DrugDoseUnit,
- LmtUsedFlag: item.LmtUsedFlag,
- DrugDay: item.DrugDay,
- DeliveryWay: item.DeliveryWay,
- ExecutionFrequency: item.ExecutionFrequency,
- DoseUnit: item.DoseUnit,
- }
-
- //查询同种药品同种规格是否存在
- _, drugerror := service.IsExistDrugByNameOne(item.DrugName, item.Dose, item.MaxUnit, item.MinNumber, item.MinUnit, item.MaxUnit, orgId)
-
- if drugerror == gorm.ErrRecordNotFound {
- service.CreateDrugsInfomation(&goodInfo)
- } else if drugerror == nil {
- service.UpdateDrugsInformation(&goodInfo, item.DrugName, item.DrugSpec, orgId)
- }
- log := models.ExportLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(drugList)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(drugList),
- "fail_num": int64(len(errLogs)),
- })
- }
- } else {
- log := models.ExportLog{
- LogType: 4,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(drugList)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(drugList),
- "fail_num": int64(len(errLogs)),
- })
- }
- }
-
- func (this *StockManagerApiController) GetInitializtion() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- var drugCategory = "药品类别"
- var drugType = "药品类型"
- var drugDosageForm = "药品剂型"
- var medicalInsuranceLevel = "医保等级"
- var drugControl = "开药控制"
- var drugClassify = "药物分类"
- var statisticsCategory = "统计分类"
- var pharmacologyCategory = "药理分类"
- var goodKind = "耗材种类"
- var tubeColor = "试管颜色"
- var costClassify = "费用类别"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
-
- drugCategoryParent, _ := service.GetDrugDataConfig(0, drugCategory)
- drugCategoryList, _ := service.GetParentDataConfig(drugCategoryParent.ID, orgId)
-
- drugDosageFormParent, _ := service.GetDrugDataConfig(0, drugDosageForm)
- drugDosageFormList, _ := service.GetParentDataConfig(drugDosageFormParent.ID, orgId)
-
- medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
- medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
-
- drugControlParent, _ := service.GetDrugDataConfig(0, drugControl)
- drugControlList, _ := service.GetParentDataConfig(drugControlParent.ID, orgId)
-
- drugClassifyParent, _ := service.GetDrugDataConfig(0, drugClassify)
- drugClassifyList, _ := service.GetParentDataConfig(drugClassifyParent.ID, orgId)
-
- statisticsCategoryParent, _ := service.GetDrugDataConfig(0, statisticsCategory)
- statisticsCategoryList, _ := service.GetParentDataConfig(statisticsCategoryParent.ID, orgId)
-
- pharmacologyCategoryParent, _ := service.GetDrugDataConfig(0, pharmacologyCategory)
- pharmacologyCategoryList, _ := service.GetParentDataConfig(pharmacologyCategoryParent.ID, orgId)
-
- goodKindParent, _ := service.GetDrugDataConfig(0, goodKind)
- goodKindList, _ := service.GetParentDataConfig(goodKindParent.ID, orgId)
-
- tubeColorParent, _ := service.GetDrugDataConfig(0, tubeColor)
- tubeColorList, _ := service.GetParentDataConfig(tubeColorParent.ID, orgId)
-
- costClassifyParent, _ := service.GetDrugDataConfig(0, costClassify)
- costClassifyList, _ := service.GetParentDataConfig(costClassifyParent.ID, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "drugCategoryList": drugCategoryList,
- "drugTypeList": drugTypeList,
- "drugDosageFormList": drugDosageFormList,
- "medicalInsuranceLevelList": medicalInsuranceLevelList,
- "drugControlList": drugControlList,
- "drugClassifyList": drugClassifyList,
- "statisticsCategoryList": statisticsCategoryList,
- "pharmacologyCategoryList": pharmacologyCategoryList,
- "goodKindList": goodKindList,
- "tubeColorList": tubeColorList,
- "costClassifyList": costClassifyList,
- })
- }
-
- func (this *StockManagerApiController) GetWarehouseOrderInfolist() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, _ := service.GetWarehouseOrderInfoList(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) PostSearchGoodList() {
-
- keyword := this.GetString("keyword")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, _ := service.GetSearchGoodList(keyword, orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (this *StockManagerApiController) GetAllStockList() {
-
- page, _ := this.GetInt64("page", -1)
- limit, _ := this.GetInt64("limit", -1)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- types, _ := this.GetInt64("type", 0)
- keywords := this.GetString("keywords")
-
- 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()
- }
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- list, total, _ := service.GetAllGoodInfoStockList(page, limit, startTime, endTime, types, keywords, orgId)
- fmt.Println("耗材总计23323232232323232323", total)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- })
- }
-
- func (this *StockManagerApiController) GetStockListById() {
-
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- }
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- list, total, _ := service.GetStockListById(id, orgId, limit, page, startTime, endTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- })
-
- }
-
- func (this *StockManagerApiController) GetStockOutList() {
-
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- is_sys, _ := this.GetInt64("is_sys")
- 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()
- }
- outList, total, _ := service.GetStockOutList(id, orgId, limit, page, startTime, endTime, is_sys)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "outList": outList,
- "total": total,
- })
- }
-
- func (this *StockManagerApiController) GetStockDrugCount() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- fmt.Println(orgId)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- }
-
- count, _ := service.GetStockDrugCount(startTime, endTime, orgId)
- outList, _ := service.GetAutoDiallysisBefor(startTime, endTime, orgId)
- autoCount, _ := service.GetOutStockTotalCountFour(startTime, endTime, orgId)
- totalCount, _ := service.GetCancelOutTotalCount(startTime, endTime, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "count": count,
- "outList": outList,
- "autoCount": autoCount,
- "totalCount": totalCount,
- })
- }
-
- func (this *StockManagerApiController) GetOrderDetialByOrderId() {
-
- ids := this.GetString("id")
- idsArray := strings.Split(ids, ",")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
- list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
- //获取该耗材的最后一条数据
- info, _ := service.GetLastWarehouseOutInfo(idsArray, orgId)
- fmt.Println("info323e2342342342432342342432", info)
- this.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "list": list,
- "info": info,
- })
- }
-
- func (this *StockManagerApiController) GetOrderDetailById() {
-
- id, _ := this.GetInt64("id")
- good_id, _ := this.GetInt64("good_id")
- record_time, _ := this.GetInt64("record_time")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- //自动出库
- userDetails, err, total := service.FindUserDetailByIdOne(good_id, record_time, orgId)
-
- //手动出库
- info, _ := service.GetWarehouseOutInfoById(id, good_id)
-
- stockFlowList, err := service.GetStockFlowBatchNumberOne(id, good_id)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": userDetails,
- "total": total,
- "info": info,
- "stockFlowList": stockFlowList,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *StockManagerApiController) GetSingleOutOrderDetail() {
- id, _ := this.GetInt64("id", 0)
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- warehouseOutInfo, _ := service.GetOrderDetialByOrderId(id, orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- goodType, _ := service.GetAllGoodType(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": warehouseOutInfo,
- "dealerList": dealerList,
- "manufacturerList": manufacturerList,
- "goodType": goodType,
- })
- }
-
- func (this *StockManagerApiController) GetExprotStockList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- idArray := this.GetString("id")
- ids := strings.Split(idArray, ",")
- 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()
- }
- fmt.Println("ids2222222222222222", ids)
- list, _ := service.GetExprotStockList(orgId, ids, startTime, endTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetOutExprotList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- idArray := this.GetString("id")
- ids := strings.Split(idArray, ",")
- fmt.Println("ids2222222222", 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 {
- 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, _ := service.GetOutExprotList(orgId, ids, startTime, endTime)
- outCount, _ := service.GetOutStockTotalCountOne(startTime, endTime, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "count": outCount,
- })
- }
-
- func (this *StockManagerApiController) GetSingleCancelOrder() {
-
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- order, _ := service.GetSingleCancelOrder(id, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": order,
- })
- }
-
- func (this *StockManagerApiController) GetCancelStockOrderPrint() {
- id := this.GetString("id")
- idStr := strings.Split(id, ",")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetCancelStockOrderPrintOne(idStr, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetStockBatchNumber() {
-
- id, _ := this.GetInt64("id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetStockBatchNumber(id, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetStockFlow() {
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- good_id, _ := this.GetInt64("good_id")
- consumable_type, _ := this.GetInt64("is_sys")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- }
-
- list, total, _ := service.GetStockFlowList(limit, page, consumable_type, orgId, startTime, endTime, good_id)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- })
- }
-
- func (this *StockManagerApiController) GetCancelExportList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- idArray := this.GetString("order_id")
- fmt.Println("232323232323232232", idArray)
- ids := strings.Split(idArray, ",")
- 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, _ := service.GetCancelExportList(startTime, endTime, ids, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetSearchGoodWarehouseList() {
-
- keyword := this.GetString("keyword")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetSearchGoodWarehouseList(keyword, orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (this *StockManagerApiController) SaveAdjuestPrice() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- tableData, _ := dataBody["tableData"].([]interface{})
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_name := items["good_name"].(string)
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
- utils.ErrorLog("packing_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- packing_price, _ := strconv.ParseFloat(items["packing_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["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
- utils.ErrorLog("license_number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- license_number := items["license_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["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
- utils.ErrorLog("buy_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- buy_price, _ := strconv.ParseFloat(items["buy_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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_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
- adjustprice := models.XtStockAdjustPrice{
- GoodName: good_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- BuyPrice: buy_price,
- PackingPrice: packing_price,
- NewPrice: new_price,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- GoodId: good_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- LicenseNumber: license_number,
- StartTime: startTime,
- Creater: this.GetAdminUserInfo().AdminUser.Id,
- CheckerStatus: 2,
- }
-
- service.CreateAdjustPrice(&adjustprice)
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功!",
- })
- }
-
- func (this *StockManagerApiController) GetAllStockPrice() {
-
- 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")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- 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.GetAllStockPrice(orgId, startTime, endTime, keyword, limit, page)
- doctor, _ := service.GetAllDoctorThree(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "doctor": doctor,
- "total": total,
- })
- }
-
- func (this *StockManagerApiController) SaveCheckPrice() {
- 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.XtStockAdjustPrice{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- err = service.UpdateAdjustPrice(ids, adjustPrice)
- fmt.Println(err)
-
- list, _ := service.GetAdjustCheckPriceList(ids)
- for _, item := range list {
- info := models.GoodInfo{
- PackingPrice: item.NewPrice,
- BuyPrice: item.BuyPrice,
- }
- err = service.UpdateAdjustCheckPrice(&info, item.GoodId)
- fmt.Println(err)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "adjustPrice": adjustPrice,
- })
- }
-
- func (this *StockManagerApiController) GetAdjustPriceById() {
-
- ids := this.GetString("ids")
- fmt.Println("ids23232233223233232", ids)
- splitIds := strings.Split(ids, ",")
- list, _ := service.GetAdjustPricebyIdOne(splitIds)
- fmt.Println("list2322322323", list)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) SaveReportStock() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- tableData, _ := dataBody["tableData"].([]interface{})
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_name := items["good_name"].(string)
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
- utils.ErrorLog("packing_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- packing_price, _ := strconv.ParseFloat(items["packing_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["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
- utils.ErrorLog("license_number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- license_number := items["license_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["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
- utils.ErrorLog("buy_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- buy_price, _ := strconv.ParseFloat(items["buy_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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_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["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- number := items["number"].(string)
-
- 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))
- orgId := this.GetAdminUserInfo().CurrentOrgId
- Creater := this.GetAdminUserInfo().AdminUser.Id
-
- if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "float64" {
- utils.ErrorLog("total")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- total := int64(items["total"].(float64))
-
- if items["good_origin_place"] == nil || reflect.TypeOf(items["good_origin_place"]).String() != "string" {
- utils.ErrorLog("good_origin_place")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_origin_place := items["good_origin_place"].(string)
- reportPrice := models.XtStockReportPrice{
- GoodName: good_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- BuyPrice: buy_price,
- PackingPrice: packing_price,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- GoodId: good_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- LicenseNumber: license_number,
- StartTime: startTime,
- Creater: Creater,
- Checker: 0,
- CheckerStatus: 2,
- CheckerTime: 0,
- Number: number,
- WarehousingInfoId: warehousing_info_id,
- ExpiryDate: expiry_date,
- ProductDate: product_date,
- Total: total,
- GoodOriginPlace: good_origin_place,
- }
- err := service.CreateReportPrice(&reportPrice)
- fmt.Println(err)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功!",
- })
- }
-
- func (this *StockManagerApiController) GetReportStockList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- 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()
- fmt.Println("开始时间", startTime)
- }
- 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()
-
- }
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- keyword := this.GetString("keyword")
- fmt.Println("startTime", startTime, "endTime", endTime)
- list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
- doctorlist, _ := service.GetAllDoctorThree(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "doctorlist": doctorlist,
- })
- }
-
- func (this *StockManagerApiController) SaveCheckDamage() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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")
- reportprice := models.XtStockReportPrice{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- err := service.UpdateCheckDamage(ids, reportprice)
- fmt.Println(err)
-
- //获取当前核对的数据
- list, _ := service.GetCheckDamageList(ids)
-
- ctime := time.Now().Unix()
- adminUserInfo := this.GetAdminUserInfo()
- 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)
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- warehouseOut := models.WarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehouseOutTime: ctime,
- Type: 1,
- }
-
- _, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
-
- if errcodes == gorm.ErrRecordNotFound {
- service.AddSigleWarehouseOut(&warehouseOut)
- }
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
- var manufacturer_id int64
- var dealer_id int64
-
- for _, item := range list {
- for _, it := range manufacturerList {
- if item.Manufacturer == it.ManufacturerName {
- manufacturer_id = it.ID
- }
- }
- for _, its := range dealerList {
- if item.Dealer == its.DealerName {
- dealer_id = its.ID
- }
- }
- //插入出库单
- warehouseOutInfo := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- GoodId: item.GoodId,
- Count: item.Count,
- Price: item.PackingPrice,
- Status: 1,
- Ctime: ctime,
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 2,
- Manufacturer: manufacturer_id,
- Number: item.Number,
- ExpiryDate: item.ExpiryDate,
- ProductDate: item.ProductDate,
- Dealer: dealer_id,
- LicenseNumber: item.LicenseNumber,
- }
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
- fmt.Println("99999999999999", errOne)
-
- //更改库存
- info, _ := service.GetWarehouseInfoById(item.WarehousingInfoId)
-
- warehousingInfo := models.WarehousingInfo{
- StockCount: info.StockCount - item.Count,
- }
- errOne = service.UpdateGoodWarehouseInfo(item.WarehousingInfoId, warehousingInfo)
- fmt.Println(errOne)
- flow := models.VmStockFlow{
- WarehousingId: 0,
- GoodId: item.GoodId,
- Number: item.Number,
- LicenseNumber: item.LicenseNumber,
- Count: item.Count,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: 0,
- SystemTime: time.Now().Unix(),
- ConsumableType: 5,
- IsSys: 0,
- WarehousingOrder: "",
- WarehouseOutId: warehouseOutInfo.ID,
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
- IsEdit: 0,
- CancelStockId: 0,
- CancelOrderNumber: "",
- Manufacturer: 0,
- Dealer: 0,
- Creator: adminUserInfo.AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: item.PackingPrice,
- WarehousingDetailId: 0,
- WarehouseOutDetailId: 0,
- CancelOutDetailId: 0,
- ProductDate: item.ProductDate,
- ExpireDate: item.ExpiryDate,
- }
- service.CreateStockFlowOne(flow)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "reportPrice": reportprice,
- })
- }
-
- func (this *StockManagerApiController) SaveInventory() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- tableData, _ := dataBody["tableData"].([]interface{})
- if len(tableData) > 0 {
- for _, item := range tableData {
- items := item.(map[string]interface{})
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_name := items["good_name"].(string)
-
- if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
- utils.ErrorLog("good_name")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
- utils.ErrorLog("packing_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- packing_price, _ := strconv.ParseFloat(items["packing_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["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
- utils.ErrorLog("license_number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- license_number := items["license_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["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
- utils.ErrorLog("buy_price")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- buy_price, _ := strconv.ParseFloat(items["buy_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["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
- utils.ErrorLog("good_id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_id := int64(items["good_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["total"] == nil || reflect.TypeOf(items["total"]).String() != "float64" {
- utils.ErrorLog("total")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- total := int64(items["total"].(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["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- number := items["number"].(string)
-
- 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["good_origin_place"] == nil || reflect.TypeOf(items["good_origin_place"]).String() != "string" {
- utils.ErrorLog("good_origin_place")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- good_origin_place := items["good_origin_place"].(string)
- orgId := this.GetAdminUserInfo().CurrentOrgId
- Creater := this.GetAdminUserInfo().AdminUser.Id
-
- inventory := models.XtStockInventory{
- GoodName: good_name,
- SpecificationName: specification_name,
- WarehousingUnit: warehousing_unit,
- Count: count,
- BuyPrice: buy_price,
- PackingPrice: packing_price,
- NewPrice: 0,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Remark: remark,
- GoodId: good_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- WarehousingOrder: warehousing_order,
- LicenseNumber: license_number,
- StartTime: startTime,
- Creater: Creater,
- Checker: 0,
- CheckerStatus: 2,
- CheckerTime: 0,
- Total: total,
- ExpireDate: expiry_date,
- ProductDate: product_date,
- Number: number,
- WarehousingInfoId: warehousing_info_id,
- GoodOriginPlace: good_origin_place,
- }
- err = service.CreateInentory(inventory)
- fmt.Println(err)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功!",
- })
- }
-
- func (this *StockManagerApiController) GetInventorylist() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- keyword := this.GetString("keyword")
- inventory_status, _ := this.GetInt64("inventory_status")
- 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()
- fmt.Println("开始时间", startTime)
- }
- 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()
-
- }
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, total, _ := service.GetInventorylist(startTime, endTime, page, limit, inventory_status, keyword, orgId)
- doctorlist, _ := service.GetAllDoctorThree(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "doctorlist": doctorlist,
- })
- }
-
- func (this *StockManagerApiController) SaveCheckInventory() {
-
- 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.XtStockInventory{
- Checker: checker,
- CheckerStatus: 1,
- CheckerTime: checkTime,
- }
- adminUserInfo := this.GetAdminUserInfo()
- err = service.UpdateCheckInventory(ids, inventory)
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
- var manufactuer_id int64
- var dealer_id int64
- //查询耗材信息
- list, _ := service.GetInventoryDetailById(ids)
- for _, item := range list {
- for _, it := range manufacturerList {
- if item.Manufacturer == it.ManufacturerName {
- manufactuer_id = it.ID
- }
- }
-
- for _, its := range dealerList {
- if item.Dealer == its.DealerName {
- dealer_id = its.ID
- }
- }
- //查寻该批次的库存量
- list, _ := service.GetWarehouseInfoById(item.WarehousingInfoId)
-
- //查询该耗材最后1条批次
- info, _ := service.GetLastWarehouseInfo(item.GoodId)
- fmt.Println("总共", item.Count)
- fmt.Println("数据", list.StockCount)
- //盘点盘点库存和et实际库存的大小
- // 如果盘点库存大于实际库存,怎需要入库
- if item.Count > list.StockCount {
-
- ctime := time.Now().Unix()
-
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
- total = total + 1
- warehousing_order := "RKD" + 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.Warehousing{
- WarehousingOrder: warehousing_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: ctime,
- Status: 1,
- WarehousingTime: ctime,
- Type: 1,
- }
- service.AddSigleWarehouse(&warehousing)
-
- //获取最
- //入库单表格
- warehouseInfo := models.WarehousingInfo{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehousing.ID,
- GoodId: item.GoodId,
- Number: info.Number,
- ProductDate: info.ProductDate,
- ExpiryDate: info.ExpiryDate,
- WarehousingCount: item.Count - list.StockCount,
- Price: info.Price,
- Status: 1,
- Ctime: ctime,
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 1,
- Manufacturer: manufactuer_id,
- StockCount: item.Count - list.StockCount,
- Dealer: dealer_id,
- LicenseNumber: info.LicenseNumber,
- }
-
- flow := models.VmStockFlow{
- WarehousingOrder: warehousing.WarehousingOrder,
- WarehousingId: warehousing.ID,
- GoodId: item.GoodId,
- Number: info.Number,
- ProductDate: info.ProductDate,
- ExpireDate: info.ExpiryDate,
- Count: item.Count - list.StockCount,
- Price: item.BuyPrice,
- Status: 1,
- Ctime: ctime,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Manufacturer: info.Manufacturer,
- Dealer: info.Dealer,
- LicenseNumber: info.LicenseNumber,
- IsEdit: 1,
- Creator: adminUserInfo.AdminUser.Id,
- SystemTime: operation_time,
- ConsumableType: 1,
- WarehousingDetailId: warehouseInfo.ID,
- }
-
- service.CreateWarehouseInfo(warehouseInfo)
- service.CreateStockFlowOne(flow)
- }
-
- //如果盘点库存小于实际库存,需要出库
- if item.Count < list.StockCount {
- 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)
- operation_time := time.Now().Unix()
- creater := adminUserInfo.AdminUser.Id
-
- //查询最早的1条批次
- warehouseInfo, _ := service.GetFirstWarehouseInfo(item.GoodId)
- warehouseOut := models.WarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Status: 1,
- WarehouseOutTime: time.Now().Unix(),
- Type: 1,
- }
- err = service.CreateWarehouseOut(warehouseOut)
- fmt.Println(err)
- warehouseOutInfo := &models.WarehouseOutInfo{
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- WarehouseOutId: warehouseOut.ID,
- GoodId: warehouseInfo.GoodId,
- Count: list.StockCount - item.Count,
- Price: warehouseInfo.Price,
- Status: 1,
- Ctime: time.Now().Unix(),
- Remark: item.Remark,
- OrgId: adminUserInfo.CurrentOrgId,
- Type: 1,
- Manufacturer: manufactuer_id,
- Number: warehouseInfo.Number,
- ExpiryDate: warehouseInfo.ExpiryDate,
- ProductDate: warehouseInfo.ProductDate,
- Dealer: dealer_id,
- LicenseNumber: warehouseInfo.LicenseNumber,
- }
-
- stockFlow := models.VmStockFlow{
- WarehousingId: item.WarehousingInfoId,
- GoodId: warehouseInfo.GoodId,
- Number: warehouseInfo.Number,
- LicenseNumber: warehouseInfo.LicenseNumber,
- Count: list.StockCount - item.Count,
- UserOrgId: warehouseInfo.OrgId,
- PatientId: 0,
- SystemTime: 0,
- ConsumableType: 2,
- IsSys: 2,
- WarehousingOrder: "",
- WarehouseOutId: warehouseOut.ID,
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
- IsEdit: 1,
- CancelStockId: 0,
- CancelOrderNumber: "",
- Manufacturer: manufactuer_id,
- Dealer: dealer_id,
- Creator: adminUserInfo.AdminUser.Id,
- UpdateCreator: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Price: warehouseInfo.Price,
- WarehousingDetailId: 0,
- WarehouseOutDetailId: warehouseOutInfo.ID,
- CancelOutDetailId: 0,
- ProductDate: warehouseInfo.ProductDate,
- ExpireDate: warehouseInfo.ExpiryDate,
- }
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
- fmt.Println(errOne)
- //创建出库明细
- service.CreateStockFlowOne(stockFlow)
-
- //更改库存
- warehousingInfos := models.WarehousingInfo{
- StockCount: item.Count,
- }
- service.UpdateStockOut(item.WarehousingInfoId, warehousingInfos)
- }
- }
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "inventory": inventory,
- })
- }
-
- func (this *StockManagerApiController) GetModifyPriceDetail() {
-
- id, _ := this.GetInt64("id")
-
- detail, _ := service.GetModifyPriceDetail(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *StockManagerApiController) UpdateStockPrice() {
-
- id, _ := this.GetInt64("id")
- newPrice := this.GetString("new_price")
- new_price, _ := strconv.ParseFloat(newPrice, 64)
- good_name := this.GetString("good_name")
- packingPrice := this.GetString("packing_price")
- packing_price, _ := strconv.ParseFloat(packingPrice, 64)
- remark := this.GetString("remark")
- good_id, _ := this.GetInt64("good_id")
- manufacturer := this.GetString("manufacturer")
- dealer := this.GetString("dealer")
- adjust := models.XtStockAdjustPrice{
- NewPrice: new_price,
- GoodName: good_name,
- PackingPrice: packing_price,
- Remark: remark,
- GoodId: good_id,
- Manufacturer: manufacturer,
- Dealer: dealer,
- }
- err := service.UpdateStockPrice(adjust, id)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "adjust": adjust,
- })
- }
-
- func (this *StockManagerApiController) DeleteStockPrice() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteStockPrice(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *StockManagerApiController) GetStockDamageDetail() {
-
- id, _ := this.GetInt64("id")
- detail, err := service.GetStockDamageDetail(id)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *StockManagerApiController) ModifyPrice() {
-
- count, _ := this.GetInt64("count")
- id, _ := this.GetInt64("id")
- good_name := this.GetString("good_name")
- specification_name := this.GetString("specification_name")
- number := this.GetString("number")
- warehousing_unit := this.GetString("warehousing_unit")
- buyPrice := this.GetString("buy_price")
- buy_price, _ := strconv.ParseFloat(buyPrice, 64)
- packingPrice := this.GetString("packing_price")
- packing_price, _ := strconv.ParseFloat(packingPrice, 64)
- good_origin_place := this.GetString("good_origin_place")
- manufacturer := this.GetString("manufacturer")
- dealer := this.GetString("dealer")
- total, _ := this.GetInt64("total")
- remark := this.GetString("remark")
- warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
- good_id, _ := this.GetInt64("good_id")
- adjust := models.XtStockReportPrice{
- Count: count,
- SpecificationName: specification_name,
- Number: number,
- GoodName: good_name,
- WarehousingUnit: warehousing_unit,
- BuyPrice: buy_price,
- PackingPrice: packing_price,
- GoodOriginPlace: good_origin_place,
- Manufacturer: manufacturer,
- Dealer: dealer,
- Total: total,
- Remark: remark,
- WarehousingInfoId: warehousing_info_id,
- GoodId: good_id,
- }
- err := service.ModifyPrice(id, adjust)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "adjust": adjust,
- })
- }
-
- func (this *StockManagerApiController) DeleteDamage() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteDamage(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *StockManagerApiController) GetStockDamageById() {
- ids := this.GetString("ids")
-
- splitIds := strings.Split(ids, ",")
- list, _ := service.GetStockDamageById(splitIds)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetInventoryDetail() {
- id, _ := this.GetInt64("id")
- detail, _ := service.GetInventoryDetail(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- })
- }
-
- func (this *StockManagerApiController) ModifyInventory() {
- id, _ := this.GetInt64("id")
- good_id, _ := this.GetInt64("good_id")
- good_name := this.GetString("good_name")
- specification_name := this.GetString("specification_name")
- number := this.GetString("number")
- warehousing_unit := this.GetString("warehousing_unit")
- buyPrice := this.GetString("buy_price")
- buy_price, _ := strconv.ParseFloat(buyPrice, 64)
- packingPrice := this.GetString("packing_price")
- packing_price, _ := strconv.ParseFloat(packingPrice, 64)
- total, _ := this.GetInt64("total")
- good_origin_place := this.GetString("good_origin_place")
- license_number := this.GetString("license_number")
- dealer := this.GetString("dealer")
- manufacturer := this.GetString("manufacturer")
- count, _ := this.GetInt64("count")
- remark := this.GetString("remark")
- inventory := models.XtStockInventory{
- GoodId: good_id,
- GoodName: good_name,
- SpecificationName: specification_name,
- Number: number,
- WarehousingUnit: warehousing_unit,
- BuyPrice: buy_price,
- PackingPrice: packing_price,
- Total: total,
- GoodOriginPlace: good_origin_place,
- LicenseNumber: license_number,
- Dealer: dealer,
- Manufacturer: manufacturer,
- Count: count,
- Remark: remark,
- }
- err := service.ModifyInventory(id, inventory)
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "inventory": inventory,
- })
- }
-
- func (this *StockManagerApiController) DeleteInventory() {
- id, _ := this.GetInt64("id")
- err := service.DeleteInventory(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *StockManagerApiController) GetInventoryDetailList() {
- keyword := this.GetString("keyword")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, total, _ := service.GetInventoryDetailList(keyword, limit, page, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- }
-
- func (this *StockManagerApiController) GetInventoryPrintList() {
-
- ids := this.GetString("ids")
- splitIds := strings.Split(ids, ",")
- list, _ := service.GetInventoryPrintList(splitIds)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) GetInventoryDetailPrintList() {
- ids := this.GetString("ids")
- splitIds := strings.Split(ids, ",")
- list, _ := service.GetInventoryDetailPrintList(splitIds)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) DeleteDrugPrice() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteDrugPrice(id)
- fmt.Println(err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *StockManagerApiController) GetGoodWarehouseList() {
-
- id, _ := this.GetInt64("id")
- list, _ := service.GetGoodWarehouseList(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StockManagerApiController) ProofInventory() {
-
- id, _ := this.GetInt64("id")
- good_id, _ := this.GetInt64("good_id")
- warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
- proof_count, _ := this.GetInt64("proof_count")
- total, _ := this.GetInt64("total")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- creater := this.GetAdminUserInfo().AdminUser.Id
-
- info := models.WarehousingInfo{
- GoodId: good_id,
- StockCount: proof_count,
- }
- err := service.UpdateProofInventory(warehousing_info_id, info)
- inventory := models.XtStockInventory{
- Total: proof_count,
- }
- err = service.UpdateStockInventory(inventory, id)
- fmt.Println(err)
- record := models.XtStockCorrectRecord{
- GoodId: good_id,
- OrdCount: total,
- WarehousingInfoId: warehousing_info_id,
- NewCount: proof_count,
- UserOrgId: orgId,
- Status: 1,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
- service.CeateStockCorrectRecord(record)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": info,
- })
- }
-
- func (this *StockManagerApiController) GetWarehouseTotal() {
-
- id, _ := this.GetInt64("id")
- list, _ := service.GetWarehouseTotal(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
|