| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437 |
- using CallCenter.Utility;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.App_Start;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Enum;
- using CallCenterApi.Interface.Models.Input;
- using CallCenterAPI.WechatSDK;
- using CallCenterAPI.WechatSDK.Models;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using qcloudsms_csharp;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Security.Cryptography;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Web;
- using System.Web.Mvc;
- using System.Xml;
- namespace CallCenterApi.Interface.Controllers.weixin
- {
- public class WxLoginController : BaseController
- {
- private readonly BLL.T_Sys_UserAccount userAccountBLL = new BLL.T_Sys_UserAccount();
- private readonly BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
- private readonly BLL.T_Cus_CustomerBaseNew customerBaseBLL = new BLL.T_Cus_CustomerBaseNew();
- private readonly BLL.T_Cus_CustomerFinance finbll = new BLL.T_Cus_CustomerFinance();
- private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
- private readonly BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
- private readonly BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
- private readonly BLL.T_Wo_WorkOrder_Logs blllogs = new BLL.T_Wo_WorkOrder_Logs();
- private readonly BLL.T_Sys_RoleInfo rolebll = new BLL.T_Sys_RoleInfo();
- private readonly BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
- private readonly BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
- BLL.T_Wo_QuestionManage quesBLL = new BLL.T_Wo_QuestionManage();
- ///// <summary>
- ///// 绑定微信号
- ///// </summary>
- ///// <param name="wxLoginDto"></param>
- ///// <returns></returns>
- //public ActionResult Login(WxLoginDto wxLoginDto)
- //{
- // var res = Redirect("获取微信openId", wxLoginDto.RedirectUrl);
- // var temp = WxHelper.GetOpenId(wxLoginDto);
- // if (string.IsNullOrWhiteSpace(temp.OpenId))
- // return res;
- // //openId => 用户
- // //如果不存在,跳转至登录页面
- // res = Redirect("绑定微信号", "");
- // return res;
- //}
- /// <summary>
- /// 绑定微信号 - 员工和业主分开登陆
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- public ActionResult Login(WxLoginDto login)
- {
- #region 把其他OpenId更新为空
- var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
- if (userAccount != null)
- {
- userAccount.F_WxOpenId = "";
- userAccountBLL.Update(userAccount);
- }
- var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(login.OpenId);
- if (modelcustomer != null)
- {
- modelcustomer.F_WxOpenId = "";
- customerBaseBLL.Update(modelcustomer);
- }
- #endregion
- if (string.IsNullOrEmpty(login.UserCode))
- return Error("账号不能为空!");
- if (string.IsNullOrEmpty(login.Password))
- return Error("密码不能为空!");
- Model.T_Sys_UserAccount loginCode = new BLL.T_Sys_UserAccount().LoginGetModel(login.UserCode, login.Password);
- Model.T_Sys_UserAccount loginwork = new BLL.T_Sys_UserAccount().LogworkGetModel(login.UserCode, login.Password);
- if (loginCode != null || loginwork != null)
- {
- Model.T_Sys_UserAccount loginUser = null;
- string deptcode = "";
- if (loginCode != null)
- loginUser = loginCode;
- else
- loginUser = loginwork;
- loginUser.F_WxOpenId = login.OpenId;
- int UserType = 0; string rolecode = ""; string UserName = ""; string rolename = "";
- UserName = loginUser.F_UserName;
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(loginUser.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- #region 读取角色code
- var rolemodel = roleBLL.GetModel(loginUser.F_RoleId);
- if (rolemodel != null)
- rolecode = rolemodel.F_RoleCode;
- string area="", offic = "", region = "";
- region = loginUser.F_Remark;
- if (rolemodel.F_RoleCode == "DQJL")
- {
- area = modelDep.F_DeptName;
-
- }
- else if (rolemodel.F_RoleCode == "FGSJL")
- {
- var dept = departmentBLL.GetModel(modelDep.F_ParentId);
- if (dept != null)
- {
- area = dept.F_DeptName;
-
- offic = modelDep.F_DeptName;
- }
- }
- else if (rolemodel.F_RoleCode == "YWY")
- {
- if (modelDep != null)
- {
- if (modelDep.F_Layer == 2)
- {
- var dept = departmentBLL.GetModel(modelDep.F_ParentId);
- if (dept != null)
- {
- area = dept.F_DeptName;
-
- offic = modelDep.F_DeptName;
- }
- }
- if (modelDep.F_Layer == 1)
- {
- area = modelDep.F_DeptName;
-
- }
- }
- }
- #endregion
- #region 部门角色
- //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
- if (loginUser.F_RoleId == 17)
- {
- //-1管理员
- return Error("无操作权限");
- }
- else
- {
- if (loginUser.F_RoleId == 60)
- {
- UserType = 0;
- rolename = "分公司经理";
- }
- else if (loginUser.F_RoleId == 62)
- {
- UserType = 0;
- rolename = "大区经理";
- }
- else if (loginUser.F_RoleId == 61)
- {
- UserType = 2;
- rolename = "高层";
- }
- else if (loginUser.F_RoleId == 58)
- {
- UserType = 4;
- rolename = "业务员";
- }
- else if (loginUser.F_RoleId == 59)
- {
- UserType = 3;
- rolename = "办理人员";
- }
- else
- {
- return Error("无操作权限");
- }
-
- #region
- ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
- //IF (MODELDEP.F_TYPE == 1)
- //{
- // //1--接待部
- // USERTYPE = 1;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 2)
- //{
- // //2--办理人员
- // USERTYPE = 2;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 3)
- //{
- // //3--区域客服
- // USERTYPE = 3;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 4)
- //{
- // //4--监管
- // USERTYPE = 4;
- //}
- //ELSE
- //{
- // USERTYPE = 0;
- //}
- #endregion
- }
- #endregion
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- usertype = UserType,
- UserName = UserName,
- rolename = rolename,
- rolecode = rolecode,
- area = area ,
- offic =offic ,
- region =region
- };
- if (userAccountBLL.Update(loginUser))
- return Success("绑定成功", obj);
- else
- return Error("绑定失败");
- }
- return Error("账号或密码错误,请重新登录");
- //else if (login.UserType == 5)
- //{
- // //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
- // Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
- // // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
- // //首次密码默认为身份证后6位信息
- // //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
- // string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_WxPassword=@F_PassWord and F_DeleteFlag = 0 ORDER BY F_CreatedOn ASC ";
- // paras_Customer.Add("@F_UserCode", login.UserCode);
- // paras_Customer.Add("@F_PassWord", login.Password);
- // var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
- // if (dt_Customer != null && dt_Customer.Rows.Count > 0)
- // {
- // //var customer = customerBaseBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
- // var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
- // customer.F_WxOpenId = login.OpenId;
- // #region 新加 - 登录后同时获取用户账号,openid,和角色
- // //5--业主(客户档案会员)
- // //int UserType = 5;
- // var obj = new
- // {
- // openid = login.OpenId,
- // usercode = login.UserCode,
- // companyname = customer.F_CompanyName,
- // //companyaddress=customer.F_CompanyAddress,
- // };
- // #endregion
- // if (customerBaseBLL.Update(customer))
- // return Success("绑定成功!", obj);
- // else
- // return Error("绑定失败!");
- // }
- // return Error("账号或密码错误或者没有注册,请重新登录");
- //}
- return Error("绑定失败");
- }
- /// <summary>
- /// 绑定微信号 - 员工和业主统一登陆 - 不用
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult Login2(WxLoginDto login)
- {
- Dictionary<string, string> paras = new Dictionary<string, string>();
- string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
- paras.Add("@F_UserCode", login.UserCode);
- paras.Add("@F_PassWord", login.Password);
- var dt = DbHelperSQL.Query(sql, paras).Tables[0];
- #region 把其他OpenId更新为空
- var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
- if (userAccount != null)
- {
- userAccount.F_WxOpenId = "";
- userAccountBLL.Update(userAccount);
- }
- var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault();//.GetModelByOpenid(login.OpenId);
- if (modelcustomer != null)
- {
- modelcustomer.F_WxOpenId = "";
- customerBaseBLL.Update(modelcustomer);
- }
- #endregion
- if (dt != null && dt.Rows.Count > 0)
- {
- var user = userAccountBLL.GetModel(login.UserCode);
- user.F_WxOpenId = login.OpenId;
- //int UserType = 0;
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- #region 部门角色
- ////部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
- //if (user.F_RoleId == 17)
- //{
- // //-1管理员
- // UserType = -1;
- //}
- //else
- //{
- // //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // if (modelDep.F_Type == 1)
- // {
- // //1--接待部
- // UserType = 1;
- // }
- // else if (modelDep.F_Type == 2)
- // {
- // //2--办理人员
- // UserType = 2;
- // }
- // else if (modelDep.F_Type == 3)
- // {
- // //3--区域客服
- // UserType = 3;
- // }
- // else if (modelDep.F_Type == 4)
- // {
- // //4--监管
- // UserType = 4;
- // }
- // else
- // {
- // UserType = 0;
- // }
- //}
- #endregion
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- //usertype = UserType
- };
- if (userAccountBLL.Update(user))
- {
- return Success("绑定成功", obj);
- }
- else
- {
- return Error("绑定失败");
- }
- }
- else
- {
- //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
- Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
- // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
- //首次密码默认为身份证后6位信息
- //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
- string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
- paras_Customer.Add("@F_UserCode", login.UserCode);
- paras_Customer.Add("@F_PassWord", login.Password);
- var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
- if (dt_Customer != null && dt_Customer.Rows.Count > 0)
- {
- var customer = customerBaseBLL.GetModelList(" F_CustomerCode='" + login.UserCode + "'").FirstOrDefault(); //customerBaseBLL.GetModel(login.UserCode);
- customer.F_WxOpenId = login.OpenId;
- #region 新加 - 登录后同时获取用户账号,openid,和角色
- //5--业主(客户档案会员)
- //int UserType = 5;
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- //usertype = UserType
- };
- #endregion
- if (customerBaseBLL.Update(customer))
- {
- return Success("绑定成功!", obj);
- }
- else
- {
- return Error("绑定失败!");
- }
- }
- else
- {
- return Error("账号或密码错误,请重新登录");
- }
- //return Error("账号或密码错误,请重新登录");
- }
- }
- /// <summary>
- /// 随机字符串数组集合
- /// </summary>
- private static readonly string[] NonceStrings = new string[]
- {
- "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
- "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
- };
- /// <summary>
- /// 生成签名的随机串
- /// </summary>
- /// <returns></returns>
- public static string CreateNonceStr()
- {
- Random random = new Random();
- var sb = new StringBuilder();
- var length = NonceStrings.Length;
- //生成15位数的随机字符串,当然也可以通过控制对应字符串大小生成,但是至多不超过32位
- for (int i = 0; i < 16; i++)
- {
- sb.Append(NonceStrings[random.Next(length - 1)]);//通过random获得的随机索引到,NonceStrings数组中获取对应数组值
- }
- return sb.ToString();
- }
- /// <summary>
- /// 获取签名
- /// </summary>
- /// <param name="url"></param>
- /// <returns></returns>
- public ActionResult GetJsSdk(string url)
- {
- var timestamp = GetCurrentUinxTime();
- var nonceStr = CreateNonceStr();
- var obj = new
- {
- state = "success",
- message = "成功",
- appId = AppId,
- timestamp = timestamp,
- nonceStr = nonceStr,
- token = GetToken(),
- ticket= Getticket(GetToken()),
- url,
- signature = GetSignature(Getticket(GetToken()), nonceStr, timestamp, url)
- };
- return Content(obj.ToJson()); ;
- }
-
- string AppId = Configs.GetValue("WechatAppid");
- string AppSecret = Configs.GetValue("WechatAppsecret");
- public class Token
- {
- public string token;
- public DateTime time;
- }
-
- public class AssedToken
- {
-
- public string access_token { get; set; }
-
- public int expires_in { get; set; }
-
-
- }
- public string GetToken()
- {
- WebClient web = new WebClient();
- web.Encoding = Encoding.UTF8;
- string msg = "";
- var model = new BLL.T_Sys_AssToken().GetModelList("F_IsDelete=0 order by F_ID desc").FirstOrDefault();
- if (model!=null )
- {
- System.TimeSpan id = DateTime.Now - DateTime.Parse(model.F_CreatTime .ToString());
- if (id.TotalMinutes>=120)
- {
- string url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + AppId + "&secret=" + AppSecret;
- string Dataaa = web.DownloadString(url);//这一句话就能请求到数据了
- JObject jo = (JObject)JsonConvert.DeserializeObject(Dataaa);
- string access_token = jo["access_token"].ToString();
-
- var asser = new Model.T_Sys_AssToken();
- asser.F_CreatTime = DateTime.Now;
- asser.F_IsDelete = 0;
- asser.F_Token = access_token;
- int a = new BLL.T_Sys_AssToken().Add(asser);
- if (a >0)
- {
- msg = access_token;
- }
- }
- else
- {
- msg = model.F_Token ;
- }
- }
- else
- {
- string url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + AppId + "&secret=" + AppSecret;
- string Dataaa = web.DownloadString(url);//这一句话就能请求到数据了
- JObject jo = (JObject)JsonConvert.DeserializeObject(Dataaa);
- string access_token = jo["access_token"].ToString();
- var asser = new Model.T_Sys_AssToken();
- asser.F_CreatTime = DateTime.Now;
- asser.F_IsDelete = 0;
- asser.F_Token = access_token;
- int a = new BLL.T_Sys_AssToken().Add(asser);
- if (a > 0)
- {
- msg = access_token;
- }
- }
-
- return msg;
- }
-
- public string Getticket(string token)
- {
- WebClient web = new WebClient();
- web.Encoding = Encoding.UTF8;
- string msg = "";
- string urltoken = " https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + token + "&type=jsapi";
- string Dataaasig = web.DownloadString(urltoken);//这一句话就能请求到数据了
- JObject jo = (JObject)JsonConvert.DeserializeObject(Dataaasig);
- string ticket = jo["ticket"].ToString();
- string errmsg = jo["errmsg"].ToString();
-
- return ticket;
- }
-
- public class Accesstoken
- {
- public string access_token;
- public int expires_in;
- }
- /// <summary>
- /// 获取jsapi_ticket
- /// </summary>
- /// <param name="jsapi_ticket">微信公众号调用微信JS临时票据</param>
- /// <param name="nonceStr">随机串</param>
- /// <param name="timestamp">时间戳</param>
- /// <param name="url">当前网页URL</param>
- /// <returns></returns>
- public static string GetSignature(string jsapi_ticket, string nonceStr, long timestamp, string url)
- {
- var string1Builder = new StringBuilder();
- //注意这里参数名必须全部小写,且必须有序
- string1Builder.Append("jsapi_ticket=").Append(jsapi_ticket).Append("&")
- .Append("noncestr=").Append(nonceStr).Append("&")
- .Append("timestamp=").Append(timestamp).Append("&")
- .Append("url=").Append(url.IndexOf("#") >= 0 ? url.Substring(0, url.IndexOf("#")) : url);
- return Sha1Sign(string1Builder.ToString());
- }
- public static string Sha1Sign(string data)
- {
- byte[] temp1 = Encoding.UTF8.GetBytes(data);
- SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
- byte[] temp2 = sha.ComputeHash(temp1);
- sha.Clear();
- // 注意, 不能用这个
- // string output = Convert.ToBase64String(temp2);// 不能直接转换成base64string
- var output = BitConverter.ToString(temp2);
- output = output.Replace("-", "");
- output = output.ToLower();
- return output;
- }
-
- /// <summary>
- /// 获取当前时间戳
- /// </summary>
- /// <returns></returns>
- public static long GetCurrentUinxTime()
- {
- DateTime currentDate = DateTime.Now;//当前时间
- //转化为时间戳
- DateTime localTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
- return long.Parse((currentDate - localTime).TotalSeconds.ToString().Split('.')[0]);
- // var ticks = currentDate.ToUniversalTime().Ticks - new DateTime(1970, 1, 1, 0, 0, 0, //DateTimeKind.Utc).Ticks;
- // var timeSpan = ticks / TimeSpan.TicksPerSecond;
- //return timeSpan;
- }
- /// <summary>
- /// 获取微信openid
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- public ActionResult GetOpenId(WxLoginDto wld)
- {
- wld.RedirectUrl = RequestString.GetUrlReferrer();
- if (string.IsNullOrEmpty(wld.OpenId))
- {
- var temp = WxHelper.GetOpenId(wld);
- if (string.IsNullOrWhiteSpace(temp.OpenId))
- {
- //Request.QueryString[ ] == null
- return Redirect("请求", temp.RedirectUrl);
- }
- wld.OpenId = temp.OpenId;
- #region 获取是否绑定用户表
- //获取是否绑定用户表
- var usertemp = new BLL.T_Sys_UserAccount().GetModelByOpenid(wld.OpenId);
- if (usertemp != null)
- {
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(usertemp.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- wld.UserCode = usertemp.F_UserCode;
- #region 读取角色code
- var rolemodel = roleBLL.GetModel(usertemp.F_RoleId);
- if (rolemodel != null)
- wld.RoleCode = rolemodel.F_RoleCode;
- #endregion
- #region 部门角色
- if (usertemp.F_RoleId == 17)
- {
- //-1管理员
- wld.UserType = -1;
- }
- else
- {
- if (usertemp.F_RoleId == 60 || usertemp.F_RoleId == 62)
- {
- wld.UserType = 0;
- }
- else if (usertemp.F_RoleId == 61)
- {
- wld.UserType = 2;
- }
- else if (usertemp.F_RoleId == 58)
- {
- wld.UserType = 4;
- }
- else if (usertemp.F_RoleId == 59)
- {
- wld.UserType = 3;
- }
- else
- {
- wld.UserType = 1;
- }
- #region
- ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
- //IF (MODELDEP.F_TYPE == 1)
- //{
- // //1--接待部
- // USERTYPE = 1;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 2)
- //{
- // //2--办理人员
- // USERTYPE = 2;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 3)
- //{
- // //3--区域客服
- // USERTYPE = 3;
- //}
- //ELSE IF (MODELDEP.F_TYPE == 4)
- //{
- // //4--监管
- // USERTYPE = 4;
- //}
- //ELSE
- //{
- // USERTYPE = 0;
- //}
- #endregion
- #region
- ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
- //if (modelDep.F_Type == 1)
- //{
- // //1--接待部
- // wld.UserType = 1;
- //}
- //else if (modelDep.F_Type == 2)
- //{
- // //2--办理人员
- // wld.UserType = 2;
- //}
- //else if (modelDep.F_Type == 3)
- //{
- // //3--区域客服
- // wld.UserType = 3;
- //}
- //else if (modelDep.F_Type == 4)
- //{
- // //4--监管
- // wld.UserType = 4;
- //}
- //else
- //{
- // wld.UserType = 0;
- //}
- #endregion
- }
- #endregion
- }
- else
- {
- var customertemp = customerBaseBLL.GetModelByOpenid(wld.OpenId);
- if (customertemp != null)
- {
- wld.UserCode = customertemp.F_CustomerCode;
- //5--业主(客户档案会员)
- wld.UserType = 5;
- }
- else
- {
- wld.UserCode = "";
- }
- //wld.UserCode = "";
- }
- #endregion
- }
- var model = new BLL.T_Sys_Users().GetModel(wld.OpenId);
- if (model == null)
- {
- model = new Model.T_Sys_Users();
- model.F_OpenId = wld.OpenId;
- model.F_Type = 1;
- model.F_CreateTime = DateTime.Now;
- new BLL.T_Sys_Users().Add(model);
- }
- var newobj = new
- {
- openid = wld.OpenId,
- usercode = wld.UserCode,
- usertype = wld.UserType,
- rolecode = wld.RoleCode,
- };
- return Success("成功", newobj);
- }
- /// <summary>
- ///退回工单列表
- /// </summary>
- public string GetBackid(Model.T_Sys_UserAccount ua)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType in(" + (int)EnumItemType.deal + "," + (int)EnumItemType.audit + ")"
- + " and "
- + "F_OptType in(" + (int)EnumItemOpt.abreback + "," + (int)EnumItemOpt.reback + ") and F_NextUser='" + ua.F_UserCode + "'"
- + ""
- + " and isnull(F_IsUsed,'0')='0' ";
- return str;
- }
- /// <summary>
- ///工单列表
- /// </summary>
- public ActionResult GetList(string handler,string description,string OpenId, string code, string cusname, string keywords, string cusphone, string companyname, string province, string city,
- string country, string township, string category, string salebase, string touser, int source = 0, int state = -1, int status = -1, int type = 0, int pageindex = 1, int pagesize = 10)
- {
- // int userId = CurrentUser.UserData.F_UserId;
- if (!string.IsNullOrEmpty(OpenId))
- {
- // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- // if (source != 3)
- // {
- // if (ua == null)
- // {
- // return Error("你的账号已在别处登录,你确定要再次登录吗?");
- // }
- // }
- // Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (source > 0)//工单来源
- {
- if (source == 1)
- sql += $" and F_Source in (1,'')";
- else
- sql += $" and F_Source='" + source + "'";
- }
- if (!string.IsNullOrWhiteSpace(description))//问题描述
- sql += $" and F_Description like '%" + description.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(touser))//参与人
- sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(code))//工单编号
- sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
- sql += $" and (F_QuestionType like '%" + keywords.Trim()
- + "%' or F_ZX_Area like '%" + keywords.Trim() + "%' or F_ZX_Branch like '%" + keywords.Trim()
- + "%' or F_CusName like '%" + keywords.Trim() + "%' or F_WorkOrderCode like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%' ) ";
- if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
- sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
- sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(companyname))//公司名称
- sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(category))//产品名称
- sql += $" and F_TS_Category like '%" + category.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(salebase))//销售基地
- sql += $" and F_SalesBase like '%" + salebase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//省
- sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//市
- sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//县
- sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//乡
- sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
- if (!string .IsNullOrEmpty (handler))
- {
- Model.T_Sys_UserAccount user = userAccountBLL .GetworkModel(handler);
- if (user != null)
- {
- if (GetParticipate(user.F_UserCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetParticipate(user.F_UserCode) + ") ";
- }
- }
- else
- {
- Model.T_Sys_UserAccount userer = userAccountBLL.GetName(handler);
- if (userer != null)
- {
- if (GetParticipate(userer.F_UserCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetParticipate(userer.F_UserCode) + ") ";
- }
- }
- }
- }
- // sql += " and (F_CreateBy= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.F_ID in ( " + GetCYWorkOrderID(ua.F_UserCode) + ")) ";
- if (ua != null)
- {
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- if (source == 3)
- {
- sql += $" and F_WxOpenId ='" + OpenId + "'";
- }
- if (state >-1)
- {
- switch (state)
- {
- case 0://待审批
- string uwhere = "";
- if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL")
- {
- if (GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) + ") ";
- }
- else
- {
- return Success("暂无工单");
- }
- }
- else
- {
- return Success("无操作权限");
- }
- break;
- case 11://已创单
- sql += $" and F_CreateBy ='" + ua.F_UserCode + "'";
- break;
- case 12://退单
- if (GetBackid(ua) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetBackid(ua) + ") ";
- }
- else
- {
- return Success("暂无工单");
- }
- break;
- case 1://已审核
- if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "GC")
- {
- if (GetApprovedOrderID(ua.F_UserCode) != "")
- {
- sql += $" and F_ID in ( " + GetApprovedOrderID(ua.F_UserCode) + ") "; ;
- }
- else
- {
- return Error("暂无工单");
- }
- }
- else
- {
- return Success("暂无工单");
- }
- break;
- case 2://待完成的(待接单)
- if (GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) != "")
- {
- sql += $" and F_State in(" + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.assign + ") and T_Wo_WorkOrder.F_ID in ( " +
- GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) + ") "; ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- break;
- case 5://待审批
- if (ro.F_RoleCode == "GC")
- {
- if (GetHApproval(ua.F_UserCode) != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetHApproval(ua.F_UserCode) + ") "; ;
- }
- }
- else
- {
- return Success("暂无工单"); ;
- }
- break;
- case 4://待完成的(待处理)
- if (GetDWCWorkOrderID(ua.F_UserCode, ua.F_DeptId) != null)
- {
- sql += " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + ") and T_Wo_WorkOrder.F_ID in ( " + GetDWCWorkOrderID(ua.F_UserCode, ua.F_DeptId) + ") ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- break;
- case 10://已完成的
- if (GetDeptUserCode(ua.F_DeptId) != "")
- {
- sql += " and F_State in(10,11) and F_DealBy in(" + GetDeptUserCode(ua.F_DeptId) + ") ";
- }
- // sql += " and F_State in(10,11) and F_DealBy = '" + ua.F_UserCode + "' ";
- break;
- case 3://我参与的
- if (GetParticipateID(ua.F_UserCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetParticipateID(ua.F_UserCode) + ") ";
- }
- else
- {
- return Error("暂无工单");
- }
- break;
- case 6://待回访
- if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
- {
- uwhere = "";
- }
- else
- {
- return Success("无操作权限"); ;
- }
- sql += $" and F_State=" + (int)EnumWorkOrderState.finish + " and F_IsVisit = '" + "1" + "' " + uwhere; ;
- break;
- case 7://已回访
- if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
- {
- if (GetCYWorkOrderID(ua.F_UserCode) != "")
- {
- sql += " and (F_CreateBy= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.F_ID in ( " + GetCYWorkOrderID(ua.F_UserCode) + ")) ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- sql += $" and F_State=" + (int)EnumWorkOrderState.evaluate;
- }
- else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
- {
- string detpid = "" + ua.F_DeptId;
- var deparmentlist = new List<Model.T_Sys_Department>();
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId; ;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.evaluate + "") != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.evaluate + "") + ") "; ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- return Error("加载失败");
- }
- }
- else
- {
- return Success("无操作权限"); ;
- }
- sql += $" and F_State=" + (int)EnumWorkOrderState.evaluate;
- break;
- case 8://待完结
- if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
- {
- uwhere = ""; ;
- }
- else
- {
- return Success("无操作权限"); ;
- }
- sql += $" and F_State=" + (int)EnumWorkOrderState.finish + " and F_IsVisit = '" + "0" + "' "; ;
- break;
- case 9://待接单
- if (GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) != "")
- {
- sql += $" and F_State in(" + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.assign + ") and T_Wo_WorkOrder.F_ID in ( " +
- GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) + ") "; ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- break;
- }
- }
- else
- {
- if (ro.F_RoleCode == "QTJS" || ro.F_RoleCode == "YWY")
- sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
- else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "ZG")
- {
- string detpid = "" + ua.F_DeptId;
- var deparmentlist = new List<Model.T_Sys_Department>();
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- if (state >= 0)
- {
- if (GetDeptWorkOrderID(detpid) != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid) + ") ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- if (GetDeptWorkOrderID(detpid) != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid) + ") ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- }
- else
- {
- return Error("加载失败");
- }
- }
- }
-
- }
- else
- {
- sql += $" and F_WxOpenId ='" + OpenId + "'";
- }
- #endregion
- int recordCount = 0;
- if (!string.IsNullOrWhiteSpace(sql))
- {
- dt = BLL.PagerBLL.GetListPager(
- "T_Wo_WorkOrder",
- "F_ID",
- "*",
- sql,
- "ORDER BY T_Wo_WorkOrder.F_ID desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<WorkOrderNewInput> Input = modeltooip(modlelist, ua);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = Input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- public string GetDeptUserCode(int deptid)
- {
- string deptuser = string.Empty;
- var dept = userAccountBLL .GetModelList("F_DeptId=" + deptid);
- if (dept != null)
- {
- foreach (var it in dept)
- {
- if (deptuser != "")
- deptuser += "," + it.F_UserCode;
- else
- deptuser += it.F_UserCode;
- }
- }
- return deptuser;
- }
- /// <summary>
- ///综合查询列表
- /// </summary>
- public ActionResult GetComprehensive(string description,string OpenId, string code, string createby, string cusname, string keywords, string cusphone, string companyname, string province, string city,
- string country, string township, string category, string salebase, string touser, int source = 0, int state = -1, int type = 0, int pageindex = 1, int pagesize = 10)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- // if (ua == null)
- // {
- // return Error("你的账号已在别处登录,你确定要再次登录吗?");
- // }
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (state >= 0)//
- sql += $" and F_State=" + state;
- if (source > 0)//工单来源
- {
- if (source == 1)
- sql += $" and F_Source in (1,'')";
- else
- sql += $" and F_Source='" + source + "'";
- }
- if (!string.IsNullOrWhiteSpace(description))//问题描述
- sql += $" and F_Description like '%" + description.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(createby))//创建人
- sql += $" and F_CreateBy like '%" + createby.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(touser))//参与人
- sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(code))//工单编号
- sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
- sql += $" and ( F_QuestionType like '%" + keywords.Trim()
- + "%' or F_ZX_Area like '%" + keywords.Trim() + "%' or F_ZX_Branch like '%" + keywords.Trim()
- + "%' or F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%') ";
- if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
- sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
- sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(companyname))//公司名称
- sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(category))//产品名称
- sql += $" and F_TS_Category like '%" + category.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(salebase))//销售基地
- sql += $" and F_SalesBase like '%" + salebase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//省
- sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//市
- sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//县
- sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//乡
- sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
- if (ua != null)
- {
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- if (ro.F_RoleCode == "QTJS" || ro.F_RoleCode == "YWY")
- {
- sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
- }
- else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "ZG")
- {
- string detpid = "" + ua.F_DeptId;
- var deparmentlist = new List<Model.T_Sys_Department>();
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- if (state >= 0)
- {
- if (GetDeptWorkOrderID(detpid, "" + state + "") != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + state + "") + ") ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.neworder + ", " + (int)EnumWorkOrderState.assign + "," +
- (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish
- + "," + (int)EnumWorkOrderState.evaluate + "") != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.neworder + ", " + (int)EnumWorkOrderState.assign + "," +
- (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish
- + "," + (int)EnumWorkOrderState.evaluate + "") + ") ";
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- }
- else
- {
- return Error("加载失败");
- }
- }
- }
- else
- {
- return Error("无操作权限");
- }
- #endregion
- int recordCount = 0;
- if (!string.IsNullOrWhiteSpace(sql))
- {
- dt = BLL.PagerBLL.GetListPager(
- "T_Wo_WorkOrder",
- "F_ID",
- "*",
- sql,
- "ORDER BY T_Wo_WorkOrder.F_ID desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<WorkOrderNewInput> Input = modeltooip(modlelist, ua);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = Input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- return Error("无操作权限!");
- }
- }
- /// <summary>
- /// 根据部门获取工单号
- /// </summary>
- /// <returns></returns>
- public string GetDeptWorkOrderID(string user)
- {
- string sql = " ";
- string ua = "";
- DataTable dt = new DataTable();
- if (user != "")
- {
- sql += " and F_DeptId in ( " + user + ") ";
- }
- int recordCount;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_UserAccount",
- "F_UserId",
- "*",
- sql,
- "ORDER BY F_UserId desc",
- 10000,
- 1,
- true,
- out recordCount);
- List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
- if (modelList != null)
- {
- foreach (var it in modelList)
- {
- if (ua != "")
- ua += "," + it.F_UserCode;
- else
- ua += it.F_UserCode;
- }
- }
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where (F_CreateUser in(" + ua + ") or F_NextDept in(" + user + "))"
- ;
- return str;
- }
- /// <summary>
- /// 根据部门获取工单号
- /// </summary>
- /// <returns></returns>
- public string GetDeptWorkOrderID(string user, string F_ItemType)
- {
- string sql = " ";
- string ua = "";
- DataTable dt = new DataTable();
- if (user != "")
- {
- sql += " and F_DeptId in ( " + user + ") ";
- }
- int recordCount;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_UserAccount",
- "F_UserId",
- "*",
- sql,
- "ORDER BY F_UserId desc",
- 10000,
- 1,
- true,
- out recordCount);
- List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
- if (modelList != null)
- {
- foreach (var it in modelList)
- {
- if (ua != "")
- ua += "," + it.F_UserCode;
- else
- ua += it.F_UserCode;
- }
- }
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType in(" + F_ItemType + ")"
- + " and "
- + "F_CreateUser in(" + ua + ")"
- ;
- return str;
- }
- /// <summary>
- /// 获取待完成的工单编号
- /// </summary>
- /// <returns></returns>
- public string GetDWCWorkOrderID(string user,int deptid)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
- + " and ("
- + "(F_WoState in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + ") and F_NextDept='" + deptid + "') "//办理中和接单状态的操作人
- + " or (F_WoState in(" + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.receive + ") and F_NextDept='" + deptid + "')"//退回下一步操作人
- + ")"
- + " and isnull(F_IsUsed,'0')='0' ";
- return str;
- }
- public string GetHApproval(string user)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.audit + " and F_OptType=" + (int)EnumItemOpt.audit + "and F_NextUser= '" + user + "'" + "and F_IsUsed=2";
- return str;
- }
- /// <summary>
- /// 获取部门待完成的工单编号
- /// </summary>
- /// <returns></returns>
- public string GetDeptWorkOrderID(int deptid, string user)
- {
- string str = string.Empty;
- string deptuser = string.Empty;
- var dept = userAccountBLL.GetModelList("F_DeptId=" + deptid);
- if (dept != null)
- {
- foreach (var it in dept)
- {
- if (it.F_UserCode != user)
- {
- if (deptuser != "")
- deptuser += "','" + it.F_UserCode;
- else
- deptuser += it.F_UserCode;
- }
- }
- }
- if (!string.IsNullOrEmpty(deptuser))
- {
- // string deptuser = "select F_WoID from T_Sys_UserAccount where F_DeptId=" + deptid;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
- + " and isnull(F_IsUsed,'0')='0' " + " and "
- + "(F_WoState in(" + (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.abreback + ") and F_NextDept =" + deptid + ") "//办理中和接单状态的操作人
- + " or (F_WoState =" + (int)EnumWorkOrderState.abreback + " and F_NextUser in('" + deptuser + "'))";//退回下一步操作人
- }
- else
- {
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
- + " and "
- + "F_WoState in(" + (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.abreback + ") and F_NextDept =" + deptid + " "//办理中和接单状态的操作人
- + " and isnull(F_IsUsed,'0')='0' ";
- }
- return str;
- }
- /// <summary>
- /// 获取工单数量
- /// </summary>
- /// <returns></returns>
- public ActionResult GetWorkCount(string OpenId)
- {
- if (string .IsNullOrEmpty (OpenId) )
- return Success ("你的账号已在别处登录,你确定要再次登录吗?");
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua == null)
- {
- return Success("你的账号已在别处登录,你确定要再次登录吗?");
- }
- DataTable dt = new DataTable();
- #region 筛选条件
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- string uwhere = " ";
- string sql = "";
- if (!Refresh())
- {
- return Error("查询失败");
- }
- int YCD = 0, DJD = 0, DCL = 0, DSP = 0, YCL = 0, GCDBL = 0, YBL = 0, CQGD = 0, TD = 0,YFP=0;
- for (int i = 0; i <= 9; i++)
- {
-
- switch (i)
- {
- case 0://待接单的
- sql = "";
- sql += $" F_IsDelete=0";
- if (GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) != "")
- {
- sql += $" and F_State in("+ (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.assign + ") and T_Wo_WorkOrder.F_ID in ( " +
- GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) + ") "; ;
- }
- else
- {
- DJD = 0;
- break;
- }
- DJD = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//接单
- break;
- case 1://待完成的(待处理)
- sql = "";
- sql += $" F_IsDelete=0";
- if (GetDWCWorkOrderID(ua.F_UserCode,ua .F_DeptId ) != null)
- {
- sql += " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.reassign + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + ") and T_Wo_WorkOrder.F_ID in ( " + GetDWCWorkOrderID(ua.F_UserCode, ua.F_DeptId) + ") ";
- }
- else
- {
- DCL = 0;
- break;
- }
- DCL = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//已接单
- break;
- case 2://已完成的
- sql = "";
- sql += $" F_IsDelete=0";
- if (GetDeptUserCode(ua.F_DeptId) != "")
- {
- sql += " and F_State in(10,11) and F_DealBy in(" + GetDeptUserCode(ua.F_DeptId) + ") ";
- }
- //sql += " and F_State in(10,11) and F_DealBy = '" + ua.F_UserCode + "' ";
- YCL = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//已完成的
- break;
-
- case 3://待审批
- sql = "";
- sql += $" F_IsDelete=0";
- if (ro.F_RoleCode == "GC")
- {
- if (GetHApproval(ua.F_UserCode) != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetHApproval(ua.F_UserCode) + ") "; ;
- }
- }
- else
- {
- GCDBL = 0;
- break; ;
- }
- GCDBL = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//高层待审批
- break;
- case 4://已审批
- sql = "";
- sql += $" F_IsDelete=0";
- if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "GC")
- {
- if (GetApprovedOrderID(ua.F_UserCode) != "")
- {
- sql += $" and F_ID in ( " + GetApprovedOrderID(ua.F_UserCode) + ") "; ;
- }
- else
- {
- YBL = 0;
- break; ;
- }
- }
- else
- {
- YBL = 0;
- break; ;
- }
- YBL = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//已审批
- break;
- case 5://待审批
- sql = "";
- sql += $" F_IsDelete=0";
- if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL")
- {
- if (GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) + ") ";
- }
- else
- {
- DSP = 0;
- break; ;
- }
- }
- else
- {
- DSP = 0;
- break; ;
- }
- DSP = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//待审批
- break;
- case 6:
- sql = "";
- sql += $" F_IsDelete=0";
- sql += $" and F_CreateBy ='" + ua.F_UserCode + "'";
- YCD = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//业务员已创单
- break;
- case 7://超期
- sql = "";
- sql += $" F_IsDelete=0";
- sql += $" and F_IsOver=" + 1;
- sql += $" and F_State !=" + 11;
- if (ro.F_RoleCode == "YWY" || ro.F_RoleCode == "BLRY")
- {
- sql += $" and F_DealBy like '%" + ua.F_UserCode.Trim() + "%'";
- }
- else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
- {
- string detpid = "" + ua.F_DeptId;
- var deparmentlist = new List<Model.T_Sys_Department>();
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId; ;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- if (GetDeptWorkOrderID(detpid) != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid) + ") "; ;
- }
- else
- {
- CQGD = 0;
- break; ;
- }
- }
- else
- {
- CQGD = 0;
- break; ;
- }
- }
- else if (ro.F_RoleCode == "QTJS")
- {
- CQGD = 0;
- break; ;
- }
- CQGD = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//超期
- break;
- case 8://退单
- sql = "";
- sql += $" F_IsDelete=0";
- if (GetBackid(ua) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetBackid(ua) + ") ";
- }
- else
- {
- TD = 0;
- break;
- }
- TD = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//
- break;
- case 9://我参与的
- sql = "";
- sql += $" F_IsDelete=0";
- if (GetParticipateID(ua.F_UserCode) != "")
- {
- sql += " and T_Wo_WorkOrder.F_ID in ( " + GetParticipateID(ua.F_UserCode) + ") ";
- }
- else
- {
- YFP = 0;
- break;
- }
- YFP = new BLL.T_Wo_WorkOrder().GetModelList(sql).Count;//
- break;
- }
- }
- #endregion
- var obj = new
- {
- state = "success",
- message = "成功",
- DJD = DJD,//待接单
- DCL = DCL,//已接单(待处理)
- YCL = YCL,//已完成的
- GCDBL = GCDBL,//高层待审批
- YBL = YBL,//已审批
- DSP = DSP,//待审批
- YCD = YCD,//业务员已创单
- TD = TD,//退单
- CQGD = CQGD,//超期
- YFP= YFP
- };
- return Content(obj.ToJson()); ;
-
- }
- /// <summary>
- /// 注解
- /// </summary>
- /// <param name="orderid"></param>
- /// <param name="cont"></param>
- /// <returns></returns>
- public ActionResult Annotation(string OpenId, int orderid, string cont)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
- //验证信息
- if (model != null)
- {
- if (string.IsNullOrEmpty(model.F_Annotation))
- {
- model.F_Annotation = cont+"-"+ ua.F_UserName + "("+ua .F_WorkNumber +")"+DateTime .Now .ToString ("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- model.F_Annotation = model.F_Annotation + "。" + cont + "-" + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ;
- }
- var res = woBLL.Update(model);
- if (res)
- return Success("注解成功");
- else
- return Error("注解失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 审核工单
- /// </summary>
- public ActionResult GetApproval(string OpenId, long orderid, string AuditCont, int IsAudit = 0, int AuditState = 0, float overtime = 0, int sms = 0)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- var res = Approval(OpenId, orderid, AuditCont, ua, model, overtime, sms, IsAudit, AuditState);
- if (res)
- return Success("审核成功");
- else
- return Error("审核失败");
- }
- else
- return Error("工单不存在");
- }
- }
- return Error("OpenId不能为空");
- }
- /// <summary>
- /// 填写超时原因
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult Reasontimeout(string OpenId, long orderid, string cont)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- //验证信息
- if (model != null)
- {
- model.F_Reasontimeout = cont;
- bool n = woBLL.Update(model);
- if (n)
- return Success("填写成功");
- else
- return Error("填写失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 审核工单
- /// </summary>
- [WechatActionFilter]
- public bool Approval(string OpenId, long orderid, string AuditCont, Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, float overtime = 0, int sms = 0, int IsAudit = 0, int AuditState = 0)
- {
- bool res = true;
- string touser = ""; string tousername = "";
- string opt = "审核";
- #region 获取接收人
- string deptname = "";
- string deptmodelsname = "";
- int wostate = 0;
- var toussers = "";
- #region 上报
- if (IsAudit != 0)
- {
- if (GetUser(OpenId) != null)
- {
- var user = GetUser(OpenId);
- var deptmodel = departmentBLL.GetModel(user.F_DeptId);
- var deptmodels = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- if (deptmodels != null)
- {
- deptmodelsname = deptmodels.F_DeptName + "-";
- }
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.audit + " and F_CreateUser!=" + user.F_UserCode + " and F_OptType=" + (int)EnumItemOpt.audit + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- toussers = itemlast.F_CreateUser;
- wostate = 16;
- if (AuditState == 0)
- {
- opt = "同意上报";
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:同意上报" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.reaudit, user.F_UserCode, user.F_DeptId, nowUser, overtime, sms);
- var uaid = AddLog(model.F_ID, model.F_State.Value, deptname + user.F_UserName + "(" + user.F_WorkNumber + ")" + "待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, user.F_UserCode, user.F_DeptId, nowUser, overtime, sms);
- if (userid <= 0 || uaid <= 0)
- res = false;
- }
- else if (AuditState == 1)
- {
- opt = "驳回修订";
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:驳回修订" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.reback, toussers, 0, nowUser, overtime, sms);
- if (userid <= 0)
- res = false;
- }
- else
- {
- opt = "强制结案";
- wostate = 11;
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:强制结案" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.visit, "", 0, nowUser, overtime, sms);
- if (userid <= 0)
- res = false;
- }
- }
- else
- {
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(nowUser.F_RoleId);
- if (ro.F_RoleCode == "DQJL")
- {
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.audit + " and F_OptType=" + (int)EnumItemOpt.audit + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- toussers = itemlast.F_CreateUser;
- if (AuditState == 0)
- {
- opt = "同意上报";
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:同意上报" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.reaudit, "", 0, nowUser, overtime, sms);
- res = GetDaQucirCulation(AuditCont, nowUser, DateTime.Now.ToString(), model.F_ID, true);
- if (userid <= 0 || !res)
- res = false;
- wostate = 1;
- }
- else if (AuditState == 1)
- {
- opt = "驳回修订";
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:驳回修订" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.reback, toussers, 0, nowUser, overtime, sms);
- if (userid <= 0)
- res = false;
- wostate = 16;
- }
- else
- {
- opt = "强制结案";
- var userid = AddLog(model.F_ID, model.F_State.Value, deptmodelsname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "工单审批:强制结案" + AuditCont, (int)EnumItemType.audit, (int)EnumItemOpt.visit, "", 0, nowUser, overtime, sms);
- if (userid <= 0)
- res = false;
- wostate = 11;
- }
- }
- else
- {
- res = false;
- }
- }
- }
- #endregion
- #endregion
- if (res)
- {
- model.F_State = wostate;
- //处理内容
- if (!string.IsNullOrEmpty(AuditCont))
- model.F_AuditCont += AuditCont + ";";
- model.F_IsAudit = IsAudit;
- model.F_AuditState = AuditState;
- model.F_AuditBy = nowUser.F_UserCode;
- model.F_AuditOn = DateTime.Now;
- woBLL.Update(model);
- if (nowUser.F_UserCode != model.F_CreateBy)
- {
- sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//
- // var createmodel = userAccountBLL.GetModel(model.F_CreateBy); //
- // if (createmodel != null)
- // {
- // if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
- // {
- // sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
- // }
- // }
- }
- #region 向下一级操作人员推送消息
- if (!string.IsNullOrWhiteSpace(touser))
- {
- sendsysmsg(model, nowUser, touser, (int)model.F_ID, opt);//
- // var modelUser2 = userAccountBLL.GetModel(touser); //
- // if (modelUser2 != null)
- // {
- // if (!string.IsNullOrEmpty(modelUser2.F_WxOpenId))
- // {
- // sendwxmsg(model, modelUser2.F_WxOpenId, nowUser, opt);
- // }
- // }
- }
- #endregion 向下一级操作人员推送消息
- }
- else
- return false;
- return true;
- }
- /// <summary>
- /// 大区经理未审批流转市场管理科
- /// </summary>
- /// <param name="ua"></param>
- /// <param name="time"></param>
- /// <param name="id"></param>
- public bool GetDaQucirCulation(string AuditCont, Model.T_Sys_UserAccount ua, string time, long id, bool istrue)
- {
- DateTime times = DateTime.Parse(time).AddHours(24);
- Model.T_Wo_WorkOrder model = woBLL.GetModel(id);
- List<Model.T_Wo_WorkOrder> modeLlist = new List<Model.T_Wo_WorkOrder>();
- modeLlist.Add(model);
- List<WorkOrderNewInput> Input = modeltooip(modeLlist, ua);
- string cont = "";
- int dapt = 0, nextda = 0; string opt = "";
- var itemlast = itembll.GetModelList(" F_WoID='" + model.F_ID + "' order by F_ID desc").FirstOrDefault();
- int sms =(int ) itemlast.F_IsSMS;
- var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
- string deptname = "";
- if (deptmodel1 != null)
- {
- dapt = deptmodel1.F_ParentId;
- deptname = deptmodel1.F_DeptName;
- }
- int isbl = 0;
- if (dapt != 0)
- {
- if (dapt == 11)
- {
- isbl = 1;
- nextda = 37;
- opt = "流转市场管理科";
- }
- else if (dapt == 14)
- {
- isbl = 1;
- nextda = 57;
- opt = "流转营销管理处";
- }
- else if (dapt == 15)
- {
- isbl = 1;
- nextda = 74;
- opt = "流转策划推广";
- }
- else if (dapt == 16)
- {
- isbl = 1;
- nextda = 88;
- opt = "流转销售部";
- }
- else if (dapt == 18)
- {
- nextda = 18;
- opt = "流转车用尿素";
- }
- else if (ua.F_DeptId == 17 || ua.F_DeptId == 19 || ua.F_DeptId == 20 || ua.F_DeptId == 21)
- {
- isbl = 1;
- nextda = ua.F_DeptId;
- opt = "流转" + deptname;
- }
- }
- if (istrue)
- {
- cont = "大区经理已审批:" + AuditCont + "," + opt;
- }
- else
- {
- cont = "大区经理未审批" + opt;
- }
- if (nextda != 0)
- {
- var res = AssignWO(ua, model, Input[0], cont, "", nextda, 0, model .F_limit , sms, 0, 0, 0, time.ToString(), isbl);
- return res;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 查询工单详情
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetCustomDetails(string OpenId, int id)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- if (id <= 0)
- {
- return Error("请输入正确的id");
- }
- DataTable FileUrl = new DataTable();
- var list = new List<Model.T_Wo_WorkOrder>();
- var model = woBLL.GetModel(id);
- if (model != null)
- list.Add(model);
- var itemlasts = itembll.GetModelList(" F_WoID=" + +id + " ");
- ; var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- if (!string.IsNullOrEmpty(model.F_Files))
- {
- FileUrl = GetFileData(model.F_Files, configfj.F_ParamValue);
- }
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
-
- if (list.Count > 0)
- {
- List<WorkOrderNewInput> Input = modeltooip(list, ua);
- if (Input != null)
- {
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = Input,
- FileUrl,
- total = itemlasts,
- };
-
- return Content(obj.ToJson());
- }
- else
- {
- return Error("没有查询到此工单");
- }
- }
- else
- return Error("没有查询到此工单");
- }
- else
- {
- return Error("无操作权限!");
- }
- }
- /// <summary>
- /// 查询工单详情
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetDetails(string OpenId, int id)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- if (id <= 0)
- {
- return Error("请输入正确的id");
- }
- DataTable FileUrl = new DataTable();
- var list = new List<Model.T_Wo_WorkOrder>();
- var model = woBLL.GetModel(id);
- if (model != null)
- list.Add(model);
- var itemlasts = itembll.GetModelList(" F_WoID=" + +id + " ");
- ; var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- if (!string.IsNullOrEmpty(model.F_Files))
- {
- FileUrl = GetFileData(model.F_Files, configfj.F_ParamValue);
- }
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (model.F_Source != "3")
- {
- if (ua == null)
- {
- return Success("你的账号已在别处登录,你确定要再次登录吗?");
- }
- }
- if (list.Count > 0)
- {
- List<WorkOrderNewInput> Input = modeltooip(list, ua);
- if (Input != null)
- {
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = Input,
- FileUrl,
- total = itemlasts,
- };
- return Content(obj.ToJson());
- }
- else
- {
- return Error("没有查询到此工单");
- }
- }
- else
- return Error("没有查询到此工单");
- }
- else
- {
- return Error("无操作权限!");
- }
- }
- public string GetID(string str, long id)
- {
- if (str != "")
- {
- str += "," + id;
- }
- else
- {
- str += id;
- }
- return str;
- }
- public string GetDeptment(Model.T_Sys_UserAccount ua)
- {
- string detpid = "" + ua.F_DeptId;
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- var deparmentlist = new List<Model.T_Sys_Department>();
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- }
- return detpid;
- }
- /// <summary>
- /// 获取待审批的工单
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetApprovalOrderID(Model.T_Sys_UserAccount ua, string OpenId, string F_RoleCode)
- {
- string str = string.Empty;
- #region 查询自己名下未审批的工单列表
- var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_OptType in(" + (int)EnumItemOpt.audit + ")" + " and "
- + "F_WoState in(" + (int)EnumWorkOrderState.audit + ") and F_NextUser='" + ua.F_UserCode + "' "
- + "" + " ");
- foreach (var it in itemlast)
- {
- float hours = (DateTime.Now - DateTime.Parse(it.F_CreateTime.ToString())).Hours;
- int overtime = 0;
- if (!string .IsNullOrEmpty (it.F_LimitTime))
- {
- overtime = int.Parse(it.F_LimitTime);
- }
- int sms = int.Parse (it.F_IsSMS.ToString ());
- if (F_RoleCode == "DQJL")
- {
- if (hours >= 24)
- {
- GetDaQucirCulation("", ua, it.F_CreateTime.ToString(), it.F_WoID, false);
- }
- else
- {
- str = GetID(str, it.F_WoID);
- }
- }
- else
- {
- var user = GetUser(OpenId);
- string deptname = "";
- string deptmodelsname = "";
- var deptmodel = departmentBLL.GetModel(user.F_DeptId);
- var deptmodels = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- if (deptmodels != null)
- {
- deptmodelsname = deptmodels.F_DeptName + "-";
- }
- if (hours >= 24)
- {
- DateTime time = DateTime.Parse(it.F_CreateTime.ToString()).AddHours(24);
- Model.T_Wo_WorkOrder model = woBLL.GetModel(it.F_WoID);
- AddLog(model.F_ID, model.F_State.Value, deptmodelsname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "未审批流转大区经理", (int)EnumItemType.audit, (int)EnumItemOpt.audit, user.F_UserCode, user.F_DeptId, ua, overtime, sms );
- AddLog(model.F_ID, model.F_State.Value, deptname + user.F_UserName + "(" + user.F_WorkNumber + ")" + "待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, user.F_UserCode, user.F_DeptId, user, overtime, sms);
- }
- else if (hours >= 48)
- {
- GetDaQucirCulation("", user, it.F_CreateTime.ToString(), it.F_WoID, false);
- }
- else
- {
- str = GetID(str, it.F_WoID);
- }
- }
- }
- #endregion
- if (F_RoleCode == "DQJL")
- {
- if (!string.IsNullOrEmpty(GetDeptment(ua)))
- {
- var itemlasts = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_OptType in(" + (int)EnumItemOpt.audit + ")" + " and "
- + "F_WoState in(" + (int)EnumWorkOrderState.audit + ") and F_NextUser in ( " + GetDeptment(ua) + ") ");
- foreach (var it in itemlasts)
- {
- int overtime = 0;
- if (!string.IsNullOrEmpty(it.F_LimitTime))
- {
- overtime = int.Parse(it.F_LimitTime);
- }
- int sms = int.Parse(it.F_IsSMS.ToString());
- float hours = (DateTime.Now - DateTime.Parse(it.F_CreateTime.ToString())).Hours;
- if (F_RoleCode == "DQJL")
- {
- if (hours >= 24)
- {
- Model.T_Sys_UserAccount user = userAccountBLL.GetModel(it.F_CreateUser);
- DateTime time = DateTime.Parse(it.F_CreateTime.ToString()).AddHours(24);
- Model.T_Wo_WorkOrder model = woBLL.GetModel(it.F_WoID);
- string deptname = "";
- string deptmodelsname = "";
- var deptmodel = departmentBLL.GetModel(user.F_DeptId);
- var deptmodels = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- if (deptmodels != null)
- {
- deptmodelsname = deptmodels.F_DeptName + "-";
- }
- AddLog(model.F_ID, model.F_State.Value, deptmodelsname + user.F_UserName + "(" + user.F_WorkNumber + ")" + "未审批流转大区经理", (int)EnumItemType.audit, (int)EnumItemOpt.audit, ua.F_UserCode, ua.F_DeptId, user, overtime, sms);
- AddLog(model.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, ua.F_UserCode, ua.F_DeptId, ua, overtime, sms );
- if (hours < 48)
- {
- str = GetID(str, it.F_WoID);
- }
- else
- {
- GetDaQucirCulation("", ua, time.ToString(), it.F_WoID, false);
- }
- }
- }
- }
- }
- }
- return str;
- }
- /// <summary>
- /// 获取已审批的工单列表
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetApprovedOrderID(string user)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType=" + (int)EnumItemOpt.reaudit
- + " and F_CreateUser=" + user + " "//
- ;
- return str;
- }
- /// <summary>
- /// 获取已审批的工单列表
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetApprovedOrderID()
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType=" + (int)EnumItemOpt.reaudit
- //
- ;
- return str;
- }
- /// <summary>
- /// 根据model返回CustomerBaseNewInput对象
- /// </summary>
- private List<WorkOrderNewInput> modeltooip(List<Model.T_Wo_WorkOrder> model1, Model.T_Sys_UserAccount ua)
- {
- if (model1 != null && model1.Count > 0)
- {
- List<WorkOrderNewInput> Input = new List<WorkOrderNewInput>(model1.Count);
- for (int i = 0; i < model1.Count; i++)
- {
- WorkOrderNewInput model = new WorkOrderNewInput();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(model1[i].F_CustomerID))
- {
- cuModel = customerBaseBLL.GetModel(model1[i].F_CustomerID.ToString());//通过客户编号获取客户资料
- }
- else
- {
- var sql = $" and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'";
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 " + sql).FirstOrDefault();
- }
- if (cuModel != null)
- {
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- model.F_AreaName = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new Model.T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- model.F_BranchName = pdModel1.F_DeptName;
- }
- }
- model.F_CompanyName = cuModel.F_CompanyName;//公司名称
- model.F_CustomerID = cuModel.F_CustomerCode;//客户编码
- model.F_Salesman = cuModel.F_Salesman;
- model.F_SalesPhone = cuModel.F_SalesPhone;
- model.F_Legal = cuModel.F_Legal;
- model.F_LegalPhone = cuModel.F_LegalPhone;
- model.F_AddressProvince = cuModel.F_AddressProvince;
- model.F_AddressCity = cuModel.F_AddressCity;
- model.F_AddressCountry = cuModel.F_AddressCountry;
- model.F_AddressTownship = cuModel.F_AddressTownship;
- model.F_AddressFull = cuModel.F_AddressFull;
- model.F_Brands = cuModel.F_Brands;
- model.F_Channel = cuModel.F_Channel;
- model.F_IsRunXLX = cuModel.F_IsRunXLX;
- model.F_AnnualSales = cuModel.F_AnnualSales;
- model.F_Formula = cuModel.F_Formula;
- model.F_RaiseCrops = cuModel.F_RaiseCrops;
- model.F_PlantingArea = cuModel.F_PlantingArea;
- model.F_FertilizerBrand = cuModel.F_FertilizerBrand;
- }
- if (valcode(model1[i].F_MaterialID.ToString(), 11))
- {
- model.F_MaterialID = model1[i].F_MaterialID;//验证物料编码为11位纯数字
- Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(model1[i].F_MaterialID.ToString());//通过物料编码获取物料信息
- if (maModel != null)
- {
- model.F_MaterialName = maModel.F_MaterialName;
- model.F_Model = maModel.F_Model;
- model.F_Specs = maModel.F_Specs;
- model.F_Level1 = maModel.F_Level1;
- model.F_Level2 = maModel.F_Level2;
- model.F_Level3 = maModel.F_Level3;
- model.F_Brand = maModel.F_Brand;
- model.F_MaterialEffect = maModel.F_MaterialEffect;
- model.F_Pipeline = maModel.F_Pipeline;
- model.F_Craft = maModel.F_Craft;
- }
- }
- #region 基本字段
- model.F_ID = model1[i].F_ID;//
- model.F_WorkOrderCode = model1[i].F_WorkOrderCode;//工单编号
- #region
- if (!string.IsNullOrEmpty(model1[i].F_Source))
- {
- model.F_Source = int.Parse(model1[i].F_Source);//工单来源
- }
- if (model1[i].F_Source == "1")
- {
- model.F_SourceName = "电话";
- }
- else if (model1[i].F_Source == "2")
- {
- model.F_SourceName = "微信业务员";
- }
- else if (model1[i].F_Source == "3")
- {
- model.F_SourceName = "微信客户";
- }
- else
- {
- model.F_SourceName = "官网";
- }
- model.F_Type = int.Parse(model1[i].F_Type);//工单来源
- if (model1[i].F_Type == "1")
- {
- model.F_TypeName = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (model1[i].F_Type == "2")
- {
- model.F_TypeName = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (model1[i].F_Type == "3")
- {
- model.F_TypeName = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else
- {
- model.F_TypeName = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- model.F_State = model1[i].F_State;
- if (model1[i].F_State == 0)//工单状态
- {
- model.F_StateName = "待指派";
- }
- else if (model1[i].F_State == 1)
- {
- model.F_StateName = "待接单";
- }
- else if (model1[i].F_State == 2)
- {
- model.F_StateName = "待处理";
- }
- else if (model1[i].F_State == 3)
- {
- model.F_StateName = "已退回";
- }
- else if (model1[i].F_State == 4)
- {
- model.F_StateName = "异常退回";
- }
- else if (model1[i].F_State == 5)
- {
- model.F_StateName = "处理中";
- }
- else if (model1[i].F_State == 6)
- {
- model.F_StateName = "待回访";
- }
- else if (model1[i].F_State == 7)
- {
- model.F_StateName = "待完结";
- }
- else if (model1[i].F_State == 10)
- {
- model.F_StateName = "已处理";
- }
- else if (model1[i].F_State == 11)
- {
- model.F_StateName = "已评价";
- }
- else if (model1[i].F_State == 12)
- {
- model.F_StateName = "已退回";
- }
- else if (model1[i].F_State == 14)
- {
- model.F_StateName = "待办理";
- }
- else if (model1[i].F_State == 15)
- {
- model.F_StateName = "微信未通过";
- }
- else if (model1[i].F_State == 16)
- {
- model.F_StateName = "待办理";
- }
- #endregion
- model.F_CusName = model1[i].F_CusName;//客户姓名
- model.F_CusPhone = model1[i].F_CusPhone;//客户电话
- model.F_Canal = model1[i].F_Canal;//
- model.F_IncidentProvince = model1[i].F_IncidentProvince;//事发地-省
- model.F_IncidentCity = model1[i].F_IncidentCity;//事发地-市
- model.F_IncidentCountry = model1[i].F_IncidentCountry;//事发地-县
- model.F_IncidentTownship = model1[i].F_IncidentTownship;//事发地-乡
- model.F_IncidentDetailed = model1[i].F_IncidentDetailed;//事发地-详细
- model.F_SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- model.F_Description = model1[i].F_Description;//问题描述
- model.F_Files = "0";//附件上传ids
- model.F_DealType = model1[i].F_DealType;//处理方式:当即办理、电话转接、网络转办(点选)
- #endregion
- if (!string.IsNullOrEmpty(model1[i].F_QuestionType))
- {
- try
- {
- int b = int.Parse(model1[i].F_QuestionType.Trim());
- Model.T_Wo_QuestionManage manage = quesBLL.GetModel(b);
- if (manage != null)
- {
- model.F_QuestionType = manage.F_QuestionName;
- model.F_QuestionTypeid = manage.F_Id;
- if (manage.F_Label == "3")
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(manage.F_ParentId.ToString()));//获取问题类别
- Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
- model.F_QuestionTypeone = Manage2.F_QuestionName;//问题类别1
- model.F_QuestionTypeoneid = Manage2.F_Id;//问题类别1
- model.F_QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
- model.F_QuestionTypetwoid = Manage1.F_Id;//问题类别1
- }
- }
- }
- catch (Exception)
- {
- model.F_QuestionType = model1[i].F_QuestionType; //问题类别(投诉抽捡和咨询类别不一样)
- }
- }
- model.F_Annotation = model1[i].F_Annotation; ;//注解
- #region 投诉类
- model.F_BatchNumber = model1[i].F_BatchNumber;//生产批次号
- model.F_TS_Formula = model1[i].F_TS_Formula;// 投诉-配方
- model.F_TS_Category = model1[i].F_TS_Category;//投诉-产品种类:化肥、化工、其他
- if (!string.IsNullOrEmpty(model1[i].F_TS_Quantity))
- {
- model.F_TS_Quantity = model1[i].F_TS_Quantity ;//投诉-问题数量(吨)
- }
- else
- model.F_TS_Quantity = "";
- model.F_TS_Level = model1[i].F_TS_Level;//投诉-重要级别:轻微、一般、较大、重大
- #endregion
- #region 咨询类
- // model.F_ZX_ProName = model1[i].F_ZX_ProName;//咨询-产品名称:三聚氰胺、甲醇、液氨、二甲醚、糠醇、其他
- model.F_ZX_Quantity = model1[i].F_ZX_Quantity;// 咨询-问题数量(吨)
- model.F_ZX_Area = model1[i].F_ZX_Area;// 咨询-大区
- model.F_ZX_Branch = model1[i].F_ZX_Branch;// 咨询-分公司
- #endregion
- #region 抽检类
- model.F_CJ_Time = model1[i].F_CJ_Time;// 抽检-抽检时间
- model.F_CJ_Level = model1[i].F_CJ_Level;// 抽检-抽检级别:乡镇级、县级、市级、省级及以上、个人送检
- model.F_CJ_Unit = model1[i].F_CJ_Unit;// 抽检-抽检单位:市场监督、农业部、土肥站、工商、联合执法、其他
- model.F_CJ_TestUnit = model1[i].F_CJ_TestUnit;//抽检-化验单位
- model.F_CJ_Tonnage = model1[i].F_CJ_Tonnage;//抽检-抽检吨数
- model.F_CJ_BagNo = model1[i].F_CJ_BagNo;//抽检-抽检袋数
- model.F_CJ_Outlay = model1[i].F_CJ_Outlay;//抽检-公关费用金额:单位元
- model.F_WorkerBrand = model1[i].F_Brand;//工单品牌
- model.F_DealBy = model1[i].F_DealBy;//处理人
- model.F_DealTime = model1[i].F_DealTime;//处理时间
- model.F_DealContent = model1[i].F_DealContent;//处理内容
- model.F_DealResult = model1[i].F_DealResult;//处理结果
- model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
- model.F_SC_ProductBase = model1[i].F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
- model.F_SC_PreliminaryOpinion = model1[i].F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
- model.F_SC_QualityMonth = model1[i].F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
- model.F_SC_CJ_SpotResult = model1[i].F_SC_CJ_SpotResult;/// 市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
- model.F_SC_CJ_SelfResult = model1[i].F_SC_CJ_SelfResult;//市场管理科-抽检-自检结果
- model.F_SC_CJ_ApprovalNo = model1[i].F_SC_CJ_ApprovalNo;// 市场管理科-抽检-对应审批工作流单号
- model.F_SC_CJ_ReturnAccount = model1[i].F_SC_CJ_ReturnAccount;//市场管理科-抽检-确认返账金额(元)
- model.F_ZL_QualityEventLevel = model1[i].F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
- model.F_ZL_ClaimAmount = model1[i].F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
- model.F_ZL_ResponsibleUnit = model1[i].F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
- model.F_ZL_ApprovalOpinions = model1[i].F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
- model.F_ZL_ApprovalDisagree = model1[i].F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
- model.F_ZL_CompensationMethod = model1[i].F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
- model.F_ZL_CompensationMoney = model1[i].F_ZL_CompensationMoney;// 质量管理科-补偿钱款
- model.F_ZL_CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
- model.F_ZL_Fquantity = model1[i].F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
- model.F_ZL_ImprovementRequirements = model1[i].F_ZL_ImprovementRequirements;//质量管理科-改进要求
- model.F_ZL_CApprovalNo = model1[i].F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
- model.F_ZL_CJ_IsRecord = model1[i].F_ZL_CJ_IsRecord;//质量管理科-抽检-未备案、已备案
- model.F_VisitRemarks = model1[i].F_VisitRemarks;//回访备注
- model.SuperiorOpinion = AssCont(model1[i].F_ID);//上级处理意见
- model.F_Reasontimeout= model1[i].F_Reasontimeout;//超期原因
- if (model1[i].F_SMSReply == 1)
- {
- model.F_SMSReply = "满意";//短信回访结果
- }
- else if (model1[i].F_SMSReply == 2)
- {
- model.F_SMSReply = "一般";//短信回访结果
- }
- else if (model1[i].F_SMSReply == 3)
- {
- model.F_SMSReply = "不满意";//短信回访结果
- }
- else
- {
- model.F_SMSReply = "";//短信回访结果
- }
- if (model1[i].F_IsVisit != 0)
- {
- model.F_IsVisit = "是";//是否回访
- }
- else
- {
- model.F_IsVisit = "否";//是否回访
- }
- model.F_IsAudit = model1[i].F_IsAudit;//是否审核
- model.F_Highopinions = model1[i].F_Highopinions;//高层处理意见
- model.F_CreateOn = model1[i].F_CreateOn; ;//添加时间
- // model.F_CreateBy = model1[i].F_CreateBy; ;//添加人
- if (!string.IsNullOrEmpty(model1[i].F_CreateBy))
- {
- Model.T_Sys_UserAccount creatname = userAccountBLL.GetModel(model1[i].F_CreateBy);
- if (creatname != null)
- {
- model.F_CreateBy = creatname.F_WorkNumber; ;//添加人
- model.F_CreateName = creatname.F_UserName; ;//添加人
- model.F_CreatePhone = creatname.F_Mobile;
- model.CreateName = creatname.F_UserName + "(" + creatname.F_WorkNumber + ")";
- }
- }
- model.F_UpdateBy = model1[i].F_UpdateBy;//修改人工号
- model.F_UpdateOn = model1[i].F_UpdateOn; ;//修改人工号
- if (model1[i].F_IsAudit != 0 && model1[i].F_IsAudit != null)
- {
- if (model1[i].F_AuditState == 0)
- {
- model.F_AuditState = "同意上报";
- }
- else if (model1[i].F_AuditState == 1)
- {
- model.F_AuditState = "驳回修订";
- }
- else
- {
- model.F_AuditState = "强制结案";
- }
- }
- else
- {
- model.F_AuditState = "";
- }
-
- model.F_AuditBy = model1[i].F_AuditBy;//审核人
- model.F_AuditOn = model1[i].F_AuditOn;//审核时间
- model.F_AuditCont = model1[i].F_AuditCont;//审核内容
- model.RemainingTime = float.Parse(string.Format("{0:f2}", TimeToOver(model1[i].F_ID, model1[i].F_limit)));
- if (ua != null)
- {
- var itemlast = itembll.GetModelList(" F_WoID='" + model.F_ID + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- model.F_UserCode = itemlast.F_CreateUser;
- if (!string.IsNullOrEmpty(model.F_UserCode))
- {
- Model.T_Sys_UserAccount user = userAccountBLL.GetModel(model.F_UserCode);
- model.F_UserName = user.F_UserName;
- Model.T_Sys_Department dept = departmentBLL.GetModel(user.F_DeptId);
- if (dept != null)
- {
- model.F_NextDeptName = dept.F_DeptName;
- }
- }
- }
- if (model1[i].F_Type !="3")
- {
- if (TimeToOver(model1[i].F_ID, model1[i].F_limit) < 0)
- {
- model.F_IsOver = 1;
- }
- else
- {
- model.F_IsOver = model1[i].F_IsOver;
- }
- }
- if (ua != null)
- {
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- model.F_Deptid = deptmodel.F_DeptId;
- model.F_DeptName = deptmodel.F_DeptName;
- }
- }
- #endregion
- Input.Add(model);
- }
- return Input;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 是否超时
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- private float TimeToOver(int id, int limit)
- {
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id );
- string time1 = "", time2 = ""; int x = 0, y = 0;
- if (itemlasts.Count > 0)
- {
- for (int z = 0; z < itemlasts.Count; z++)
- {
- if (itemlasts[z].F_WoState >= 1)
- {
- if (itemlasts[z].F_WoState == 1)
- {
- x = z;
- time1 = itemlasts[z].F_CreateTime.ToString();
- break;
- }
- }
- }
- for (int i = 0; i < itemlasts.Count; i++)
- {
- if (itemlasts[i].F_WoState >= 1)
- {
-
- if (itemlasts[i].F_WoState == 11)
- {
- y = i;
- time2 = itemlasts[i].F_CreateTime.ToString();
- }
- }
- }
- if (time2 != "")
- {
- if (time1 != "")
- {
- if (x > y)
- {
- System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
- float b = limit - (float)a.TotalHours;
- return b;
- }
- else
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- float b = limit - (float)a.TotalHours;
- return b;
- }
- }
- else
- {
- return 0;
- }
- }
- else if (time1 != "")
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- float b = limit - (float)a.TotalHours;
- return b;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- private string AssCont(int id)
- {
- string cont = "";
- var itemlist = itembll.GetModelList("F_WoID=" + id + "and F_IsUsed=0" + "order by F_ID desc");
- if (itemlist.Count > 0)
- {
- cont = itemlist[0].F_OptContent;
- }
- return cont;
- }
- /// <summary>
- /// 获取当前用户上一级的用户
- /// </summary>
- /// <param name="OpenId"></param>
- /// <returns></returns>
- public Model.T_Sys_UserAccount GetUser(string OpenId)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- // int userId = CurrentUser.UserData.F_UserId;
- // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- // var dept = departmentBLL.GetModel(deptmodel.F_ParentId);
- #region 业务员
- if (ro.F_RoleCode == "YWY")
- {
- if (deptmodel != null)
- {
- if (deptmodel.F_Layer == 2)
- {
- Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + deptmodel.F_DeptId + " and F_RoleId=60 ").FirstOrDefault();
- if (userModel!=null )
- return userModel;
- else
- {
- var dept = departmentBLL.GetModel(deptmodel.F_ParentId);
- if (dept != null)
- {
- Model.T_Sys_UserAccount userModel1 = userAccountBLL.GetModelList(" F_DeptId=" + dept.F_DeptId + " and F_RoleId=62 ").FirstOrDefault();
- return userModel1;
- }
- }
- }
- if (deptmodel.F_Layer == 1)
- {
- Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + deptmodel.F_DeptId + " and F_RoleId=62 ").FirstOrDefault();
- return userModel;
- }
- }
- else
- {
- return null;
- }
- }
- #endregion
- #region 大区经理
- else if (ro.F_RoleCode == "DQJL")
- {
- return null;
- }
- #endregion
- #region 分公司经理
- else if (ro.F_RoleCode == "FGSJL")
- {
- if (deptmodel != null)
- {
- var dept = departmentBLL.GetModel(deptmodel.F_ParentId);
- if (dept != null)
- {
- Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + dept.F_DeptId + " and F_RoleId=62 ").FirstOrDefault();
- if (userModel!=null )
- return userModel;
-
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- }
- #endregion
- }
- return null;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 获取上一级管理员
- /// </summary>
- /// <param name="OpenId"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult GetDpment(string OpenId)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- if (GetUser(OpenId) != null)
- {
- return Success("获取成功!", GetUser(OpenId));
- }
- else
- {
- return Success("获取失败!", null);
- }
- }
- else
- {
- return Error("OpenId不能为空!");
- }
- }
- /// <summary>
- /// 修改密码
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult UpdatePassWord()
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- //5--业主(客户档案会员)
- int usertype = RequestString.GetInt("usertype", 0);
- //原密码
- string oldpwd = RequestString.GetFormString("oldpwd").Trim();
- string pwd = RequestString.GetFormString("pwd").Trim();
- string repeatpwd = RequestString.GetFormString("repeatpwd").Trim();
- if (usertype == 0)
- return Error("无权修改密码");
- if (string.IsNullOrWhiteSpace(oldpwd))
- return Error("请输入原密码");
- if (string.IsNullOrWhiteSpace(pwd))
- return Error("请输入新密码");
- if (string.IsNullOrWhiteSpace(repeatpwd))
- return Error("请再次输入新密码");
- if (!pwd.Equals(repeatpwd))
- return Error("两个新密码不同,请重新输入");
- var model = new Model.T_Sys_UserAccount();
- var modelCus = new Model.T_Cus_CustomerBaseNew();
- //坐席表
- if (usertype < 5)
- {
- model = userAccountBLL.GetModelByOpenid(stropenid);
- if (model != null)
- {
- if (!model.F_Password.Equals(oldpwd)) return Error("原密码不正确");
- model.F_Password = pwd;
- if (userAccountBLL.Update(model))
- return Success("重置密码成功");
- }
- return Error("重置密码失败");
- }
- //客户档案表
- modelCus = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();//customerBaseBLL.GetModelByOpenid(stropenid);
- if (modelCus != null)
- {
- if (!modelCus.F_WxPassword.Equals(oldpwd)) return Error("原密码不正确");
- modelCus.F_WxPassword = pwd;
- if (customerBaseBLL.Update(modelCus))
- return Success("重置密码成功");
- }
- return Error("重置密码失败");
- }
- /// <summary>
- /// 验证生产批次号为15位
- /// </summary>
- private bool vaBatchNumber(string code)
- {
- var res = false;
- if (code.Length == 15)
- {
- char chr = code[12];
- if (chr > 'A' && chr < 'Z')
- {
- string code1 = code.Substring(0, 12);
- string code2 = code.Substring(15 - 2, 2);
- if (Regex.IsMatch(code1, @"^\d{12}$") && Regex.IsMatch(code2, @"^\d{2}$"))
- res = true;
- }
- else
- {
- res = false;
- }
- }
- return res;
- }
- /// <summary>
- /// 验证物料编码为10位纯数字
- /// </summary>
- private bool valcode(string code, int number)
- {
- var res = false;
- //11位数字
- if (code.Length == number && Regex.IsMatch(code, @"^\d{" + number + "}$"))
- res = true;
- return res;
- }
- /// <summary>
- /// 验证物料编号是否唯一
- /// </summary>
- private bool gematerque(int id, string code)
- {
- var sql = " F_IsDelete=0 ";
- sql += "and (F_MaterialCode='" + code + "')";
- if (id > 0)
- sql += " and F_Id<>" + id;
- var count = mmBLL.GetModelList(sql).Count();
- return count > 0;
- }
- /// <summary>
- /// 验证客户编号是否唯一
- /// </summary>
- private bool getunique(int id, string code)
- {
- var sql = " F_IsDelete=0 ";
- sql += "and (F_CustomerCode='" + code + "')";
- if (id > 0)
- sql += " and F_CustomerId<>" + id;
- var count = customerBaseBLL.GetModelList(sql).Count();
- return count > 0;
- }
- /// <summary>
- /// 获取我参与的工单编号
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetParticipateID(string user)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") and F_OptType in( 0,1,7 )";
- ;
- return str;
- }
- /// <summary>
- /// 获取我参与的工单编号
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetParticipate(string user)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") ";
- ;
- return str;
- }
- private bool IsCustomerBaseNew(WorkOrderNewInput input)
- {
- bool n = false;
- if (!string.IsNullOrEmpty(input.F_CustomerID) || !string.IsNullOrEmpty(input.F_CompanyName)
- || !string.IsNullOrEmpty(input.F_AreaName) || !string.IsNullOrEmpty(input.F_BranchName)
- || !string.IsNullOrEmpty(input.F_Salesman) || !string.IsNullOrEmpty(input.F_SalesPhone)
- || !string.IsNullOrEmpty(input.F_Brands) )
- {
- n = true;
- }
- return n;
- }
- /// <summary>
- /// 添加客户
- /// </summary>
- private Model.T_Cus_CustomerBaseNew inputtooCustomer(Model.T_Cus_CustomerBaseNew model, WorkOrderNewInput input)
- {
- var newmodel = model;
- if (!string.IsNullOrWhiteSpace(input.F_CustomerID.ToString()))
- model.F_CustomerCode = input.F_CustomerID.ToString();
- else
- model.F_CustomerCode = model.F_CustomerCode;
- if (!string.IsNullOrWhiteSpace(input.F_CompanyName))
- model.F_CompanyName = input.F_CompanyName;
- #region 基本字段
- if (!string.IsNullOrEmpty(input.F_AreaName))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_AreaName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_AreaName);
- }
- model.F_AreaID = pdModel.F_DeptId.ToString();
- }
- if (!string.IsNullOrEmpty(input.F_BranchName))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_BranchName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_BranchName);
- }
- model.F_BranchID = pdModel.F_DeptId.ToString();
- }
- model.F_Salesman = input.F_Salesman;//业务员
- model.F_SalesPhone = input.F_SalesPhone;//业务员电话
- model.F_Channel = input.F_Channel;// 渠道类型:总经销、二级商、种田大户、农户、化工客户、公司员工
- model.F_Legal = input.F_CusName;//法人
- model.F_LegalPhone = input.F_CusPhone;//法人电话
- model.F_AddressProvince = input.F_AddressProvince;//省
- model.F_AddressCity = input.F_AddressCity;//市
- model.F_AddressCountry = input.F_AddressCountry;//县
- model.F_AddressTownship = input.F_AddressTownship;//乡
- model.F_AddressFull = input.F_AddressFull;//详细地址
- model.F_Brands = input.F_Brands;// 经营品牌:心连心、手拉手、沃利沃、双心、空
- model.F_IsRunXLX = input.F_IsRunXLX;// 是否经营心连心:是、否
- model.F_AnnualSales = input.F_AnnualSales;//年销量
- model.F_Formula = input.F_Formula;//配方
- model.F_RaiseCrops = input.F_RaiseCrops;//种植作物
- model.F_PlantingArea = input.F_PlantingArea;//种植面积
- model.F_FertilizerBrand = input.F_FertilizerBrand;//用肥品牌
- model.F_FileId = 0;
- #endregion
- return model;
- }
- private string GetCusCode(int i)
- {
- DateTime times = DateTime.Now.AddMinutes(i);
- string time = times.ToString("yyMMddhhmm");
- return time;
- }
- private string GetIntCode()
- {
- string time = DateTime.Now.ToString("hhmmss");
- Random ran = new Random();
- int RandKey = ran.Next(1000, 9999);
- string timecode = 3 + "" + RandKey + "" + time;
- return timecode;
- }
- private bool IsMaterial(WorkOrderNewInput input)
- {
- bool n = false;
- if (!string.IsNullOrEmpty(input.F_MaterialID) || !string.IsNullOrEmpty(input.F_MaterialName)
- || !string.IsNullOrEmpty(input.F_Model) || !string.IsNullOrEmpty(input.F_Specs)
- || !string.IsNullOrEmpty(input.F_Level1) || !string.IsNullOrEmpty(input.F_Level2)
- || !string.IsNullOrEmpty(input.F_Level3) || !string.IsNullOrEmpty(input.F_Brand)
- || !string.IsNullOrEmpty(input.F_MaterialEffect) || !string.IsNullOrEmpty(input.F_Craft)
- || !string.IsNullOrEmpty(input.F_Pipeline))
- {
- n = true;
- }
- return n;
- }
- private void AddMait(WorkOrderNewInput input, string usercode)
- {
- Model.T_Wo_MaterialManage dModel = new Model.T_Wo_MaterialManage();
- dModel.F_MaterialCode = input.F_MaterialID.ToString();//物料编号
- dModel.F_MaterialName = input.F_MaterialName;//物料名称
- dModel.F_Model = input.F_Model;//型号
- dModel.F_Specs = input.F_Specs;//规格
- dModel.F_Level1 = input.F_Level1;//一级分类
- dModel.F_Level2 = input.F_Level2;//二级分类
- dModel.F_Level3 = input.F_Level3;//三级分类
- dModel.F_Brand = input.F_Brand;//品牌
- dModel.F_MaterialEffect = input.F_MaterialEffect;//复合肥肥效
- dModel.F_Craft = input.F_Craft;//工艺
- dModel.F_Pipeline = input.F_Pipeline;//产品线
- dModel.F_IsDelete = 0;
- dModel.F_CreateOn = DateTime.Now;
- dModel.F_CreateBy = usercode;
- int f = mmBLL.Add(dModel);
- }
- /// <summary>
- /// 根据传入的对象和input的内容返回对象(添加修改使用)
- /// </summary>
- private Model.T_Wo_WorkOrder inputtoobj(Model.T_Sys_UserAccount ua, Model.T_Wo_WorkOrder model, WorkOrderNewInput input, int type)
- {
- string usercode = "";
- if (ua != null)
- {
- usercode = ua.F_UserCode;
- }
- var newmodel = model;
- if (input.F_ID != 0)
- {
- model.F_ID = input.F_ID;
- }
- else
- {
- model.F_ID = model.F_ID;//工单ID
- }
- if (type == 2)
- {
- model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
- model.F_Source = model.F_Source;
- }
- else
- {
- model.F_WorkOrderCode = model.F_WorkOrderCode;//工单编号
- model.F_Source = model.F_Source.ToString();//工单来源
- }
- if (input.F_Type == 2 || input.F_Type == 3)
- {
- if (string.IsNullOrEmpty(input.F_CustomerID))
- {
- var sql = $" and F_LegalPhone = '" + input.F_CusPhone.Trim() + "'";
- var Customer = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 " + sql).FirstOrDefault(); ;
- if (Customer != null)
- {
- model.F_CustomerID = Customer.F_CustomerCode;
- if (!string.IsNullOrEmpty(input.F_Salesman))
- Customer.F_Salesman = input.F_Salesman;
- if (!string.IsNullOrEmpty(input.F_SalesPhone))
- Customer.F_SalesPhone = input.F_SalesPhone;
- if (!string.IsNullOrEmpty(input.F_Brands))
- Customer.F_SalesPhone = input.F_Brands;
- if (!string.IsNullOrEmpty(input.F_AreaName))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_AreaName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_AreaName);
- }
- Customer.F_AreaID = pdModel.F_DeptId.ToString();
- }
- else
- {
- Customer.F_AreaID = "";
- }
- if (!string.IsNullOrEmpty(input.F_BranchName))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_BranchName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_BranchName);
- }
- Customer.F_BranchID = pdModel.F_DeptId.ToString();
- }
- else
- {
- Customer.F_BranchID = "";
- }
- if (!string.IsNullOrEmpty(input.F_CompanyName ))
- Customer.F_CompanyName = input.F_CompanyName;
- customerBaseBLL.Update(Customer);
- }
- else
- {
- if (IsCustomerBaseNew(input))
- {
-
- if (string.IsNullOrEmpty(input.F_CustomerID))
- {
- int i = 0;
- while (true)
- {
-
- if (!getunique(0, GetCusCode(i)))
- {
- input.F_CustomerID = GetCusCode(i);
- break;
- }
- else
- {
- i++;
- }
- }
- }
- var CustomerBaseNewmodel = new Model.T_Cus_CustomerBaseNew();
- CustomerBaseNewmodel.F_CustomerCode = input.F_CustomerID;
- CustomerBaseNewmodel.F_CreateBy = usercode;
- CustomerBaseNewmodel.F_CreateOn = DateTime.Now;
- CustomerBaseNewmodel.F_IsDelete = 0;
- customerBaseBLL.Add(inputtooCustomer(CustomerBaseNewmodel, input));
- }
- }
- }
- else
- {
- var Customer = customerBaseBLL.GetModel(input.F_CustomerID.Trim());
- if (Customer != null)
- {
- if (!string.IsNullOrEmpty(input.F_Salesman))
- Customer.F_Salesman = input.F_Salesman;
- if (!string.IsNullOrEmpty(input.F_SalesPhone))
- Customer.F_SalesPhone = input.F_SalesPhone;
- if (!string.IsNullOrEmpty(input.F_Brands))
- Customer.F_Brands = input.F_Brands;
- if (!string.IsNullOrEmpty(input.F_CompanyName))
- Customer.F_CompanyName = input.F_CompanyName.Trim();
- if (!string.IsNullOrEmpty(input.F_AreaName))
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_AreaName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_AreaName);
- }
- Customer.F_AreaID = pdModel.F_DeptId.ToString();
- }
- else
- {
- Customer.F_AreaID = "";
- }
- if (!string.IsNullOrEmpty(input.F_BranchName))
- {
- {
- Model.T_Sys_Department pdModel = new Model.T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(input.F_BranchName));
- }
- catch
- {
- pdModel = departmentBLL.GetModel(input.F_BranchName);
- }
- Customer.F_BranchID = pdModel.F_DeptId.ToString();
- }
- }
- else
- {
- Customer.F_BranchID = "";
- }
- if (!string.IsNullOrEmpty(input.F_CompanyName))
- Customer.F_CompanyName = input.F_CompanyName;
- customerBaseBLL .Update(Customer);
- }
- }
- }
- #region 基本字段
- if (!string.IsNullOrEmpty(input.F_MaterialID))
- {
- model.F_MaterialID = input.F_MaterialID.ToString();//物料编码为11为纯数字
- }
- model.F_Source = input.F_Source.ToString();//工单来源
-
- model.F_Type = input.F_Type.ToString();//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- model.F_CusName = input.F_CusName;//客户姓名
- model.F_CusPhone = input.F_CusPhone;//客户电话
- model.F_CompanyName = input.F_CompanyName;//公司名称
- model.F_IncidentProvince = input.F_IncidentProvince;//事发地-省
- model.F_IncidentCity = input.F_IncidentCity;//事发地-市
- model.F_IncidentCountry = input.F_IncidentCountry;//事发地-县
- model.F_IncidentTownship = input.F_IncidentTownship;//事发地-乡
- model.F_IncidentDetailed = input.F_IncidentDetailed;//事发地-详细
- model.F_SalesBase = input.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- model.F_Description = input.F_Description;//问题描述
- model.F_ZX_Area = input.F_ZX_Area;// 大区
- model.F_ZX_Branch = input.F_ZX_Branch;//分公司
- if (!string.IsNullOrEmpty(input.F_Files))
- model.F_Files = input.F_Files;//附件上传ids
- else
- model.F_Files = model.F_Files;//附件上传ids
- model.F_Brand = input.F_WorkerBrand;//
- model.F_DealType = model.F_DealType;//处理方式:当即办理、电话转接、网络转办(点选)
- model.F_Canal = input.F_Canal;//处理方式:当即办理、电话转接、网络转办(点选)
- #endregion
- model.F_QuestionType = input.F_QuestionType;//问题类别(投诉抽捡和咨询类别不一样)
- model.F_CustomerID = input.F_CustomerID;//客户编号为10为纯数字
- model.F_MaterialID = input.F_MaterialID;//物料编码为11为纯数字
- #region 投诉类
- model.F_BatchNumber = input.F_BatchNumber;//生产批次号
- model.F_TS_Formula = input.F_TS_Formula;// 投诉-配方
- model.F_TS_Category = input.F_TS_Category;//投诉-产品种类:化肥、化工、其他
- model.F_TS_Quantity = input.F_TS_Quantity;//投诉-问题数量(吨)
- model.F_TS_Level = input.F_TS_Level;//投诉-重要级别:轻微、一般、较大、重大
- #endregion
- #region 咨询类
- // model.F_ZX_ProName = input.F_ZX_ProName;//咨询-产品名称:三聚氰胺、甲醇、液氨、二甲醚、糠醇、其他
- model.F_ZX_Quantity = input.F_ZX_Quantity;// 咨询-问题数量(吨)
- #endregion
- #region 抽检类
- model.F_CJ_Time = input.F_CJ_Time;// 抽检-抽检时间
- model.F_CJ_Level = input.F_CJ_Level;// 抽检-抽检级别:乡镇级、县级、市级、省级及以上、个人送检
- model.F_CJ_Unit = input.F_CJ_Unit;// 抽检-抽检单位:市场监督、农业部、土肥站、工商、联合执法、其他
- model.F_CJ_TestUnit = input.F_CJ_TestUnit;//抽检-化验单位
- model.F_CJ_Tonnage = input.F_CJ_Tonnage;//抽检-抽检吨数
- model.F_CJ_BagNo = input.F_CJ_BagNo;//抽检-抽检袋数
- model.F_CJ_Outlay = input.F_CJ_Outlay;//抽检-公关费用金额:单位元】
- model.F_WxOpenId = input.F_WxOpenId;
-
- // model.F_VisitRemarks = input.F_VisitRemarks;//回访备注
- //if (!string.IsNullOrEmpty(input.F_BatchNumber))
- //{
- // if (type == 1)
- // {
- // model.F_SC_QualityMonth = new WorkOrderController().GetProTime(input.F_BatchNumber, DateTime.Parse(model.F_CreateOn.ToString())).ToString();
- // }
- // else
- // {
- // model.F_SC_QualityMonth = new WorkOrderController().GetProTime(input.F_BatchNumber, DateTime.Now).ToString();
- // }
- //}
- if (type == 1)
- {
- model.F_State = model.F_State;//工单状态
- model.F_CreateOn = model.F_CreateOn;//添加时间
- model.F_CreateBy = model.F_CreateBy;//添加人
- model.F_UpdateBy = usercode;//修改人工号
- model.F_UpdateOn = DateTime.Now;//修改人工号
-
- if (input.F_UpdateCount != null)
- {
- model.F_UpdateCount = model.F_UpdateCount + 1;//修改次数
- }
- else
- {
- model.F_UpdateCount = 1;//修改次数
- }
- model.F_limit = model.F_limit;
- }
- else
- {
- model.F_limit = 0;
- model.F_State = (int)EnumWorkOrderState.neworder;
- model.F_CreateBy = usercode;
- model.F_CreateOn = DateTime.Now;
- }
- model.F_IsVisit = 1;
- model.F_IsDelete = 0;
- model.F_IsOver = 0;
- #endregion
- return model;
- }
- /// <summary>
- /// 获取我参与的工单编号
- /// </summary>
- /// <param name="user"></param>
- /// <returns></returns>
- public string GetCYWorkOrderID(string user)
- {
- string str = string.Empty;
- str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") and F_OptType in( 1,3,13 )";
- return str;
- }
- /// <summary>
- /// 获取高层
- /// </summary>
- /// <param name="deptId"></param>
- /// <returns></returns>
- public ActionResult GetHighlevel()
- {
- var user = userAccountBLL.GetModelList(" F_RoleId=61");
- if (user != null)
- return Success("获取高层信息成功", new
- {
- user
- });
- return Error("获取高层信息失败");
- }
- /// <summary>
- /// 验证客户电话是否唯一
- /// </summary>
- private bool getunphone(int id, string phone)
- {
- var sql = " F_IsDelete=0 ";
- sql += "and (F_LegalPhone='" + phone + "')";
- if (id > 0)
- sql += " and F_CustomerId<>" + id;
- var count = customerBaseBLL.GetModelList(sql).Count();
- return count > 0;
- }
-
- /// <summary>
- /// 添加工单
- /// </summary>
- /// <returns></returns>
- public ActionResult CustomAdd(WorkOrderNewInput input, int overtime = 0, int sms = 0)
- {
-
- if (string.IsNullOrEmpty(input.F_CusName))
- return Error("请输入客户姓名!");
- if (string.IsNullOrEmpty(input.F_CusPhone))
- return Error("请输入客户电话!");
-
- if (input.F_Type == 3)
- {
- if (string.IsNullOrEmpty(input.F_Files))
- return Error("请上传抽检单");
- if (string.IsNullOrEmpty(input.F_CJ_Time.ToString()))
- return Error("请选择抽检时间");
- }
- if (!string.IsNullOrEmpty(input.F_SalesPhone))
- {
- if (!IsNumeric(input.F_SalesPhone))
- return Error("请输入正确的业务员电话");
- }
- var model = new Model.T_Wo_WorkOrder();
- #region 保存客户基本信息
- model = inputtoobj(null , model, input, 2);
- model.F_State = (int)EnumWorkOrderState.customers;
- model.F_limit = overtime;
- #endregion
- long n = woBLL.Add(model);
- if (n > 0)
- {
- #region 流转上一级领导审批
- Model.T_Wo_WorkOrder modlelist = new BLL.T_Wo_WorkOrder().GetModel(n);
- if (modlelist != null)
- {
- AddLog(modlelist.F_ID, 0, "客户" + "创建工单", (int)EnumItemType.deal, (int)EnumItemOpt.create, "", 0, null, overtime, sms);
- return Success("添加成功");
- }
- #endregion
- return Success("添加成功!");
- }
- else
- return Error("添加失败!");
- }
- /// <summary>
- /// 添加工单
- /// </summary>
- /// <returns></returns>
- public ActionResult Add(WorkOrderNewInput input, int overtime = 0, int sms = 0)
- {
- if (!string.IsNullOrEmpty(input.F_WxOpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + input.F_WxOpenId + "'").FirstOrDefault();
- // string usercode = CurrentUser.UserData.F_UserCode;
- // Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
- if (ua == null && input.F_Source != 3)
- {
- return Error("无操作权限!");
-
- }
- if (input .F_Source !=3& input.F_Type == 2)
- {
- if (string.IsNullOrEmpty(input.F_SalesBase))
- return Error("请输入基地!");
- if (string.IsNullOrEmpty(input.F_QuestionType))
- return Error("请选择问题类别!");
- }
- //if (!string.IsNullOrEmpty(input.F_BatchNumber) && !vaBatchNumber(input.F_BatchNumber))
- //{
- // return Error("请输入正确的生产批次号!");
- //}
- //else
- //{
- // if (!string.IsNullOrEmpty(input.F_BatchNumber))
- // {
- // var prono = input.F_BatchNumber.Substring(0, 6);
- // try
- // {
- // var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
- // var protime = Convert.ToDateTime(pronos);
- // if (DateTime.Parse(pronos) > DateTime.Now)
- // {
- // return Error("生产批次号错误,生产日期不能大于当前时间!");
- // }
- // }
- // catch
- // {
- // return Error("生产批次号错误,日期格式错误!");
- // }
- // }
- //}
- if (!string.IsNullOrEmpty(input.F_CustomerID) && !valcode(input.F_CustomerID.ToString(), 10))
- return Error("客户编号为10为纯数字!");
- if (!string.IsNullOrEmpty(input.F_MaterialID) && !valcode(input.F_MaterialID.ToString(), 11))
- return Error("物料编码为11为纯数字!");
- if (string.IsNullOrEmpty(input.F_CusName))
- return Error("请输入客户姓名!");
- if (string.IsNullOrEmpty(input.F_CusPhone))
- return Error("请输入客户电话!");
-
- if (!string.IsNullOrEmpty(input.F_CustomerID))
- {
- var Customer = customerBaseBLL.GetModel(input.F_CustomerID.Trim());
- if (Customer == null)
- return Error("无此客户编码!");
- }
- if (!string.IsNullOrWhiteSpace(input.F_MaterialID))
- {
- var Customer = mmBLL.GetModel(input.F_MaterialID.Trim());
- if (Customer == null)
- return Error("无此物料编码!");
- }
- if (input.F_Type == 3)
- {
- if (string.IsNullOrEmpty(input.F_Files))
- return Error("请上传抽检单");
- if (string.IsNullOrEmpty(input.F_CJ_Time.ToString()))
- return Error("请选择抽检时间");
- if (overtime==0)
- {
- overtime = 2160;
- }
- }
- if (!string.IsNullOrEmpty(input.F_SalesPhone))
- {
- if (!IsNumeric(input.F_SalesPhone))
- return Error("请输入正确的业务员电话");
- }
- var model = new Model.T_Wo_WorkOrder();
- #region 保存客户基本信息
- model = inputtoobj(ua, model, input, 2);
- if (model.F_Source == "3")
- {
- model.F_State = (int)EnumWorkOrderState.customers;
- }
- else
- {
- model.F_State = (int)EnumWorkOrderState.audit;
- }
- model.F_limit = overtime;
-
- #endregion
- long n = woBLL.Add(model);
- if (n > 0)
- {
- #region 流转上一级领导审批
- Model.T_Wo_WorkOrder modlelist = new BLL.T_Wo_WorkOrder().GetModel(n);
- if (modlelist != null)
- {
- if (ua != null && model.F_Source != "3")
- {
- if (GetUser(input.F_WxOpenId) != null)
- {
- var user = GetUser(input.F_WxOpenId);
- string deptname = "", deptname1 = "";
- var deptmodel = departmentBLL.GetModel(user.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel1 != null)
- {
- deptname1 = deptmodel1.F_DeptName + "-";
- }
- AddLog(modlelist.F_ID, 0, deptname1 + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "创建工单", (int)EnumWorkOrderState.neworder, (int)EnumItemOpt.create, user.F_UserCode, user.F_DeptId, ua, overtime, sms );
- AddLog(modlelist.F_ID, modlelist.F_State.Value, deptname + user.F_UserName + "(" + user.F_WorkNumber + ")" + "待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, user.F_UserCode, user.F_DeptId, ua, overtime, sms);
- }
- else
- {
- string deptname1 = "";
- int dapt = 0, nextda = 0;
- string deptment = "";
- var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel1 != null)
- {
- deptname1 = deptmodel1.F_DeptName + "-";
- dapt = deptmodel1.F_ParentId;
- deptment = deptmodel1.F_DeptName;
- }
- AddLog(modlelist.F_ID, 0, deptname1 + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "创建工单", (int)EnumWorkOrderState.neworder, (int)EnumItemOpt.create, "", 0, ua, overtime, sms);
- string opt = "";
- if (dapt != 0)
- {
- if (dapt == 11)
- {
- nextda = 37;
- opt = "流转市场管理科";
- }
- else if (dapt == 14)
- {
- nextda = 57;
- opt = "流转营销管理处";
- }
- else if (dapt == 15)
- {
- nextda = 74;
- opt = "流转策划推广";
- }
- else if (dapt == 16)
- {
- nextda = 88;
- opt = "流转销售部";
- }
- else if (dapt == 18)
- {
- nextda = 18;
- opt = "流转车用尿素";
- }
- else if (ua.F_DeptId == 17 || ua.F_DeptId == 19 || ua.F_DeptId == 20 || ua.F_DeptId == 21)
- {
- nextda = ua.F_DeptId;
- opt = "流转" + deptment ;
- }
- }
- if (nextda != 0)
- {
- var res = AssignWO(ua, modlelist, input, opt, "", nextda, 0, overtime, sms,0,0,0,"",1);
- if (res)
- return Success("添加成功");
- else
- return Error("流转失败!");
- }
- else
- {
- return Error("流转失败!");
- }
- }
- }
- else
- {
- AddLog(modlelist.F_ID, 0, "客户" + "创建工单", (int)EnumItemType.deal, (int)EnumItemOpt.create, "", 0, null, overtime, sms);
- return Success("添加成功");
- }
- }
- #endregion
- return Success("添加成功!");
- }
- else
- return Error("添加失败!");
- }
- else
- {
- return Error("OpenId不能为空!");
- }
- }
- /// <summary>
- /// 更新市场管理科,质量管理科
- /// </summary>
- /// <param name="model"></param>
- /// <param name="input"></param>
- /// <returns></returns>
- private Model.T_Wo_WorkOrder InToworkModel(Model.T_Wo_WorkOrder model, WorkOrderNewInput input)
- {
- if (!string.IsNullOrEmpty(input.F_SC_ProductBase))
- model.F_SC_ProductBase = input.F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
- if (!string.IsNullOrEmpty(input.F_SC_PreliminaryOpinion))
- model.F_SC_PreliminaryOpinion = input.F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
- if (!string.IsNullOrEmpty(input.F_SC_QualityMonth))
- model.F_SC_QualityMonth = input.F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
- if (!string.IsNullOrEmpty(input.F_SC_CJ_SpotResult))
- model.F_SC_CJ_SpotResult = input.F_SC_CJ_SpotResult;/// 市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
- if (!string.IsNullOrEmpty(input.F_SC_CJ_SelfResult))
- model.F_SC_CJ_SelfResult = input.F_SC_CJ_SelfResult;//市场管理科-抽检-自检结果
- if (!string.IsNullOrEmpty(input.F_SC_CJ_ApprovalNo))
- model.F_SC_CJ_ApprovalNo = input.F_SC_CJ_ApprovalNo;// 市场管理科-抽检-对应审批工作流单号
- if (!string.IsNullOrEmpty(input.F_SC_CJ_ReturnAccount))
- model.F_SC_CJ_ReturnAccount = input.F_SC_CJ_ReturnAccount;//市场管理科-抽检-确认返账金额(元)
- if (!string.IsNullOrEmpty(input.F_ZL_QualityEventLevel))
- model.F_ZL_QualityEventLevel = input.F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
- if (!string.IsNullOrEmpty(input.F_ZL_ClaimAmount))
- model.F_ZL_ClaimAmount = input.F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
- if (!string.IsNullOrEmpty(input.F_ZL_ResponsibleUnit))
- model.F_ZL_ResponsibleUnit = input.F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
- if (!string.IsNullOrEmpty(input.F_ZL_ApprovalOpinions))
- model.F_ZL_ApprovalOpinions = input.F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
- if (!string.IsNullOrEmpty(input.F_ZL_ApprovalDisagree))
- model.F_ZL_ApprovalDisagree = input.F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
- if (!string.IsNullOrEmpty(input.F_ZL_CompensationMethod))
- model.F_ZL_CompensationMethod = input.F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
- if (!string.IsNullOrEmpty(input.F_ZL_CompensationMoney))
- model.F_ZL_CompensationMoney = input.F_ZL_CompensationMoney;// 质量管理科-补偿钱款
- if (!string.IsNullOrEmpty(input.F_ZL_CResponsibleUnits))
- model.F_ZL_CResponsibleUnits = input.F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
- if (!string.IsNullOrEmpty(input.F_ZL_Fquantity))
- model.F_ZL_Fquantity = input.F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
- if (!string.IsNullOrEmpty(input.F_ZL_ImprovementRequirements))
- model.F_ZL_ImprovementRequirements = input.F_ZL_ImprovementRequirements;//质量管理科-改进要求
- if (!string.IsNullOrEmpty(input.F_ZL_CApprovalNo))
- model.F_ZL_CApprovalNo = input.F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
- if (!string.IsNullOrEmpty(input.F_ZL_CJ_IsRecord))
- model.F_ZL_CJ_IsRecord = input.F_ZL_CJ_IsRecord;//质量管理科-抽检-未备案、已备案
- if (input.F_IsVisit != null)
- {
- try
- {
- model.F_IsVisit = int.Parse(input.F_IsVisit);
- }
- catch
- {
- model.F_IsVisit = 1;
- }
- }
- return model;
- }
- /// <summary>
- /// 指派/转派工单
- /// <param name="orderid">工单id</param>
- /// <param name="cont">指派说明</param>
- /// <param name="clbm">指派部门</param>
- /// <param name="clid">指派人</param>
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult AssignWorkOrder(string OpenId, long orderid, string cont, WorkOrdeDeptment deptment, string F_Files, int isvisit = 1,
- int overtime = 0, int sms = 0, int clbm = 0, int clid = 0, int isApprovalp = 0, int hclbm = 0, int hclid = 0)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model .F_State !=0)
- {
- var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID=" + model.F_ID + "and F_IsUsed=0 order by F_ID desc ").FirstOrDefault();
- if (modellist != null)
- {
- if (modellist.F_NextUser != ua.F_UserCode)
- return Error("非接单人不可操作工单");
- }
- }
-
- WorkOrderNewInput input = new WorkOrderNewInput();
- if (ua != null)
- {
- if (clid != 0)
- {
- Model.T_Sys_UserAccount clus = userAccountBLL .GetModel(clid);
- if (clus != null)
- {
- if (clus.F_WorkNumber == "7000")
- return Error("不能转派到市场管理员");
- }
- }
- if (hclid == 0 && hclbm == 0 && isApprovalp != 0)
- {
- return Error("请选择接收部门");
- }
- if (clbm == 0 && clid == 0)
- {
- return Error("请选择接收部门");
- }
- else
- {
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- if (model != null)
- {
- if (model.F_Type == "2")
- {
- if (deptmodel.F_DeptId == 37)
- {
- // input. F_SC_QualityMonth = QualityMonth;//市场管理科-超出质保期限
- input.F_SC_PreliminaryOpinion = deptment.PreliminaryOpinion;//市场管理科-初审意见:退货、换货、补偿、自行处理
- }
- else if (deptmodel.F_DeptId == 12)
- {
- input.F_IsVisit = isvisit.ToString();
- input.F_ZL_QualityEventLevel = deptment.QualityEventLevel;//质量管理科-质量事件等级(未遂、一般、较大、重大)
- input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
- input.F_ZL_ResponsibleUnit = deptment.ResponsibleUnit;// 质量管理科-责任单位(需列出,可选多个)
- input.F_ZL_ApprovalOpinions = deptment.ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
- input.F_ZL_ApprovalDisagree = deptment.ApprovalDisagree;// 质量管理科-审批不同意意见
- input.F_ZL_CompensationMethod = deptment.CompensationMethod;// 质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
- input.F_ZL_CompensationMoney = deptment.CompensationMoney;// 质量管理科-补偿钱款
- input.F_ZL_CResponsibleUnits = deptment.CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
- input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
- input.F_ZL_ImprovementRequirements = deptment.ImprovementRequirements;// 质量管理科-改进要求
- input.F_ZL_CApprovalNo = deptment.CApprovalNo;// 质量管理科-对应审批工作流单号
- }
- }
- else if (model.F_Type == "3")
- {
- if (deptmodel.F_DeptId == 37)
- {
- input.F_SC_CJ_SpotResult = deptment.SpotResult;//市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
- input.F_SC_CJ_SelfResult = deptment.SelfResult;//市场管理科-抽检-自检结果
- input.F_SC_CJ_ApprovalNo = deptment.ApprovalNo;//市场管理科-抽检-对应审批工作流单号
- input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//市场管理科-抽检-确认返账金额
- }
- else if (deptmodel.F_DeptId == 12)
- {
- input.F_IsVisit = isvisit.ToString();
- input.F_ZL_CJ_IsRecord = deptment.IsRecord;//质量管理科-抽检-未备案、已备案
- input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
- }
- }
- if (deptmodel.F_DeptId == 25)
- {
- input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//销售内勤-确认返账金额
- }
- else if (deptmodel.F_DeptId == 36)
- {
- input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
- }
- }
- else
- return Error("工单不存在!");
- }
- else
- {
- return Error("请选择接收部门");
- }
- }
- if (model != null)
- {
- if (model.F_State == 1)
- {
- return Error("工单已转派请勿重复操作!");
- }
- else
- {
- var res = AssignWO(ua, model, input, cont, F_Files, clbm, clid, overtime, sms, isApprovalp, hclbm, hclid);
- if (res)
- return Success("转派成功");
- else
- return Error("转派失败!");
- }
-
- }
- else
- return Error("工单不存在!");
- }
- }
- return Error("无操作权限!");
- }
- /// <summary>
- /// 转派工单
- /// </summary>
- public bool AssignWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, WorkOrderNewInput input, string cont, string F_Files, int clbm = 0, int clid = 0, int overtime = 0, int sms = 0, int isApprovalp = 0, int hclbm = 0, int hclid = 0, string creat = "",int isbl=0)
- {
- if (model.F_limit > 0)
- overtime = model.F_limit;
- string smscont = "";
- if (model.F_Type == "1")
- {
- smscont = "咨询";
- }
- else if (model.F_Type == "2")
- {
- smscont = "投诉";
- }
- else if (model.F_Type == "3")
- {
- smscont = "抽检";
- }
- else
- {
- smscont = "建议";
- }
- string[] mag = { smscont };
- string smsmsg = "您好,您有一条新的" + smscont + "工单,请及时接单处理!";
- string touser = ""; string tousername = "";
- #region 获取接收人
- int deptid = 0;
- if (clid != 0)
- {
- Model.T_Sys_UserAccount clus = userAccountBLL.GetModel(clid);
- deptid = clus.F_DeptId;
- clbm = clus.F_DeptId;
- if (clus != null)
- {
- touser = clus.F_UserCode;
- tousername = clus.F_UserName + "(" + clus.F_WorkNumber + ")";
- }
- if (sms != 0)
- {
- if (!string.IsNullOrEmpty(clus.F_Mobile))
- {
- SmsSingleSenderResult result = new SMSController().SMSSingleshot(445305, mag, clus.F_Mobile);
- bool n = new SMSController().AddSmS(clus.F_Mobile, smsmsg, nowUser.F_UserId);
- }
- }
- }
- else
- {
- string users = string.Empty;
- deptid = clbm;
- string sql = "";
- if (isbl>0)
- {
- sql = " and F_RoleId=59";
- }
- var list = userAccountBLL.GetModelList(" F_DeptId='" + clbm + "'"+ sql);
- foreach (var l in list)
- {
- if (string.IsNullOrEmpty(users))
- {
- users = l.F_UserCode;
- tousername = l.F_UserName + "(" + l.F_WorkNumber + ")";
- }
- else
- {
- users = users + "," + l.F_UserCode;
- tousername = tousername + "," + l.F_UserName + "(" + l.F_WorkNumber + ")";
- }
- if (sms != 0)
- {
- if (!string.IsNullOrEmpty(l.F_Mobile))
- {
- SmsSingleSenderResult result = new SMSController().SMSSingleshot(445305, mag, l.F_Mobile);
- bool n = new SMSController().AddSmS(l.F_Mobile, smsmsg, nowUser.F_UserId);
- }
- }
- }
- touser = users;
- }
- string htouser = "", htousername = "";
- if (isApprovalp != 0 && nowUser.F_DeptId == 37)
- {
- if (hclid != 0)
- {
- Model.T_Sys_UserAccount clus = userAccountBLL.GetModel(hclid);
- if (clus != null)
- {
- if (string.IsNullOrEmpty(htouser))
- {
- htouser = clus.F_UserCode;
- htousername = clus.F_UserName + "(" + clus.F_WorkNumber + ")";
- }
- }
- }
- else
- {
- var list = userAccountBLL.GetModelList(" F_DeptId='" + hclbm + "'");
- foreach (var l in list)
- {
- if (string.IsNullOrEmpty(htouser))
- {
- htouser = l.F_UserCode;
- htousername = l.F_UserName + "(" + l.F_UserCode + ")";
- }
- else
- {
- htouser = htouser + "," + l.F_UserCode;
- htousername = htousername + "," + l.F_UserName + "(" + l.F_WorkNumber + ")";
- }
- }
- }
- AddLog(model.F_ID, (int)EnumWorkOrderState.assign, htousername + "高层待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, htouser, hclbm, nowUser, overtime, sms, creat, 2);
- }
- #endregion
- #region 工单处理
- var opt = "指派";
- int optbut = (int)EnumItemOpt.assign;
- int wostate = (int)EnumWorkOrderState.assign;//已指派待接单
- #region 读取当前登录人部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- var optcont = "";
- if (!string.IsNullOrEmpty(cont))
- optcont = ",说明:" + cont;
- var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单给 " + tousername + optcont;
- var itemid = AddLog(model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, touser, clbm, nowUser, overtime, sms, creat);
- if (itemid > 0)
- {
- #region 处理工单
- //工单完结要更新工单的状态
- // model.F_DealBy = touser;
- model.F_State = wostate;
- if (model.F_limit == 0)
- model.F_limit = overtime;
- if (!string.IsNullOrEmpty(F_Files))
- {
- if (!string .IsNullOrEmpty(model.F_Files))
- model.F_Files = model.F_Files+ ","+F_Files;
- else
- model.F_Files = F_Files;
- }
- //处理内容
- if (!string.IsNullOrEmpty(cont))
- model.F_DealContent += cont + ";";
- InToworkModel(model, input);
- woBLL.Update(model);
- #endregion
- #region 推送消息
- #region 推送消息给添加的坐席 -转派和处理
- if (nowUser.F_UserCode != model.F_CreateBy)
- {
- sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//推送系统消息
- // var createmodel = userAccountBLL.GetModel(model.F_CreateBy); //被指派人
- // if (createmodel != null)
- // {
- // if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
- // {
- // sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
- // }
- // }
- }
- #endregion
- #region 向下一级操作人员推送消息
- if (!string.IsNullOrWhiteSpace(touser))
- {
- sendsysmsg(model, nowUser, touser, (int)model.F_ID, opt);//推送系统消息
- // var modelUser2 = userAccountBLL.GetModel(touser); //被指派人
- // if (modelUser2 != null)
- // {
- // if (!string.IsNullOrEmpty(modelUser2.F_WxOpenId))
- // {
- // sendwxmsg(model, modelUser2.F_WxOpenId, nowUser, "指派");
- // }
- //}
- }
- #endregion
- #endregion
- return true;
- }
- else
- return false;
- #endregion
- }
- /// <summary>
- /// 查询超时工单列表
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetOvertime(string OpenId, string code, string keywords, string cusname, string cusphone, string companyname, string province, string city,
- string country, string township, string touser, int source = 0, int type = 0, int pageindex = 1, int pagesize = 10)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua == null)
- {
- return Success("你的账号已在别处登录,你确定要再次登录吗?");
- }
- if (!Refresh())
- {
- return Error("查询失败");
- }
- string sql = $" and F_IsDelete=0";
- // sql += "and F_Type !=3";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (source > 0)//工单来源
- {
- if (source == 1)
- sql += $" and F_Source in (1,'')";
- else
- sql += $" and F_Source='" + source + "'";
- }
- if (!string.IsNullOrWhiteSpace(touser))//参与人
- sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(code))//工单编号
- sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
- sql += $" and (F_WorkOrderCode like '%" + keywords.Trim() + "%' or F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%' )";
- if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
- sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
- sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(companyname))//公司名称
- sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//省
- sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//市
- sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//县
- sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(province))//乡
- sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
- sql += $" and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
- (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ")";
- sql += $" and F_IsOver=" + 1;
- Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
- if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY" || ro.F_RoleCode == "BLRY")
- {
- sql += $" and F_DealBy like '%" + ua.F_UserCode.Trim() + "%'";
- }
- else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
- {
- string detpid = "" + ua.F_DeptId;
- var deparmentlist = new List<Model.T_Sys_Department>();
- Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
- if (dModel != null)
- {
- if (dModel.F_Layer == 1)
- {
- deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
- if (deparmentlist.Count > 0)
- {
- foreach (var it in deparmentlist)
- {
- if (detpid != "")
- {
- detpid += "," + it.F_DeptId;
- }
- else
- {
- detpid = "" + it.F_DeptId; ;
- }
- }
- }
- }
- else
- {
- detpid = ua.F_DeptId.ToString();
- }
- if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.dealing + ", " + (int)EnumWorkOrderState.receive + "," +
- (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "") != "")
- {
- sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
- (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "") + ") "; ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- else
- {
- return Error("加载失败");
- }
- }
- else if (ro.F_RoleCode == "JDYBZZX")
- {
- sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
- }
- else if (ro.F_RoleCode == "QTJS")
- {
- return Error("无操作权限!");
- }
- #endregion
- int recordCount = 0;
- if (!string.IsNullOrWhiteSpace(sql))
- {
- dt = BLL.PagerBLL.GetListPager(
- "T_Wo_WorkOrder",
- "F_ID",
- "*",
- sql,
- "ORDER BY T_Wo_WorkOrder.F_ID desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- }
- List<long> woid = new List<long>();
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- List<WorkOrderNewInput> Input = modeltooip(modlelist, ua);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = Input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Error("无操作权限!");
- }
- }
- /// 是否超时
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- private bool TimeforOver(int id)
- {
- var itemlasts = itembll.GetModelList(" F_WoID=" + id );
- string time1 = "", time2 = ""; int x = 0, y = 0;
- float time = 0;
- if (itemlasts.Count > 0)
- {
- for (int z = 0; z < itemlasts.Count; z++)
- {
- if (itemlasts[z].F_WoState >= 1)
- {
- if (itemlasts[z].F_WoState == 1)
- {
- x = z;
- time1 = itemlasts[z].F_CreateTime.ToString();
- time = float.Parse(itemlasts[z].F_LimitTime);
- break; ;
- }
- }
- }
- for (int i = 0; i < itemlasts.Count; i++)
- {
- if (itemlasts[i].F_WoState >= 1)
- {
-
- if (itemlasts[i].F_WoState == 11)
- {
- y = i;
- time2 = itemlasts[i].F_CreateTime.ToString();
- }
- }
- }
- if (time2 != "")
- {
- if (time1 != "")
- {
- if (x > y)
- {
- System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- else
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- }
- else
- {
- return true;
- }
- }
- else if (time1 != "")
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- else
- {
- return true;
- }
- }
- else
- {
- return true;
- }
- return true;
- }
- /// <summary>
- /// 接单 - 确认工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult SureWorkOrder(long orderid, string OpenId)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID=" + model.F_ID + "and F_IsUsed=0 order by F_ID desc ").FirstOrDefault();
- if (modellist != null)
- {
- string[] sprt = modellist.F_NextUser.Split(',');
- if (sprt.Length == 1)
- {
- if (modellist.F_NextUser != ua.F_UserCode)
- return Error("非接单人不可操作工单");
- }
- }
- if (model.F_State == 2)
- {
- return Error("工单已接单无需重新接单");
- }
- else
- {
- var res = SureWO(ua, model);
- if (res)
- return Success("接单成功");
- else
- return Error("接单失败");
- }
- }
- else
- return Error("工单不存在");
- }
- return Error("OpenId不能为空");
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 高层审批
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult HigApprovalOrder(string OpenId, long orderid, string cont)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- //验证信息
- if (model != null)
- {
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.audit + " and F_OptType=" + (int)EnumItemOpt.audit + "and F_NextUser= '" + ua.F_UserCode + "'" + "and F_IsUsed=2 and F_WoID = " + orderid);
- int overtime = 0, sms = 0;
- if (itemlast.Count > 0)
- {
- foreach (var it in itemlast)
- {
- if (!string .IsNullOrEmpty (it.F_LimitTime))
- overtime = int.Parse(it.F_LimitTime);
- sms = int .Parse (it.F_IsSMS.ToString ());
- it.F_IsUsed = 1;
- itembll.Update(it);
- }
- }
- model.F_Highopinions = cont;
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- AddLog(model.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "高层已审批", (int)EnumItemType.audit, (int)EnumItemOpt.reaudit, "", 0, ua, overtime, sms, "", 1);
- bool n = woBLL.Update(model);
- if (n)
- return Success("审批成功");
- else
- return Error("审批失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 接单
- /// </summary>
- public bool SureWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model)
- {
- int overtime = 0, sms = 0;
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
- if (itemlasts.Count > 0)
- {
- foreach (var it in itemlasts)
- {
- if (it.F_WoState == 1)
- {
- overtime = int.Parse(it.F_LimitTime);
- sms = int.Parse(it.F_IsSMS.ToString());
- }
- }
- }
- #region 工单处理
- var opt = "处理接单";
- int optbut = (int)EnumItemOpt.receive;
- int wostate = (int)EnumWorkOrderState.receive;
- #region 读取当前登录人部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt;
- var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, nowUser.F_UserCode, nowUser.F_DeptId, nowUser, overtime, sms);
- if (itemid > 0)
- {
- #region 处理工单
- model.F_State = wostate;//已接单待处理
- model.F_DealBy = nowUser.F_UserCode;//已接单待处理
- woBLL.Update(model);
- #endregion
- #region 推送消息
- //读取上一级指派人员以及添加坐席并推送系统消息和微信消息
- #region 给添加坐席推送系统消息和微信消息
- sendsysmsg(model, nowUser, model.F_CreateBy, (int)itemid, "处理接单");
- // var createUser = userAccountBLL.GetModel(model.F_CreateBy);
- // if (createUser != null && !string.IsNullOrEmpty(createUser.F_WxOpenId))
- // sendwxmsg(model, createUser.F_WxOpenId, nowUser, "接单");
- #endregion
- #region 读取上一级指派人员推送系统消息和微信消息
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- {
- if (itemlast.F_CreateUser != model.F_CreateBy)
- {
- sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, "处理接单");
- // var lastUser = userAccountBLL.GetModel(itemlast.F_CreateUser);
- // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
- // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, "接单");
- }
- }
- #endregion
- #endregion
- return true;
- }
- else
- return false;
- #endregion
- }
- /// <summary>
- /// 工单处理
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult DealWorkOrder(string OpenId, long orderid, string F_Files, string cont, WorkOrdeDeptment deptment,
- string uncont = "",
- int isvisit = 1, int isover = 0)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- if (string.IsNullOrEmpty(cont))
- return Error("请输入处理内容");
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- WorkOrderNewInput input = new WorkOrderNewInput();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- if (model != null)
- {
- var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID=" + model.F_ID + "and F_IsUsed=0 order by F_ID desc ").FirstOrDefault();
- if (modellist != null)
- {
- if (modellist.F_NextUser != ua.F_UserCode)
- return Error("非接单人不可操作工单");
- }
- if (model.F_Type == "2")
- {
- if (deptmodel.F_DeptId == 37)
- {
- input.F_SC_ProductBase = deptment.ProductBase;//
- }
- else if (deptmodel.F_DeptId == 12)
- {
- input.F_IsVisit = isvisit.ToString();
- input.F_ZL_QualityEventLevel = deptment.QualityEventLevel;//质量管理科-质量事件等级(未遂、一般、较大、重大)
- input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
- input.F_ZL_ResponsibleUnit = deptment.ResponsibleUnit;// 质量管理科-责任单位(需列出,可选多个)
- input.F_ZL_ApprovalOpinions = deptment.ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
- input.F_ZL_ApprovalDisagree = deptment.ApprovalDisagree;// 质量管理科-审批不同意意见
- input.F_ZL_CompensationMethod = deptment.CompensationMethod;// 质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
- input.F_ZL_CompensationMoney = deptment.CompensationMoney;// 质量管理科-补偿钱款
- input.F_ZL_CResponsibleUnits = deptment.CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
- input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
- input.F_ZL_ImprovementRequirements = deptment.ImprovementRequirements;// 质量管理科-改进要求
- input.F_ZL_CApprovalNo = deptment.CApprovalNo;// 质量管理科-对应审批工作流单号
- }
- }
- else if (model.F_Type == "3")
- {
- if (deptmodel.F_DeptId == 37)
- {
- input.F_SC_ProductBase = deptment.ProductBase;//
- }
- else if (deptmodel.F_DeptId == 12)
- {
- input.F_IsVisit = isvisit.ToString();
- input.F_ZL_CJ_IsRecord = deptment.IsRecord;//质量管理科-抽检-未备案、已备案
- }
- }
- if (deptmodel.F_DeptId == 25)
- {
- input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//销售内勤-确认返账金额
- }
- else if (deptmodel.F_DeptId == 36)
- {
- input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
- }
- }
- else
- return Error("工单不存在!");
- }
- else
- {
- return Error("请选择接收部门");
- }
- if (model != null)
- {
- if (model.F_State == 10)
- return Error("工单已处理请勿重复操作!");
- else
- {
- var res = DealWO(ua, model, F_Files, input, cont, isover, uncont);
- if (res)
- return Success("处理成功");
- else
- return Error("处理失败!");
- }
-
- }
- else
- return Error("工单不存在!");
- }
- }
- return Error("无操作权限!");
- }
- /// <summary>
- /// 更新工单
- /// </summary>
- private bool Refresh()
- {
- int type = 0;
- var modlelist = woBLL.GetModelList(" F_IsDelete=0" + "and F_IsOver=0" + " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
- (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish + ")");
- if (modlelist.Count > 0)
- {
- foreach (var it in modlelist)
- {
- if (TimeforOver(it.F_ID))
- {
- type = 0;
- }
- else
- {
- type = 1;
- }
- if (type != it.F_IsOver)
- {
- it.F_IsOver = type;
- bool n = woBLL.Update(it);
- if (!n)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- /// <summary>
- /// 退回工单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult BackWorkOrder(string OpenId, long orderid, string cont, int type = 0)
- {//办理人员和监管可以退回工单
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- //河南心连心化学工业集团股份有限公司-系统维护管理员(8000)指派工单给 李波(80324),张绍申(80325),杜爱国(80326),说明:无
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- //验证信息
- if (model != null)
- {
-
- var modellist = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID=" + model.F_ID + "and F_IsUsed=0 order by F_ID desc ").FirstOrDefault();
- if (modellist != null)
- {
- if (modellist != null)
- {
- string[] sprt = modellist.F_NextUser.Split(',');
- if (sprt.Length == 1)
- {
- if (modellist.F_NextUser != ua.F_UserCode)
- return Error("非接单人不可操作工单");
- }
- }
- }
-
- var res = BackWO(ua, model, cont, type);
- if (res)
- return Success("退回成功");
- else
- return Error("退回失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- ///申请延期
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult DelayWorkOrder(string OpenId, long orderid, string cont, float limit = 0)
- {
- if (!string.IsNullOrEmpty(OpenId))
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- //验证信息
- if (model != null)
- {
- var res = DeWO(ua, model, cont, limit);
- if (res)
- return Success("延期成功");
- else
- return Error("延期失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 申请延期
- /// </summary>
- public bool DeWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, float limit)
- {
- #region 工单处理
- int sms = 0; int wostate = 0;
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
- if (itemlasts.Count > 0)
- {
- foreach (var it in itemlasts)
- {
- if (it.F_WoState == 1)
- {
- sms = int.Parse(it.F_IsSMS.ToString());
- }
- itembll.Update(it);
- wostate = int.Parse(it.F_WoState.ToString());
- }
- }
- int optbut = (int)EnumItemOpt.Delay;
- #region 读取当前登录人部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "延期工单,延期说明:" + cont;
- //获取上一级处理人员
- var touser = "";
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- touser = itemlast.F_CreateUser;
- var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.Delay, optbut, touser, 0, nowUser, limit + model.F_limit, sms, "", 1);
- #endregion
- return true;
- }
- /// <summary>
- /// 退回工单
- /// </summary>
- public bool BackWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, int type)
- {
- #region 工单处理
- int sms = 0;
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
- if (itemlasts.Count > 0)
- {
- foreach (var it in itemlasts)
- {
- if (it.F_WoState == 1)
- {
- sms = int.Parse(it.F_IsSMS.ToString());
- }
- }
- }
- var opt = "退回";
- int F_OptType = 1;
- int optbut = (int)EnumItemOpt.reback;
- int wostate = (int)EnumWorkOrderState.reback;
- if (type == 1)
- {
- opt = "异常退回";
- optbut = (int)EnumItemOpt.abreback;
- wostate = (int)EnumWorkOrderState.abreback;
- F_OptType = 2;
- }
- #region 读取当前登录人部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单,退回说明:" + cont;
- //获取上一级处理人员
- var touser = ""; var deptid = 0;
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_NextDept =" + nowUser.F_DeptId + " and F_WoState =" + F_OptType + " and F_WoID='" + model.F_ID + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- {
- touser = itemlast.F_CreateUser;
- if (!string.IsNullOrEmpty(touser))
- {
- var ua = userAccountBLL.GetModel(touser);
- if (ua != null)
- {
- deptid = ua.F_DeptId;
- }
- }
- }
- var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, touser, deptid, nowUser, model.F_limit, sms);
- if (itemid > 0)
- {
- string smscont = "";
- if (model.F_Type == "1")
- {
- smscont = "咨询";
- }
- else if (model.F_Type == "2")
- {
- smscont = "投诉";
- }
- else if (model.F_Type == "3")
- {
- smscont = "抽检";
- }
- else
- {
- smscont = "建议";
- }
- string[] mag = { smscont };
- string smsmsg = "您好,您有一条新的" + smscont + "工单,请及时接单处理!";
- var tousermodel = new BLL.T_Sys_UserAccount().GetModel(touser);
- if (tousermodel != null)
- {
- if (!string.IsNullOrEmpty(tousermodel.F_Mobile))
- {
- SmsSingleSenderResult result = new SMSController().SMSSingleshot(445305, mag, tousermodel.F_Mobile.Trim());
- bool n = new SMSController().AddSmS(tousermodel.F_Mobile.Trim(), smsmsg, nowUser.F_UserId);
- }
- }
- #region 处理工单
- if (deptid == 2)
- {
- model.F_State = (int)EnumWorkOrderState.reassign;
- }
- else
- {
- model.F_State = wostate;
- }
- woBLL.Update(model);
- #endregion
- #region 推送消息
- #region 向上一级操作人员推送消息
- if (!string.IsNullOrWhiteSpace(touser) && touser != nowUser.F_UserCode)
- {//排除上一级指派人是自己
- sendsysmsg(model, nowUser, touser, (int)itemid, opt);
- // var lastUser = userAccountBLL.GetModel(touser);
- // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
- // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
- }
- #endregion
- #endregion
- return true;
- }
- else
- return false;
- #endregion
- }
- /// <summary>
- /// 处理工单
- /// </summary>
- public bool DealWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string F_Files, WorkOrderNewInput input, string cont, int isover = 0, string uncont = "")
- {
- #region 工单处理
- int sms = 0;
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
- if (itemlasts.Count > 0)
- {
- foreach (var it in itemlasts)
- {
- if (it.F_WoState == 1)
- {
- sms = int.Parse(it.F_IsSMS.ToString());
- }
- }
- }
- var opt = "处理";
- int optbut = (int)EnumItemOpt.deal;
- int wostate = (int)EnumWorkOrderState.receive;
- if (isover == 1)
- {
- model.F_DealResult = "已处理";//处理结果
- opt = "处理完结";
- optbut = (int)EnumItemOpt.end;
- wostate = (int)EnumWorkOrderState.finish;
- model.F_DealBy = nowUser.F_UserCode;
- model.F_DealTime = DateTime.Now;
- }
- else
- {
- model.F_DealResult = "未处理";//处理结果
- model.F_DealReasons = uncont;//未处理原因
- }
- #region 读取当前登录人部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- var optcont = "";
- if (!string.IsNullOrEmpty(cont))
- optcont = ",处理内容:" + cont;
- var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单" + optcont;
- var itemid = AddLog(model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, "", 0, nowUser, model.F_limit, sms);
- if (itemid > 0)
- {
- #region 处理工单
- model.F_State = wostate;
- if (!string.IsNullOrEmpty(F_Files))
- {
- if (!string.IsNullOrEmpty(model.F_Files))
- model.F_Files = model.F_Files + "," + F_Files;
- else
- model.F_Files = F_Files;
- }
- //处理内容
- if (!string.IsNullOrEmpty(cont))
- model.F_DealContent += cont + ";";
- model.F_DealTime = DateTime.Now;
- InToworkModel(model, input);
- woBLL.Update(model);
- #endregion
- #region 推送消息
- #region 推送消息给添加的坐席 -处理情况
- if (nowUser.F_UserCode != model.F_CreateBy)
- {
- sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//推送系统消息
- // var createmodel = userAccountBLL.GetModel(model.F_CreateBy); //被指派人
- /// if (createmodel != null)
- // {
- // if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
- // {
- // sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
- // }
- // }
- }
- #endregion
- #region 向上一级操作人员推送消息
- var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_ID desc").FirstOrDefault();
- if (itemlast != null)
- {
- if (itemlast.F_CreateUser != model.F_CreateBy)
- {
- sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, opt);
- // var lastUser = userAccountBLL.GetModel(itemlast.F_CreateUser);
- // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
- // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
- }
- }
- #endregion
- #region 办理完结向客户发送消息
- //if (model.F_State == (int)EnumWorkOrderState.finish)
- //{
- // if (!string.IsNullOrEmpty(model.F_CustomerID))
- // {
- // var cusmodel = customerBaseBLL.GetModel(model.F_CustomerID.Trim());
- // if (cusmodel != null && !string.IsNullOrEmpty(cusmodel.F_WxOpenId))
- // {
- // sendwxmsg(model, cusmodel.F_WxOpenId, nowUser, opt);
- // }
- // }
- //}
- if (isover == 1)
- {
- if (!string.IsNullOrEmpty(model.F_WxOpenId))
- sendwxmsg(model, model.F_WxOpenId, nowUser, model.F_DealContent);
- }
-
- #endregion
- #endregion
- return true;
- }
- else
- return false;
- #endregion
- }
- //推送系统提醒
- public void sendsysmsg(Model.T_Wo_WorkOrder womodel, Model.T_Sys_UserAccount nowUser, string touser, int toid, string opt)
- {
- #region 消息提醒
- string strmsg = string.Empty;
- strmsg = nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + "操作" + opt + "工单";
- Model.T_Msg_List msg = new Model.T_Msg_List();
- msg.Type = (int)Model.MSGType.workorder;//处理
- msg.ToUser = touser;
- msg.ToID = toid;
- msg.Detail = strmsg;
- msg.State = 0;
- msg.IsDel = 0;
- msg.CreateUser = nowUser.F_UserCode;
- msg.CreateDate = DateTime.Now;
- new BLL.T_Msg_List().Add(msg);
- #endregion
- }
- //推送微信消息
- public void sendwxmsg(Model.T_Wo_WorkOrder womodel, string openid, Model.T_Sys_UserAccount nowUser, string opt)
- {
- #region 推送微信
- try
- {
- if (!string.IsNullOrEmpty(openid))
- {
- var dicv = dicvalueBll.GetModel(int.Parse(womodel.F_Type));
- string content = string.Empty;
- var wotype = "";
- if (dicv != null)
- {
- wotype = dicv.F_Name;
- }
- content = opt;
- var msg = WxHelper.SendWechatMsg1(DateTime .Now .ToString ("yyyy-MM-dd HH:mm:ss"), "你的工单已处理", wotype, womodel.F_State.ToString(), content, womodel.F_ID.ToString(), openid, "");
- Error("推送微信::::::" + msg.ToString());
- }
- }
- catch { }
- #endregion
- }
- public static bool IsNumeric(string value)
- {
- return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
- }
- /// <summary>
- /// 修改工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult Update(WorkOrderNewInput input )
- {
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + input.F_WxOpenId + "'").FirstOrDefault();
-
- if (ua != null)
- {
- #region 添加验证判断
- if (input.F_ID <= 0)
- return Error("参数错误!");
- if (!(input.F_Type > 0 && input.F_Type < 5))
- return Error("工单类型错误!");
- if (string.IsNullOrEmpty(input.F_CusName))
- return Error("请输入客户姓名!");
- if (string.IsNullOrEmpty(input.F_CusPhone))
- return Error("请输入客户电话!");
- if(input.F_Type == 2)
- {
- if (string.IsNullOrEmpty(input.F_SalesBase))
- return Error("请输入基地!");
- if (string.IsNullOrEmpty(input.F_QuestionType))
- return Error("请选择问题类别!");
- }
-
- //if (!string.IsNullOrEmpty(input.F_BatchNumber) && !vaBatchNumber(input.F_BatchNumber))
- //{
- // return Error("请输入正确的生产批次号!");
- //}
- if (!string.IsNullOrEmpty(input.F_CustomerID))
- {
- var Customer = customerBaseBLL.GetModel(input.F_CustomerID.Trim());
- if (Customer == null)
- return Error("无此客户编码!");
- }
- if (!string.IsNullOrWhiteSpace(input.F_MaterialID))
- {
- var Customer = mmBLL.GetModel(input.F_MaterialID.Trim());
- if (Customer == null)
- return Error("无此物料编码!");
- }
- //if (!string.IsNullOrEmpty(input.F_BatchNumber))
- //{
- // var prono = input.F_BatchNumber.Substring(0, 6);
- // try
- // {
- // var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
- // var protime = Convert.ToDateTime(pronos);
- // if (DateTime.Parse(pronos) > DateTime.Now)
- // {
- // return Error("生产批次号错误,生产日期不能大于当前时间!");
- // }
- // }
- // catch
- // {
- // return Error("生产批次号错误,日期格式错误!");
- // }
- //}
- if (!string.IsNullOrEmpty(input.F_CustomerID) && !valcode(input.F_CustomerID.ToString(), 10))
- return Error("客户编号为10为纯数字!");
- if (!string.IsNullOrEmpty(input.F_MaterialID) && !valcode(input.F_MaterialID.ToString(), 11))
- return Error("物料编码为11为纯数字!");
- #endregion
- var model = woBLL.GetModel(input.F_ID);
- if (model == null)
- return Error("查询不到此工单!");
- if (model.F_State == 2)
- {
- return Error("此工单已接单不能修改!");
- }
- else if (model.F_State == 11 || model.F_State == 10)
- {
- return Error("此工单已处理不能修改!");
- }
- if (!string.IsNullOrEmpty(input.F_SalesPhone))
- {
- if (!IsNumeric(input.F_SalesPhone))
- return Error("请输入正确的业务员电话");
- }
- var itemlasts = itembll.GetModelList(" F_WoID=" + model.F_ID + "order by F_ID desc ").FirstOrDefault ();
- int overtime = 0, sms = 0;
- if (itemlasts!=null )
- {
- if (itemlasts.F_LimitTime != "")
- overtime = int.Parse(itemlasts.F_LimitTime);
- sms = int.Parse(itemlasts.F_IsSMS.ToString());
- }
- #region 保存客户基本信息
- model = inputtoobj(ua, model, input, 1);
- #endregion
- bool n = woBLL.Update(model);
- if (n)
- {
- WriteWorkOrderLog(model.F_WorkOrderCode, ua.F_UserCode, 0, "", 1, "修改工单");
- #region 读取当前登录人的部门
- string deptname = "";
- var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel != null)
- {
- deptname = deptmodel.F_DeptName + "-";
- }
- #endregion
- AddLog(input.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "修改工单", (int)EnumItemType.update, (int)EnumItemOpt.update, "", 0, ua, overtime, sms, "", 1);
- if (GetUser(input.F_WxOpenId) != null)
- {
- var user = GetUser(input.F_WxOpenId);
- string deptname1 = "";
- var deptmode = departmentBLL.GetModel(user.F_DeptId);
- if (deptmode != null)
- {
- deptname1 = deptmode.F_DeptName + "-";
- }
- var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
- AddLog(input.F_ID, model.F_State.Value, deptname1 + user.F_UserName + "(" + user.F_WorkNumber + ")" + "待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, user.F_UserCode, user.F_DeptId, ua, overtime, sms);
- }
- else
- {
- string deptname1 = "";
- int dapt = 0, nextda = 0; string opt = "";
- var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
- if (deptmodel1 != null)
- {
- deptname1 = deptmodel1.F_DeptName ;
- dapt = deptmodel1.F_ParentId;
- }
- if (dapt != 0)
- {
- if (dapt == 11)
- {
- nextda = 37;
- opt = "流转市场管理科";
- }
- else if (dapt == 14)
- {
- nextda = 57;
- opt = "流转营销管理处";
- }
- else if (dapt == 15)
- {
- nextda = 74;
- opt = "流转策划推广";
- }
- else if (dapt == 16)
- {
- nextda = 88;
- opt = "流转销售部";
- }
- else if (dapt == 18)
- {
- nextda = 18;
- opt = "流转车用尿素" ;
- }
- else if (ua.F_DeptId == 17 || ua.F_DeptId == 19 || ua.F_DeptId == 20 || ua.F_DeptId == 21)
- {
- nextda = ua.F_DeptId;
- opt = "流转" + deptname1 ;
- }
- }
- if (nextda != 0)
- {
- var res = AssignWO(ua, model, input, opt, "", nextda, 0, model.F_limit, sms,0,0,0,"",1 );
- if (res)
- return Success("保存成功");
- else
- return Error("流转失败!");
- }
- else
- {
- return Error("流转失败!");
- }
- }
- return Success("保存成功!");
- }
- else
- return Error("保存失败!");
- }
- else
- {
- return Error("OpenId不能为空!!");
- }
- }
- public void WriteWorkOrderLog(string WorkOrderID, string UserCode, int IsDelete, string DelUserCode, int TypeId, string Remark)
- {
- var model = new Model.T_Wo_WorkOrder_Logs();
- model.WorkOrderID = WorkOrderID; //工单编号
- model.UserCode = UserCode; //修改人code
- model.AddTime = DateTime.Now; //添加时间
- model.IsDelete = IsDelete; //是否删除(0正常1删除)
- model.DelUserCode = DelUserCode; //删除人code
- model.TypeId = TypeId; //类型(0添加,1修改)
- model.Remark = Remark; //备注
- blllogs.Add(model);
- }
- /// <summary>
- /// 添加工单记录
- /// </summary>
- public long AddLog(long woid, int wostate, string content, int itemtype, int opttype, string nextuser, int nextdept, Model.T_Sys_UserAccount nowUser, float overtime, int sms, string create = "", int F_IsUsed = 0)
- {
- Model.T_Wo_WorkOrderItem_New itemModel = new Model.T_Wo_WorkOrderItem_New();
- #region
- //处理当前工单的记录之前的记录过期
- var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_ItemType=" + itemtype + " and F_WoID=" + woid + " ");
- if (F_IsUsed == 0)
- {
- if (itemlast.Count > 0)
- {
- foreach (var it in itemlast)
- {
- it.F_IsUsed = 1;
- it.F_LimitTime = overtime.ToString();
- itembll.Update(it);
- }
- }
- }
- #endregion
- itemModel.F_WoID = woid;
- itemModel.F_IsSMS = sms;
- itemModel.F_WoState = wostate;
- itemModel.F_ItemType = itemtype;
- itemModel.F_OptType = opttype;
- itemModel.F_OptContent = content;
- itemModel.F_NextUser = nextuser;
- itemModel.F_NextDept = nextdept;
- itemModel.F_IsUsed = F_IsUsed;
- itemModel.F_LimitTime = overtime.ToString();
- if (nowUser != null)
- {
- itemModel.F_CreateUser = nowUser.F_UserCode;
- }
- else
- {
- itemModel.F_CreateUser = "";
- }
- if (create != "")
- {
- itemModel.F_CreateTime = DateTime.Parse(create);
- }
- else
- {
- itemModel.F_CreateTime = DateTime.Now;
- }
- var res = itembll.Add(itemModel);
- return res;
- }
- #region
- //workorder.WoBillController blcon = new WoBillController();
- ///// <summary>
- ///// 获取所有业务
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetBusList()
- //{
- // var list = blcon.GetBusAllList();
- // return Success("获取信息列表成功", list);
- //}
- ///// <summary>
- ///// 获取业务内容
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetBusInfo()
- //{
- // string strbusid = HttpUtility.UrlDecode(RequestString.GetQueryString("busid"));
- // if (string.IsNullOrEmpty(strbusid))
- // return Error("参数错误");
- // var model = blcon.GetBusInfo(strbusid);
- // if (model != null)
- // return Success("获取信息成功", model);
- // else
- // return Error("获取信息失败");
- //}
- ///// <summary>
- ///// 获取开票列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetBillList()
- //{
- // DataTable dt = new DataTable();
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // string strbtime = HttpUtility.UrlDecode(RequestString.GetQueryString("btime"));
- // string stretime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));
- // string strpageindex = RequestString.GetQueryString("pageindex");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // var obj=blcon.GetLists(stropenid, strbtime, stretime, pageindex, pagesize);
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 获取开票详情
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetBillInfo()
- //{
- // string strbillid = HttpUtility.UrlDecode(RequestString.GetQueryString("billid"));
- // if (string.IsNullOrEmpty(strbillid))
- // return Error("参数错误");
- // var model = blcon.GetBillInfo(strbillid);
- // if (model != null)
- // return Success("获取信息成功", model);
- // else
- // return Error("获取信息失败");
- //}
- ///// <summary>
- ///// 开票
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult AddBill()
- //{
- // string billtype = RequestString.GetFormString("billtype");//发票类型
- // string cusname = RequestString.GetFormString("cusname");//客户名称
- // string taxidnum = RequestString.GetFormString("taxidnum");//纳税人识别号
- // string address = RequestString.GetFormString("address");//地址
- // string phone = RequestString.GetFormString("phone");//电话
- // string bank = RequestString.GetFormString("bank");//开户行
- // string bankaccount = RequestString.GetFormString("bankaccount");//开户行账号
- // string proname = RequestString.GetFormString("proname");//项目名称
- // string models = RequestString.GetFormString("models");//型号
- // string unit = RequestString.GetFormString("unit");//单位
- // string amount = RequestString.GetFormString("amount");//数量
- // string unitprice = RequestString.GetFormString("unitprice");//单价
- // string sumprice = RequestString.GetFormString("sumprice");//金额
- // string taxrate = RequestString.GetFormString("taxrate");//税率
- // string taxamount = RequestString.GetFormString("taxamount");//税额
- // string billingMethod = RequestString.GetFormString("billingmethod");//开票方式:快递/自取
- // string billingTime = RequestString.GetFormString("billingtime");//开票时间
- // string remark = RequestString.GetFormString("remark");//备注
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // Model.T_Wo_Bill dModel = new Model.T_Wo_Bill();
- // #region 保存基本信息
- // dModel.F_BillType = billtype;
- // dModel.F_CusName = cusname;
- // dModel.F_TaxIDNum = taxidnum;
- // dModel.F_Address = address;
- // dModel.F_Phone = phone;
- // dModel.F_Bank = bank;
- // dModel.F_BankAccount = bankaccount;
- // dModel.F_ProName = proname;
- // dModel.F_Models = models;
- // dModel.F_Unit = unit;
- // dModel.F_Amount = amount;
- // dModel.F_UnitPrice = unitprice;
- // dModel.F_SumPrice = sumprice;
- // dModel.F_TaxRate = taxrate;
- // dModel.F_TaxAmount = taxamount;
- // dModel.F_BillingMethod = billingMethod;
- // dModel.F_BillingTime = billingTime;
- // dModel.F_Remark = remark;
- // dModel.F_Openid = stropenid;
- // dModel.F_CreateOn = DateTime.Now;
- // dModel.F_State = 0;
- // #endregion
- // var res=blcon.addbills(dModel);
- // if (res)
- // return Success("保存成功");
- // else
- // return Error("保存失败");
- //}
- #endregion
- #region 获取公司详情
- ////获取公司信息
- //[WechatActionFilter]
- //public ActionResult GetInfo()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // if (string.IsNullOrEmpty(stropenid))
- // return Error("参数错误!");
- // var model=customerBaseBLL.GetModelByOpenid(stropenid);
- // if (model != null)
- // {
- // var sqlwo = " IsDel=0 and State <>2 "; var sqlno = " F_isDel=0 ";
- // var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
- // var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
- // if (nowUser != null)
- // {
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // sqlwo += " and State =1 and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(nowUser.F_UserCode) + "') ";
- // sqlno += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + nowUser.F_UserId + ",%')";
- // }
- // else if (nowCus != null)
- // {
- // sqlwo += " and ( CustomerID=" + model.F_CustomerId + " or County like '%" + model.F_CompanyName + "%' )";
- // sqlno += " and F_isCus=1 and F_NoticeId not in (select toid from T_Msg_List where Type=6 and ToUser='"+nowCus.F_CustomerCode+ "' and state=1 and IsDel=0)";
- // }
- // var ordercount = woBLL.GetRecordCount(sqlwo);
- // var noticecount = new BLL.T_Msg_NoticeInfo().GetRecordCount(sqlno);
- // var obj = new
- // {
- // model.F_CompanyName,//公司名称
- // model.F_CompanyLogo,//logo
- // model.F_CustomerCode,//编号
- // model.F_CycleStart,//服务周期-开始时间
- // model.F_CycleEnd,//服务周期-结束时间
- // model.F_ChargeType,//收费类型:1月度,2季度,3年度
- // model.F_Charges,//收费
- // model.F_TaxNumber,//公司税号
- // model.F_CompanyAddress,//公司地址
- // ordercount,//待处理工单数量
- // noticecount,//未读公告数量
- // };
- // return Success("获取成功", obj);
- // }
- // return Error("获取失败");
- //}
- ////获取财税信息
- ////[WechatActionFilter]
- //public ActionResult GetFinc()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // var model = customerBaseBLL.GetModelByOpenid(stropenid);
- // if (model != null)
- // {
- // var finmodel = finbll.GetModelList(" F_CustomerId=" + model.F_CustomerId).FirstOrDefault();
- // if (finmodel != null)
- // {
- // var obj = new
- // {
- // model.F_CompanyName,//公司名称
- // model.F_CompanyLogo,//logo
- // model.F_CustomerCode,//编号
- // finmodel.F_CusFinId,
- // finmodel.F_CustomerId,
- // finmodel.F_MonthState,
- // finmodel.F_AnnualIncome,
- // finmodel.F_AnnualProfit,
- // finmodel.F_AnnualCost,
- // finmodel.F_AnnualPersonCount,
- // finmodel.F_AnnualWages,
- // finmodel.F_QuarterlyCost,
- // finmodel.F_QuarterlyPersonCount,
- // finmodel.F_QuarterlyWages,
- // finmodel.F_QuarterlyIncome,
- // finmodel.F_QPVAT,
- // finmodel.F_QPSurtax,
- // finmodel.F_QPTaxes,
- // finmodel.F_QPConTax,
- // finmodel.F_QPPerinTax,
- // finmodel.F_QPStampTax,
- // finmodel.F_QPOtherTax
- // };
- // return Success("获取成功", obj);
- // }
- // }
- // return Error("获取失败");
- //}
- #endregion
- #region 工单
- /// <summary>
- /// 工单列表
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetWoList()
- {
- workorder.WorkOrderController wo = new workorder.WorkOrderController();
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
- int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
- DataTable dt = new DataTable();
- int recordCount = 0;
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- //客户姓名,电话,工单号
- string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- //工单状态
- int states = RequestString.GetInt("states", -1);
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- //#region sql 语句相关处理
- string sql = " ";
- //获取坐席表信息
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- //获取客户档案(业主)表信息
- var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- if (!string.IsNullOrEmpty(sql))
- {
- //sql += " and IsDel=0 ";
- ////客户姓名,电话,房间号,工单号,接待描述
- //if (!string.IsNullOrEmpty(keyword))
- //{
- // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' or County like '%" + keyword + "%' ) ";
- //}
- //if (states >= 0)
- //{
- // #region 权限限制
- // if (ua != null)
- // {
- // string uwhere = " ";
- // switch (states)
- // {
- // case 0://待指派的
- // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
- // //3区域客服可以看到区域待指派工单
- // if (ua.F_RoleId != 17)
- // {
- // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
- // }
- // sql += " and State =0 " + uwhere;
- // break;
- // case 1://待接单的
- // sql += " and State =" + (int)EnumWorkOrderState.assign + " and T_Wo_WorkOrder.ID in ( " + wo.GetDJDWorkOrderID(ua.F_UserCode) + ") ";
- // break;
- // case 2://待完成的(待处理)
- // sql += " and State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ") and T_Wo_WorkOrder.ID in ( " + wo.GetDWCWorkOrderID(ua.F_UserCode) + ") ";
- // break;
- // case 3://已完成的
- // sql += " and State =" + (int)EnumWorkOrderState.finish + " and LastDealUser = '" + ua.F_UserCode + "' ";
- // break;
- // case 4://我参与的
- // sql += " and (CreateUser= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.ID in ( " + wo.GetCYWorkOrderID(ua.F_UserCode) + ")) ";
- // break;
- // case 5://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
- // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < " + (int)EnumWorkOrderState.finish + " ";
- // break;
- // }
- // }
- // else if (modelCustomer != null)
- // {
- // sql += " and ( CustomerID=" + modelCustomer.F_CustomerId + " or County like '%"+modelCustomer.F_CompanyName+"%' )";
- // }
- // else
- // {
- // sql = "";
- // }
- // #endregion
- //}
- //if (strstarttime.Trim() != "" && strstarttime != "undefined")
- //{
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- //}
- //if (strendtime.Trim() != "" && strendtime != "undefined")
- //{
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- //}
- //#endregion
- //if (strpageindex.Trim() != "")
- //{
- // pageindex = Convert.ToInt32(strpageindex);
- //}
- //if (strpagesize.Trim() != "")
- //{
- // pagesize = Convert.ToInt32(strpagesize);
- //}
- //string cols = "*,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetDeptName(ResponDept) as ResponDeptName";
- //dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrder (NOLOCK)",
- // "WorkOrderID",
- // cols,
- // sql,
- // "ORDER BY CreateTime DESC,State asc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 工单详情
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetWoInfo()
- {
- string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- if (string.IsNullOrEmpty(strworkorderid))
- return Error("参数错误");
- if (string.IsNullOrEmpty(stropenid))
- return Error("参数错误!");
- //string sql = "select *,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as YWLXName,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetUserName(CreateUser) as CreateUserName,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetUserName(ResponUser) as ResponUserName,dbo.GetDeptName(ResponDept) AS ComplaintDepartment "
- // + " from T_Wo_WorkOrder where T_Wo_WorkOrder.ID ='" + strworkorderid + "' ";
- //var dt = DbHelperSQL.Query(sql).Tables[0];
- //if (dt.Rows.Count > 0)
- //{
- // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- // if (configfj != null)
- // {
- // dt = BindFileData(dt, configfj.F_ParamValue);
- // }
- // string gcsql = "select *,dbo.GetUserName(F_NextUser) as F_NextUserName, dbo.GetDeptName(F_NextDept) as F_NextDeptName,dbo.GetUserName(F_CreateUser) as F_CreateUserName "
- // + "from T_Wo_WorkOrderItem_New where F_WoID ='" + strworkorderid + "'";
- // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
- // dt.Columns.Add("FilePath", typeof(string));
- // if (configfj != null || config != null)
- // {
- // foreach (DataRow bldr in dt.Rows)
- // {
- // if (bldr["CallID"] != null && config != null)
- // {
- // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
- // }
- // }
- // }
- // var obj = new
- // {
- // data = dt,
- // item = gcdt
- // };
- // return Success("查询成功", obj);
- //}
- return Error("查询失败");
- }
- #region 在用工单操作
- ///// <summary>
- ///// 处理工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult DealWorkOrder(long orderid, string cont, int isover = 0)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // Model.T_Sys_UserAccount ua = userAccountBLL.GetModelByOpenid(stropenid);
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- // if (model != null)
- // {
- // bool res = new workorder.WorkOrderController().DealWO(ua, model, cont, isover);
- // if (res)
- // return Success("处理成功");
- // else
- // return Error("操作失败");
- // }
- // else
- // return Error("工单不存在");
- // }
- // else
- // return Error("无操作权限");
- // }
- // else
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 接单 - 确认工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult SureWorkOrder(long orderid)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = userAccountBLL.GetModelByOpenid(stropenid);
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- // if (model != null)
- // {
- // bool res = new workorder.WorkOrderController().SureWO(ua, model);
- // if (res)
- // return Success("接单成功");
- // else
- // return Error("操作失败");
- // }
- // else
- // return Error("工单不存在");
- // }
- // else
- // return Error("无操作权限");
- // }
- // else
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 指派/转派工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult AssignWorkOrder(long orderid, string cont, int clbm = 0, int clid = 0)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = userAccountBLL.GetModelByOpenid(stropenid);
- // if (ua != null)
- // {
- // if (clbm != 0 && clid == 0)
- // return Error("请选择接收人");
- // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- // if (model != null)
- // {
- // var res = new workorder.WorkOrderController().AssignWO(ua, model, cont, clbm, clid);
- // if (res)
- // return Success("转派成功");
- // else
- // return Error("转派失败!");
- // }
- // else
- // return Error("工单不存在!");
- // }
- // }
- // return Error("无操作权限!");
- //}
- ///// <summary>
- ///// 退回工单
- ///// </summary>
- ///// <param name="input"></param>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult BackWorkOrder(long orderid, string cont,int type=0)
- //{//办理人员和监管可以退回工单
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = userAccountBLL.GetModelByOpenid(stropenid);
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- // //验证信息
- // if (model != null)
- // {
- // var res = new workorder.WorkOrderController().BackWO(ua, model, cont, type);
- // if (res)
- // return Success("处理成功");
- // else
- // return Error("处理失败!");
- // }
- // return Error("工单不存在");
- // }
- // }
- // return Error("无操作权限");
- //}
- ///// <summary>
- ///// 催办工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult AddWorkOrderRemind(long orderid, string cont)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = userAccountBLL.GetModelByOpenid(stropenid);
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- // if (model != null)
- // {
- // var res = new workorder.WorkOrderController().RemindWO(ua, model, cont);
- // if (res)
- // Success("催办成功!");
- // else
- // Success("操作失败!");
- // }
- // return Error("工单不存在!");
- // }
- // }
- // return Error("无操作权限!");
- //}
- #endregion
- #endregion
- #region 公告通知
- /// <summary>
- /// 获取公告列表
- /// </summary>
- /// <returns></returns>
- //[WechatActionFilter]
- public ActionResult GetNoticeList()
- {
- DataTable dt = new DataTable(); int recordCount = 0;
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- #region sql 语句相关处理
- string sql = " and F_isDel=0 ";
- //获取坐席表信息
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- //获取客户档案(业主)表信息
- var modelCustomer = customerBaseBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- sql += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + ua.F_UserId + ",%')";
- }
- else if (modelCustomer != null) {
- sql += " and F_isCus=1";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,F_CreateOn,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,F_CreateOn,'" + strendtime + "')>=0 ";
- }
- #endregion
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- dt = BLL.PagerBLL.GetListPager(
- "T_Msg_NoticeInfo",
- "F_NoticeId",
- "*",
- sql,
- "ORDER BY F_NoticeId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- List<Model.T_Msg_NoticeInfo> msgList = new BLL.T_Msg_NoticeInfo().DataTableToList(dt);
- List<Model.T_Sys_UserAccount> userList = new BLL.T_Sys_UserAccount().GetModelList("");
- var obj = new
- {
- rows = msgList.Select(m =>
- {
- Model.T_Sys_UserAccount usermodel = userList.Where(u => u.F_UserId == m.F_CreateBy.Value).FirstOrDefault();
- var uname = "";
- if (usermodel != null)
- uname = usermodel.F_UserName;
- return new
- {
- F_NoticeId = m.F_NoticeId,
- F_Title = m.F_Title,
- F_Content = m.F_Content,
- F_isCus = m.F_isCus,
- F_CreateOn = m.F_CreateOn,
- F_CreateBy = m.F_CreateBy,
- F_CreateByName = uname
- };
- }),
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取公告详情
- /// </summary>
- /// <returns></returns>
- //[WechatActionFilter]
- public ActionResult GetNoticeInfo()
- {
- string strnoticeid = HttpUtility.UrlDecode(RequestString.GetQueryString("noticeid"));
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- if (string.IsNullOrEmpty(strnoticeid))
- return Error("参数错误");
- if (string.IsNullOrEmpty(stropenid))
- return Error("参数错误!");
- var dModel = new BLL.T_Msg_NoticeInfo().GetModel(int.Parse(strnoticeid.Trim()));
- Model.T_Sys_UserAccount userModel = new Model.T_Sys_UserAccount();
- if (dModel != null)
- {
- if (dModel.F_CreateBy != null)
- userModel = userAccountBLL.GetModel(dModel.F_CreateBy.Value);
- var uname = "";
- if (userModel != null)
- uname = userModel.F_UserName;
- #region 标记为已读
- var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
- var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
- var usercode = "";
- if (nowUser != null)
- {
- usercode = nowUser.F_UserCode;
- var msglist = new BLL.T_Msg_List().GetModelList(" State=0 and ToUser='" + usercode + "' and Type=5 and ToID=" + dModel.F_NoticeId);
- foreach (var item in msglist)
- {
- item.State = 1;
- item.ReadDate = DateTime.Now;
- new BLL.T_Msg_List().Update(item);
- }
- }
- else if (nowCus != null)
- {
- usercode = nowCus.F_CustomerCode;
- Model.T_Msg_List msg = new Model.T_Msg_List();
- msg.Type = (int)Model.MSGType.cusnotice;
- msg.ToUser = usercode;
- msg.ToID = dModel.F_NoticeId;
- msg.Detail = "客户" + usercode + "查看了公告《" + dModel.F_Title + "》";
- msg.State = 1;
- msg.IsDel = 0;
- msg.CreateDate = DateTime.Now;
- msg.ReadDate = DateTime.Now;
- new BLL.T_Msg_List().Add(msg);
- }
- #endregion
- var obj = new
- {
- F_NoticeId = dModel.F_NoticeId,
- F_Title = dModel.F_Title,
- F_Content = dModel.F_Content,
- F_isCus = dModel.F_isCus,
- F_CreateOn = dModel.F_CreateOn,
- F_CreateBy = dModel.F_CreateBy,
- F_CreateByName = uname,
- F_UserId = dModel.F_UserId,
- F_RoleId = dModel.F_RoleId,
- };
- return Success("获取公告详情成功", dModel);
- }
- else
- return Error("获取公告详情失败");
- }
- #endregion
- #region 微信工单
- ///// <summary>
- ///// 获取工单列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetList()
- //{
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
- // int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
- // DataTable dt = new DataTable();
- // int recordCount = 0;
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //客户姓名,电话,房间号,工单号
- // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- // //工单状态(ltype:)
- // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
- // //工单状态
- // int states = RequestString.GetInt("states", -1);
- // //工单来源
- // int strtype = RequestString.GetInt("type", 0);
- // //工单类型
- // int strtypeclass = RequestString.GetInt("typeclass", 0);
- // //工单起止时间
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // //来电单位
- // string lddep = HttpUtility.UrlDecode(RequestString.GetQueryString("lddep"));
- // //20180329 来电弹屏工单记录根据反馈单位获取列表 可以看到同一坐席组的所有人的工单记录
- // string fkdep = HttpUtility.UrlDecode(RequestString.GetQueryString("fkdep"));
- // int isldtp = RequestString.GetQueryInt("isldtp", 0);
- // //微信列表(0未审核微信列表,1已审核微信列表)
- // int isaudit = RequestString.GetInt("isaudit", -1);
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // #region sql 语句相关处理
- // string sql = " ";
- // //获取坐席表信息
- // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // #region 权限限制
- // string mobile = "", roomno = "";
- // int customerid = 0, areaid = 0, proid = 0, buildingid = 0;
- // if (ua != null)
- // {
- // int deptid = ua.F_DeptId; //部门id
- // string deptCode = ua.F_DeptCode; //部门code
- // int userRegionId = ua.RegionId; //项目id
- // //部门信息
- // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
- // int depType = 0, depRegion = 0;
- // if (modelDep != null)
- // {
- // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // }
- // if (ua.F_RoleId != 17)
- // {
- // if (depType == 2)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // else if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 3)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 4)
- // {
- // if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // else if (depRegion == 9)
- // {
- // // 查看该部门工单(包括一级,二级)
- // string deptCodeNew = String.Empty;
- // int deptCodeIndex = 0; //变量声明
- // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // //============== 部门权限条件 - 部门 ================
- // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
- // }
- // }
- // }
- // string uwhere = " ";
- // switch (strltype)
- // {
- // case "0"://待指派的
- // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
- // if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
- // {
- // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
- // }
- // sql += " and State ='0' " + uwhere;
- // break;
- // case "1"://待接单的
- // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDJDWorkOrderID(ua.F_UserCode) + "') ";
- // break;
- // case "2"://待完成的
- // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(ua.F_UserCode) + "') ";
- // break;
- // case "3"://已完成的
- // sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
- // break;
- // case "4"://我参与的
- // sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + wo.GetCYWorkOrderID(ua.F_UserCode) + "')) ";
- // break;
- // case "5"://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
- // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
- // break;
- // }
- // }
- // else if (modelCustomer != null)
- // {
- // #region 根据openid获取所有工单号
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // //if (wxuser != null)
- // //{
- // // sql += " and id in (select distinct F_WorkOrderID from T_WO_UserWorkOrder where F_UserId='" + wxuser.F_Id + "') ";
- // //}
- // #endregion
- // // ============== 项目权限 - 项目 ============== 不通过项目查询,因为客户可能有多个项目的房产
- // // ============== 电话,区域,项目,楼号,房间号权限条件 - 电话 ================
- // //通过相关电话,区域,项目,楼号,房间号(CustomerTel,IsUserSend,IsAdminSend,IsTimeOut,Address)查询该用户查看的工单
- // //mobile = modelCustomer.F_LegalTel;
- // customerid = modelCustomer.F_CustomerId;
- // //int CustomerClassID = modelCustomer.F_CustomerClassID ?? 0;
- // ////F_Layer区域id F_CategoryId所购项目id F_CustomerType楼号 F_BusinessLicenseID房间号
- // //areaid = modelCustomer.F_Layer ?? 0;
- // //proid = modelCustomer.F_CategoryId ?? 0;
- // //buildingid = modelCustomer.F_CustomerType ?? 0;
- // //roomno = modelCustomer.F_BusinessLicenseID;
- // ////查询业主和相关的亲属租户名下工单
- // //sql += $" and CustomerTel IN (SELECT DISTINCT F_Mobile FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
- // //if (CustomerClassID == 0)
- // //{
- // // //业主查看房屋所有工单
- // // sql += $" and CustomerID IN (SELECT DISTINCT F_CustomerId FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
- // //}
- // //else
- // //{
- // // //租户只可查看自己工单
- // // sql += $" and CustomerID = {customerid} ";
- // //}
- // ////查询相关房间号下工单
- // //if (areaid > 0 && proid > 0 && buildingid > 0 && !string.IsNullOrEmpty(roomno))
- // //{
- // // sql += $" and F_Layer = {areaid} and F_CategoryId = {proid} and F_CustomerType = {buildingid} and F_BusinessLicenseID = '{roomno}' ";
- // //}
- // }
- // else
- // {
- // sql = "";
- // }
- // #endregion
- // if (!string.IsNullOrEmpty(sql))
- // {
- // sql += " and IsDel=0 ";
- // //客户姓名,电话,房间号,工单号,接待描述
- // if (!string.IsNullOrEmpty(keyword))
- // {
- // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' ) ";
- // }
- // if (isaudit >= 0)
- // {
- // sql += " and IsAudit = " + isaudit + " "; // ANd Type = (SELECT F_DictionaryValueId FROM dbo.T_Sys_DictionaryValue (NOLOCK) WHERE F_DictionaryFlag = 'GDLY' AND F_Name = '微信')
- // }
- // if (states >= 0)
- // sql += " and State = " + states + " ";
- // if (strtype > 0)
- // {
- // sql += " and Type = " + strtype + " ";
- // }
- // if (strtypeclass > 0)
- // {
- // sql += " and TypeClass = " + strtypeclass + " ";
- // }
- // if (lddep.Trim() != "" && lddep != "undefined")
- // {
- // sql += " and Address = '" + lddep.Trim() + "' ";
- // }
- // if (fkdep.Trim() != "" && fkdep != "undefined")
- // {
- // sql += " and Source = '" + fkdep.Trim() + "' ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // #endregion
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // string cols = "*,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetDeptName(ResponDept) as ResponDeptName";
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrder (NOLOCK)",
- // "WorkOrderID",
- // cols,
- // sql,
- // "ORDER BY CreateTime DESC",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // }
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 获取可催办工单列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetNotDoneWorkList()
- //{
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // DataTable dt = new DataTable();
- // int recordCount = 0;
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //客户姓名,电话,房间号,工单号
- // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- // //工单状态
- // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
- // //工单状态
- // int states = RequestString.GetInt("states", -1);
- // //工单来源
- // int strtype = RequestString.GetInt("type", 0);
- // //工单类型
- // int strtypeclass = RequestString.GetInt("typeclass", 0);
- // //工单起止时间
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // //区域id
- // int areaid = RequestString.GetInt("areaid", 0);
- // //项目id
- // int regionid = RequestString.GetInt("regionid", 0);
- // //期id
- // int buldingid = RequestString.GetInt("buldingid", 0);
- // string uid = HttpUtility.UrlDecode(RequestString.GetQueryString("userid") == "" ? "0" : HttpUtility.UrlDecode(RequestString.GetQueryString("userid")));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // string sql = " and isdel=0 and State != 2 ";
- // //获取坐席表信息
- // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // #region 权限限制
- // int deptid = ua.F_DeptId; //部门id
- // string deptCode = ua.F_DeptCode; //部门code
- // int userRegionId = ua.RegionId; //项目id
- // //部门信息
- // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
- // int depType = 0, depRegion = 0;
- // if (modelDep != null)
- // {
- // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // }
- // if (ua.F_RoleId != 17)
- // {
- // if (depType == 2)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // else if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 3)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 4)
- // {
- // if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // else if (depRegion == 9)
- // {
- // // 查看该部门工单(包括一级,二级)
- // string deptCodeNew = String.Empty;
- // int deptCodeIndex = 0; //变量声明
- // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // //============== 部门权限条件 - 部门 ================
- // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
- // }
- // }
- // }
- // #endregion
- // //客户姓名,电话,房间号,工单号
- // if (!string.IsNullOrEmpty(keyword))
- // {
- // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' ) ";
- // }
- // if (states >= 0)
- // sql += " and State = " + states + " ";
- // if (areaid > 0)
- // sql += " and IsUserSend = " + areaid + " ";
- // if (regionid > 0)
- // sql += " and IsAdminSend = " + regionid + " ";
- // if (buldingid > 0)
- // sql += " and IsTimeOut = " + buldingid + " ";
- // //坐席工号
- // if (uid.Trim() != "" && uid != "0")
- // {
- // sql += " and CreateUser = '" + uid + "' ";
- // }
- // if (strtype > 0)
- // {
- // sql += " and Type = " + strtype + " ";
- // }
- // if (strtypeclass > 0)
- // {
- // sql += " and TypeClass = " + strtype + " ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrder",
- // "T_Wo_WorkOrder.ID",
- // "*,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsUserSend) AS areaname,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsAdminSend) AS proname,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsTimeOut) AS buildingname,dbo.GetDictionaryName(Type) as GDLYName,dbo.GetDictionaryName(Ownerrelationsid) as OwnerrelationsName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,(SELECT TOP 1 F_DeptName FROM dbo.T_Sys_Department WHERE F_DeptId = Source) AS complaintTypeName",
- // sql,
- // "ORDER BY T_Wo_WorkOrder.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // dt.Columns.Add("CBCount", typeof(int));
- // foreach (DataRow dr in dt.Rows)
- // {
- // var list = new BLL.T_Wo_WorkOrderItem().GetList(" WorkOrderID='" + dr["WorkOrderID"].ToString() + "' and IsDel=0 and Type=2 and ','+ToUser+',' like ',%" + ua.F_UserCode + "%,' ").Tables[0];
- // dr["CBCount"] = list.Rows.Count;
- // }
- // }
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 新增工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult AddWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // //工单来源
- // int gdly = RequestString.GetFormInt("gdly", 0);
- // //工单类型
- // int gdlx = RequestString.GetFormInt("gdlx", 0);
- // //客户id
- // int customerid = RequestString.GetFormInt("customerid", 0);
- // //客户姓名
- // string callCustomer = RequestString.GetFormString("callCustomer");
- // //联系电话
- // string tel = RequestString.GetFormString("tel");
- // //处理部门
- // string fkdep = RequestString.GetFormString("fkdep");
- // //客服类类型
- // string kfdepid = RequestString.GetFormString("kfdepid");
- // //受理人 - 审核人工号
- // string auditusercode = RequestString.GetFormString("auditusercode");
- // //工单状态
- // int gdzt = RequestString.GetFormInt("gdzt", 0);
- // //接待描述 - 反馈内容
- // string fkcont = RequestString.GetFormString("fkcont");
- // string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
- // string files = RequestString.GetFormString("files");
- // //咨询类工单指派部门
- // int clbm = RequestString.GetFormInt("clbm", 0);
- // //备注
- // string note = RequestString.GetFormString("note");
- // #region 添加验证判断
- // if (string.IsNullOrEmpty(callCustomer))
- // return Error("姓名不能为空!");
- // if (string.IsNullOrEmpty(tel))
- // return Error("电话不能为空!");
- // #endregion
- // string workOrder = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // var model = userAccountBLL.GetModelByOpenid(stropenid);
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(stropenid);
- // string usercode = "";
- // if (model != null)
- // {
- // usercode = model.F_UserCode;
- // }
- // else if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // customerid = modelCustomer.F_CustomerId;
- // }
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // string workorderid = wo.AddWXWorkOrder(workOrder, gdly, gdlx, customerid, callCustomer, tel, fkdep, kfdepid, auditusercode, fkcont, files, gdzt, note, usercode,-1);
- // if (string.IsNullOrEmpty(workorderid))
- // {
- // return Error("新增失败");
- // }
- // else
- // {
- // #region 咨询类工单指派至部门
- // //工单类型(107咨询,108投诉)
- // if (gdlx == 107)
- // {
- // //需要审核后,再处理
- // //bool b = wo.DealWXWorkOrder(workOrder, 0, 0, clbm, 0, "", fkcont, stropenid);
- // }
- // #endregion
- // //暂时排除客户档案用户(F_UserId无法区分是住户添加 还是管理员添加) - 后期完善
- // if (wxuser != null)
- // {
- // Model.T_WO_UserWorkOrder tbu = new Model.T_WO_UserWorkOrder();
- // tbu.F_UserId = wxuser.F_Id;
- // tbu.F_WorkOrderId = workorderid;
- // new BLL.T_WO_UserWorkOrder().Add(tbu);
- // }
- // return Success("新增成功", workorderid);
- // }
- //}
- ///// <summary>
- ///// 修改工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult UpdateWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // //工单id
- // string workorderid = RequestString.GetFormString("orderid");
- // //工单来源
- // int gdly = RequestString.GetFormInt("gdly", 0);
- // //工单类型
- // int gdlx = RequestString.GetFormInt("gdlx", 0);
- // //客户id
- // int customerid = RequestString.GetFormInt("customerid", 0);
- // //客户姓名
- // string callCustomer = RequestString.GetFormString("callCustomer");
- // //联系电话
- // string tel = RequestString.GetFormString("tel");
- // //处理部门
- // string fkdep = RequestString.GetFormString("fkdep");
- // //客服类类型
- // string kfdepid = RequestString.GetFormString("kfdepid");
- // //受理人 - 审核人工号
- // string auditusercode = RequestString.GetFormString("auditusercode");
- // //接待描述 - 反馈内容
- // string fkcont = RequestString.GetFormString("fkcont");
- // string files = RequestString.GetFormString("files");
- // //备注
- // string note = RequestString.GetFormString("note");
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // WorkOrderController wo = new WorkOrderController();
- // if (!string.IsNullOrEmpty(workorderid))
- // {
- // var models = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + workorderid + "'");
- // if (models.Count > 0)
- // {
- // var model = models.FirstOrDefault();
- // string detail = model.Detail;
- // model.Type = gdly; //工单来源
- // model.TypeClass = gdlx; //投诉类型 -工单类型
- // model.Customer = callCustomer; //客户姓名
- // model.CustomerTel = tel; //联系电话
- // //model.CustomerID = customerid; //用户档案Id
- // model.Source = fkdep; //处理部门 反馈单位
- // model.CreateUserID = kfdepid; //客服类类型
- // model.AuditUser = auditusercode; //受理人 - 审核人工号
- // //model.CreateUser = ua.F_UserCode; //接待人(工号)
- // //model.State = 0; //工单状态
- // //反馈内容
- // var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
- // model.Detail = detailutf8;
- // if (new BLL.T_Wo_WorkOrder().Update(model))
- // {
- // //添加工单修改操作日志
- // wo.WriteWorkOrderLog(workorderid, detail, detailutf8, ua.F_UserCode, 0, "", 1, "修改工单(微信端)");
- // return Success("修改成功!");
- // }
- // }
- // }
- // }
- // }
- // return Error("修改失败!");
- //}
- ///// <summary>
- ///// 处理工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult DealWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // string orderid = RequestString.GetFormString("orderid");
- // int isend = RequestString.GetInt("isend", 0); //0转派
- // int ltype = RequestString.GetInt("ltype", 0); //处理方式 1结束 0转派
- // int clbm = RequestString.GetInt("clbm", 0); //部门id
- // int clid = RequestString.GetInt("clid", 0); //用户接收人id
- // string cont = RequestString.GetFormString("cont"); //处理内容
- // string detail = RequestString.GetFormString("detail");
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // bool res = wo.DealWXWorkOrder(orderid, isend, ltype, clbm, clid, cont, detail, stropenid);
- // if (res)
- // {
- // return Success("操作成功");
- // }
- // else
- // {
- // return Error("操作失败");
- // }
- //}
- ///// <summary>
- ///// 接单 - 确认工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult SureWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // string orderid = RequestString.GetFormString("orderid");
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem item = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and isdel=0 and Type=1 ").OrderByDescending(p => p.CreateTime).FirstOrDefault();
- // if (item != null && item.State == 0 && ("," + item.ToUser + ",").Contains("," + ua.F_UserCode + ","))
- // {
- // item.SureUser = ua.F_UserCode;
- // item.State = 1;
- // item.SureTime = DateTime.Now;
- // if (new BLL.T_Wo_WorkOrderItem().Update(item))
- // {
- // return Success("接单成功!");
- // }
- // }
- // return Error("操作失败,工单还没有派单!");
- // }
- // }
- // return Error("操作失败");
- // }
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 催办工单(管理员,业主)
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult RemindWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string usercode = string.Empty;
- // string username = string.Empty;
- // if (ua != null)
- // {
- // usercode = ua.F_UserCode;
- // username = ua.F_UserName;
- // }
- // else
- // {
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // username = modelCustomer.F_CompanyName;
- // }
- // }
- // if (string.IsNullOrEmpty(usercode))
- // return Error("参数错误!");
- // string orderid = RequestString.GetFormString("orderid");
- // string cont = RequestString.GetFormString("cont");
- // string callid = RequestString.GetFormString("callid");
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem itemlast = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and IsDel=0 and Type=1 and (State=0 or State=1) ").FirstOrDefault();
- // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
- // if (itemlast != null)
- // {
- // item.ToDept = itemlast.ToDept;
- // item.ToUser = itemlast.ToUser;
- // }
- // else
- // {
- // var cu = new BLL.T_Sys_UserAccount().GetModel(model.CreateUser);
- // if (cu != null)
- // {
- // item.ToDept = cu.F_DeptId;
- // item.ToUser = cu.F_UserCode;
- // }
- // else {
- // var modelCus = customerBaseBLL.GetModelList(" F_CustomerCode='" + model.CreateUser + "'").FirstOrDefault(); //customerBaseBLL.GetModel(model.CreateUser);
- // if (modelCus != null)
- // {
- // item.ToDept = 0;
- // item.ToUser = modelCus.F_LegalTel;
- // }
- // }
- // }
- // item.WorkOrderID = orderid;
- // item.Type = 2;
- // item.Detail = cont;
- // item.CallID = callid;
- // item.State = 0;
- // item.IsDel = 0;
- // item.IsLast = 0;
- // item.IsStart = 0;
- // item.IsTimeOut = 0;
- // item.CreateUser = usercode; // ua.F_UserCode;
- // item.CreateTime = DateTime.Now;
- // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
- // if (itemid > 0 && !string.IsNullOrEmpty(item.ToUser))
- // {
- // foreach (string ur in item.ToUser.Split(','))
- // {
- // Model.T_Msg_List msg = new Model.T_Msg_List();
- // msg.Type = 1;
- // msg.ToUser = ur;
- // msg.ToID = Int32.Parse(itemid.ToString());
- // msg.Detail = username + "向你催办了工单,单号:" + model.WorkOrderID;
- // msg.State = 0;
- // msg.IsDel = 0;
- // msg.CreateUser = usercode;
- // msg.CreateDate = DateTime.Now;
- // new BLL.T_Msg_List().Add(msg);
- // }
- // return Success("催办成功!");
- // }
- // }
- // }
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 退回工单
- ///// </summary>
- ///// <param name="input"></param>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult BackWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // string orderid = RequestString.GetFormString("orderid");
- // var model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // //验证信息
- // if (model == null)
- // {
- // return Error("工单不存在");
- // }
- // model.State = 0;
- // if (new BLL.T_Wo_WorkOrder().Update(model))
- // {
- // var modelItem = new BLL.T_Wo_WorkOrderItem().GetModelList(" IsDel=0 and Type=1 and (state='0' and ','+ToUser+',' like '%," + ua.F_UserCode + ",%') and WorkOrderID = '" + orderid + "' ").FirstOrDefault();
- // if (modelItem != null)
- // {
- // modelItem.State = 6;
- // new BLL.T_Wo_WorkOrderItem().Update(modelItem);
- // }
- // return Success("操作成功");
- // }
- // return Error("操作失败");
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 评论工单(管理人员,业主)
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult CommentWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string usercode = string.Empty;
- // string username = string.Empty;
- // if (ua != null)
- // {
- // usercode = ua.F_UserCode;
- // username = ua.F_UserName;
- // }
- // else
- // {
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // username = modelCustomer.F_CompanyName;
- // }
- // }
- // if (string.IsNullOrEmpty(usercode))
- // return Error("参数错误!");
- // string orderid = RequestString.GetFormString("orderid");
- // string cont = RequestString.GetFormString("cont");
- // string file = RequestString.GetFormString("file");
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
- // item.WorkOrderID = orderid;
- // item.Type = 3; //评论
- // item.Detail = cont;
- // item.Files = file;
- // item.State = 0;
- // item.IsDel = 0;
- // item.IsStart = 0;
- // item.IsTimeOut = 0;
- // item.IsLast = 0;
- // item.CreateUser = usercode;
- // item.CreateTime = DateTime.Now;
- // if (new BLL.T_Wo_WorkOrderItem().Add(item) > 0)
- // {
- // return Success("评论成功!");
- // }
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 刪除工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult DelWorkOrder(string[] ids)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // if (ids != null && ids.Length > 0)
- // {
- // string idd = " ";
- // foreach (string str in ids)
- // {
- // idd += str + ",";
- // }
- // string sql = "update T_Wo_WorkOrder set IsDel=1,DelUser='" + ua.F_UserCode + "',DelTime=getdate() where ID in (" + idd.TrimEnd(',') + ")";
- // if (!string.IsNullOrEmpty(idd.Trim()))
- // {
- // if (DbHelperSQL.ExecuteSql(sql) > 0)
- // {
- // return Success("删除成功");
- // }
- // }
- // else
- // {
- // return Error("请选择记录");
- // }
- // }
- // else
- // {
- // return Error("获取参数失败");
- // }
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 获取工单详情
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetWorkOrder()
- //{
- // string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // if (string.IsNullOrEmpty(strworkorderid))
- // return Error("参数错误");
- // if (string.IsNullOrEmpty(stropenid))
- // return Error("参数错误!");
- // #region pc端工单也可以查看,所以注释(注释功能只能查看自己创建的工单)
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // //if (wxuser != null)
- // //{
- // // var tbu = new BLL.T_WO_UserWorkOrder().GetList(" F_UserId='" + wxuser.F_Id + "' and F_WorkOrderId=" + strworkorderid + " ").Tables[0];
- // // if (tbu.Rows.Count > 0)
- // // {
- // // }
- // //}
- // #endregion
- // string sql = "select *,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as YWLXName,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetUserName(CreateUser) as CreateUserName,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetUserName(ResponUser) as ResponUserName,dbo.GetDeptName(ResponDept) AS ComplaintDepartment "
- // + " from T_Wo_WorkOrder where WorkOrderID ='" + strworkorderid + "' ";
- // var dt = DbHelperSQL.Query(sql).Tables[0];
- // if (dt.Rows.Count > 0)
- // {
- // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- // if (configfj != null)
- // {
- // dt = BindFileData(dt, configfj.F_ParamValue);
- // }
- // string gcsql = "select *,dbo.GetUserName(CreateUser) as UserName "
- // + "from T_Wo_WorkOrderItem where IsDel=0 and WorkOrderID ='" + dt.Rows[0]["WorkOrderId"] + "'";
- // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
- // dt.Columns.Add("FilePath", typeof(string));
- // if (configfj != null || config != null)
- // {
- // foreach (DataRow bldr in dt.Rows)
- // {
- // if (bldr["CallID"] != null && config != null)
- // {
- // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
- // }
- // }
- // }
- // var obj = new
- // {
- // data = dt,
- // item = gcdt
- // };
- // return Success("查询成功", obj);
- // }
- // return Error("查询失败");
- //}
- ///// <summary>
- ///// 获取工单明细列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetItemList()
- //{
- // string sql = " and IsDel=0 ";
- // DataTable dt = new DataTable();
- // string strid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- // string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // if (strid.Trim() != "" && strid != "undefined")
- // {
- // sql += " and WorkOrderID = '" + strid.Trim() + "' ";
- // }
- // if (strtype.Trim() != "" && strtype != "undefined")
- // {
- // sql += " and Type = '" + strtype.Trim() + "' ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // int recordCount = 0;
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrderItem",
- // "T_Wo_WorkOrderItem.ID",
- // "*,dbo.GetUserName(ToUser) as ToUserName, dbo.GetDeptName(ToDept) as ToDeptName,dbo.GetUserName(SureUser) as SureUserName,dbo.GetUserName(DealUser) as DealUserName,dbo.GetUserName(CreateUser) as CreateUserName,case Type when 1 then convert(decimal(18,2),DATEDIFF(minute, CreateTime, ISNULL(DealTime, GETDATE()))/60.00) else 0 end as totalhour",
- // sql,
- // "ORDER BY T_Wo_WorkOrderItem.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 获取工作动态列表 - 工单明细动态列表 - 管理员功能
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetWorkOrderItemList()
- //{
- // DataTable dt = new DataTable();
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //string stropenid = "oXF5e1mWpX5DajW5_yjNLPKb8ThE";
- // //获取客户档案(业主)表信息
- // var model = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string sql = " and IsDel=0 ";
- // string daytype = HttpUtility.UrlDecode(RequestString.GetQueryString("daytype"));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // #region 权限限制
- // //if (model != null) {
- // // var sqlUser = "";
- // // //部门信息
- // // var modelDep = new BLL.T_Sys_Department().GetModel(model.F_DeptId);
- // // int depType = 0, depRegion = 0;
- // // if (modelDep != null)
- // // {
- // // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // // }
- // // //根据部门查询工单(可查看当前部门工单)
- // // string deptCode = model.F_DeptCode; //部门code
- // // int userRegionId = model.RegionId; //项目id
- // // ////接待部(坐席)可以看到所有的工单
- // // //if (model.F_RoleId != 17 && depType != 1)
- // // //{
- // // // //if (depType == 2 || depType == 3)
- // // // //{
- // // // // // ============== 项目权限 - 项目 ==============
- // // // // sqlUser += $" and IsAdminSend = {userRegionId} ";
- // // // //}
- // // // //else if (depType == 4)
- // // // //{
- // // // // // 查看该部门工单(包括一级,二级)
- // // // // string deptCodeNew = String.Empty;
- // // // // int deptCodeIndex = 0; //变量声明
- // // // // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // // // // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // // // // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // // // // // ============== 部门权限条件 - 部门 ================
- // // // // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // // // // sql += $" and ToUser IN ({arrUser}) and WorkOrderID IN (SELECT WorkOrderID FROM dbo.T_Wo_WorkOrder WHERE 1=1 {sqlUser} ) ";
- // // // //}
- // // //}
- // //}
- // #endregion
- // switch (daytype)
- // {
- // case "today":
- // sql += " and DateDiff(dd,CreateTime,getdate())=0 ";
- // break;
- // case "yesterday":
- // sql += " and DateDiff(dd,CreateTime,getdate())=1 ";
- // break;
- // case "month":
- // sql += " and DateDiff(mm,CreateTime,getdate())=0 ";
- // break;
- // default:
- // break;
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // int recordCount = 0;
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrderItem",
- // "T_Wo_WorkOrderItem.ID",
- // "*,dbo.GetUserName(ToUser) as ToUserName, dbo.GetDeptName(ToDept) as ToDeptName,dbo.GetUserName(SureUser) as SureUserName,dbo.GetUserName(DealUser) as DealUserName,dbo.GetUserName(CreateUser) as CreateUserName,case Type when 1 then convert(decimal(18,2),DATEDIFF(minute, CreateTime, ISNULL(DealTime, GETDATE()))/60.00) else 0 end as totalhour",
- // sql,
- // "ORDER BY T_Wo_WorkOrderItem.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- #endregion
- #region 附件和语音文件
- /// <summary>
- /// 获取留言路径
- /// </summary>
- /// <param name="lid">留言id</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public string GetLeavePath(string lid, string prefix)
- {
- string path = string.Empty;
- var liuyan = new BLL.T_Call_LeaveRecord().GetModelList(" F_Id='" + lid + "' ").FirstOrDefault();
- if (liuyan != null)
- {
- if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
- {
- path = prefix + liuyan.F_RecFileUrl;
- }
- }
- return path;
- }
- /// <summary>
- /// 获取通话录音路径
- /// </summary>
- /// <param name="cid">通话id</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public string GetCallPath(string cid, string prefix)
- {
- string path = string.Empty;
- var luyin = new BLL.T_Call_CallRecords().GetModelList(" callid='" + cid + "' ").FirstOrDefault();
- if (luyin != null)
- {
- if (!string.IsNullOrEmpty(luyin.FilePath))
- {
- var ym = prefix;
- ym = ym.Substring(0, ym.Length - 1);
- path = ym + luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
- }
- }
- return path;
- }
- /// <summary>
- /// 获取附件数据
- /// </summary>
- /// <param name="ids">附件id,多个用英文逗号,隔开</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public DataTable GetFileData(string ids, string prefix)
- {
- DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
- }
- return dt;
- }
- /// <summary>
- /// 绑定附件信息
- /// </summary>
- /// <param name="dt"></param>
- /// <param name="prefix"></param>
- /// <returns></returns>
- public DataTable BindFileData(DataTable dt, string prefix)
- {
- dt.Columns.Add("File", typeof(object));
- foreach (DataRow dr in dt.Rows)
- {
- if (dr["Files"] != null && dr["Files"].ToString() != "")
- {
- dr["File"] = GetFileData(dr["Files"].ToString(), prefix);
- }
- }
- return dt;
- }
- #endregion
- #region 上传附件
- /// <summary>
- /// 上传附件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
- {
- try
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- string filePathName = string.Empty;
- string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy/MM/dd") + "/";
- string localPath = Server.MapPath(Path.Combine(HttpRuntime.AppDomainAppPath, path));
- if (Request.Files.Count == 0)
- {
- return Error("保存失败");
- }
- string ex = Path.GetExtension(file.FileName);
- filePathName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + ex;
- if (!System.IO.Directory.Exists(localPath))
- {
- System.IO.Directory.CreateDirectory(localPath);
- }
- file.SaveAs(Path.Combine(localPath, filePathName));
- #region 添加日志
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_FileName = filePathName;//附件名称
- model_T_Sys_Accessories.F_FileType = type;//附件类型
- model_T_Sys_Accessories.F_FileUrl = path + filePathName;//附件地址
- model_T_Sys_Accessories.F_Size = size;
- model_T_Sys_Accessories.F_UserCode = stropenid;//上传人
- int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- #endregion
- if (fid > 0)
- {//返回附件的ID
- model_T_Sys_Accessories.F_FileId = fid;//修改为返回对象以便查看图片
- return Success("文件日志都成功", model_T_Sys_Accessories);
- }
- else
- return Success("文件成功");
- }
- catch (Exception ex)
- {
- return Error(ex.Message);
- }
- }
- }
- #endregion
- }
|