商丘12345 后端

WorkOrderController.cs 645KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Models.Common;
  6. using CallCenterApi.Model;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Text.RegularExpressions;
  14. using System.Transactions;
  15. using System.Web;
  16. using System.Web.Mvc;
  17. namespace CallCenterApi.Interface.Controllers.workorder
  18. {
  19. public class WorkOrderController : BaseController
  20. {
  21. // GET: WorkOrder
  22. //工单状态:0新工单 1待交办 2待查收 3退回审核中 4办理中 5延时审核中 6已办理 7已回访 8重办中 9已结案
  23. //操作按钮:1查询 2编辑 3删除 4提交 5交办 6领导批示 7市长指示 8督办 9监察 10收回 11查收 12退回申请
  24. // 13办理 14延时申请 15退回审核 16回访 17延时审核 18重办 19结案 20导出 21回退 22强制结案
  25. private information.InternalMessagesController msg = new information.InternalMessagesController();
  26. private BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  27. private BLL.T_Bus_WorkOrder workorderBLL = new BLL.T_Bus_WorkOrder();
  28. private BLL.T_Bus_AssignedInfo assignBLL = new BLL.T_Bus_AssignedInfo();
  29. private BLL.T_Bus_AssignedItemInfo assignItemBLL = new BLL.T_Bus_AssignedItemInfo();
  30. private BLL.T_Bus_Operation operBLL = new BLL.T_Bus_Operation();
  31. private BLL.T_Sys_SystemConfig configBll = new BLL.T_Sys_SystemConfig();
  32. private BLL.T_Bus_RemindRecord remindBLL = new BLL.T_Bus_RemindRecord();
  33. private BLL.T_Bus_Feedback feedbackBLL = new BLL.T_Bus_Feedback();
  34. #region 获取工单
  35. /// <summary>
  36. /// 获取工单列表
  37. /// </summary>
  38. /// <returns></returns>
  39. //[Authority]
  40. public ActionResult GetList(int isdc = 0)
  41. {
  42. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  43. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  44. DataTable dt = new DataTable();
  45. string sql = " and F_IsDelete=0 ";
  46. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  47. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  48. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  49. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  50. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  51. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  52. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  53. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  54. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  55. int source = RequestString.GetInt("source", 0);
  56. int keyid = RequestString.GetInt("keyid", 0);
  57. int type = RequestString.GetInt("type", 0);
  58. int bigtype = RequestString.GetInt("bigtype", 0);
  59. int smalltype = RequestString.GetInt("smalltype", 0);
  60. int sourcearea = RequestString.GetInt("sourcearea", 0);
  61. int deptid = RequestString.GetInt("deptid", 0);
  62. int dealtype = RequestString.GetInt("dealtype", -1);
  63. int issend = RequestString.GetInt("issend", -1);
  64. int deptlevel = RequestString.GetInt("deptlevel", 0);
  65. string strpageindex = RequestString.GetQueryString("page");
  66. int pageindex = 1;
  67. string strpagesize = RequestString.GetQueryString("pagesize");
  68. int pagesize = 10;
  69. #region sql 语句相关处理
  70. if (strstate.Trim() != "" && strstate != "undefined")
  71. {
  72. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  73. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  74. else
  75. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  76. }
  77. if (strworkid.Trim() != "" && strworkid != "undefined")
  78. {
  79. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  80. }
  81. if (strname.Trim() != "" && strname != "undefined")
  82. {
  83. sql += " and F_CusName like '%" + strname + "%' ";
  84. }
  85. if (strtel.Trim() != "" && strtel != "undefined")
  86. {
  87. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  88. }
  89. if (strkey.Trim() != "" && strkey != "undefined")
  90. {
  91. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  92. }
  93. if (strusercode.Trim() != "" && strusercode != "undefined")
  94. {//坐席
  95. var usercode = strusercode.Trim().Split(',');
  96. var newusercode = "";
  97. foreach (var item in usercode)
  98. {
  99. if (!string.IsNullOrWhiteSpace(item.Trim()))
  100. newusercode += "'" + item + "',";
  101. }
  102. newusercode = newusercode.Trim(',');
  103. if (newusercode.Trim() != "" && newusercode != "undefined")
  104. {
  105. sql += " and F_CreateUser in (" + newusercode + ") ";
  106. //sql += " and F_CreateUser ='" + strusercode + "' ";
  107. }
  108. }
  109. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  110. {//调度员
  111. var ddusercode = strddusercode.Trim().Split(',');
  112. var newusercode = "";
  113. foreach (var item in ddusercode)
  114. {
  115. if (!string.IsNullOrWhiteSpace(item.Trim()))
  116. newusercode += "'" + item + "',";
  117. }
  118. newusercode = newusercode.Trim(',');
  119. if (newusercode.Trim() != "" && newusercode != "undefined")
  120. {
  121. sql += " and F_AssignUser in(" + newusercode + ") ";
  122. //sql += " and F_AssignUser = '" + strddusercode + "' ";
  123. }
  124. }
  125. if (source != 0)
  126. {
  127. sql += " and F_InfoSource = '" + source + "' ";
  128. }
  129. if (keyid != 0)
  130. {
  131. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  132. }
  133. else if (userModel.F_RoleCode == "DFZF")
  134. {
  135. sql += " and F_CreateUser ='"+ userModel .F_UserCode + "' ";
  136. }
  137. if (type != 0)
  138. {
  139. sql += " and F_InfoType = '" + type + "' ";
  140. }
  141. if (bigtype != 0)
  142. {
  143. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  144. }
  145. if (smalltype != 0)
  146. {
  147. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  148. }
  149. if (sourcearea != 0)
  150. {
  151. sql += " and F_SourceArea = '" + sourcearea + "' ";
  152. }
  153. if (deptid != 0)
  154. {
  155. //sql += " and ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%'";
  156. //sql += " and isnull(F_MainDeptId,null)='"+ deptid + "'";
  157. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  158. #region 20190924 zhengbingbing 主办单位查询以最后办理单位为准
  159. //if (deptlevel == 0)
  160. //{
  161. // string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  162. // sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  163. //}
  164. //else
  165. //{
  166. // string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  167. // sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  168. //}
  169. #endregion
  170. }
  171. if (dealtype != -1)
  172. {
  173. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  174. }
  175. if (issend != -1)
  176. {
  177. sql += " and isnull(F_IsRelease,0) = '" + issend + "' ";
  178. }
  179. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  180. {
  181. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  182. }
  183. if (strendtime.Trim() != "" && strendtime != "undefined")
  184. {
  185. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  186. }
  187. #endregion
  188. if (strpageindex.Trim() != "")
  189. {
  190. pageindex = Convert.ToInt32(strpageindex);
  191. }
  192. if (strpagesize.Trim() != "")
  193. {
  194. pagesize = Convert.ToInt32(strpagesize);
  195. }
  196. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  197. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  198. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  199. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  200. #region 导出
  201. if (isdc > 0)
  202. {
  203. var top = " "; var orderby = " order by F_CreateTime";
  204. if (sql == " and F_IsDelete=0 ")
  205. {
  206. top = " top 1000 "; orderby += " desc ";
  207. }
  208. //20190715调整导出字段 zhengbingbing
  209. //日期,工单号,诉求标题,诉求内容,承办单位,办理结果,是否满意,备注
  210. var dtdc = DbHelperSQL.Query(" select "+ top + " F_CreateTime 日期, F_WorkOrderId 工单号,F_ComTitle 诉求标题,F_ComContent 诉求内容,dbo.GetDictionaryName(F_Key) 主题词, "
  211. + " dbo.GetDeptNames(convert(nvarchar,(select top 1 F_MainDeptId from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId=wo.F_WorkOrderId and F_IsDelete=0 and F_State=1 and F_IsSure<>3 order by F_Id desc))) 主办单位, "
  212. + " dbo.GetDeptNames(convert(nvarchar,(select top 1 F_OtherDeptIds from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId=wo.F_WorkOrderId and F_IsDelete=0 and F_State=1 and F_IsSure<>3 order by F_Id desc))) 协办单位, "
  213. + " (select top 1 F_Result from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId =wo.F_WorkOrderId order by F_Id desc) 办理结果, "
  214. + " (select top 1 (case F_IsSatisfie when 1 then'满意' when 0 then '不满意' else '未评价' end) F_Satisfie from T_Bus_VisitResult WITH(NOLOCK) where F_State = 1 and F_IsDelete = 0 and F_WorkOrderId = wo.F_WorkOrderId order by F_Id desc) 是否满意 "
  215. + " from T_Bus_WorkOrder wo WITH(NOLOCK) where 1=1 " + sql+ orderby).Tables[0];
  216. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  217. if (msg == "")
  218. {
  219. return Success("导出成功");
  220. }
  221. else
  222. {
  223. return Error("导出失败");
  224. }
  225. }
  226. #endregion
  227. int recordCount = 0;
  228. dt = BLL.PagerBLL.GetListPager(
  229. "T_Bus_WorkOrder WITH(NOLOCK)",
  230. "F_WorkOrderId",
  231. cols,
  232. sql,
  233. "ORDER BY F_CreateTime DESC",
  234. pagesize,
  235. pageindex,
  236. true,
  237. out recordCount);
  238. #region 声音文件和交办超时
  239. dt.Columns.Add("DeptName", typeof(string));//交办单位
  240. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  241. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  242. dt.Columns.Add("OverState", typeof(string));//超时状态
  243. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  244. dt.Columns.Add("GapTime", typeof(string));//时间差
  245. dt.Columns.Add("PDState", typeof(string));//派单状态
  246. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  247. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  248. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  249. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  250. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  251. var reminds = remindBLL.GetModelList(" F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  252. foreach (DataRow dr in dt.Rows)
  253. {
  254. string iszbdw = "0";
  255. string ispd = "";
  256. int state = Int32.Parse(dr["F_WorkState"].ToString());
  257. if (state > 1)
  258. {
  259. //获取最新交办信息
  260. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  261. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  262. if (dtjb.Rows.Count > 0)
  263. {
  264. //if (dtjb.Rows[0]["F_MainDeptId"].ToString().Split(',').Contains(userModel.F_DeptId.ToString())) { iszbdw = "1"; }
  265. if (dr["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  266. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dr["F_MainDeptId"].ToString() + "')");
  267. if (dr["F_OtherDeptIds"] != null && dr["F_OtherDeptIds"].ToString() != "")
  268. {
  269. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dr["F_OtherDeptIds"].ToString() + "')");
  270. }
  271. #region 20191016
  272. //if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  273. //dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  274. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  275. //{
  276. // dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  277. //}
  278. #endregion
  279. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  280. #region
  281. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  282. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  283. //if (deptinfo != null)
  284. //{
  285. // if (did == userModel.F_DeptId) { iszbdw = "1"; }
  286. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  287. //}
  288. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  289. //{
  290. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  291. // string dns = string.Empty;
  292. // foreach (string strid in strids)
  293. // {
  294. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  295. // if (dinfo != null)
  296. // {
  297. // if (string.IsNullOrEmpty(dns))
  298. // {
  299. // dns = dinfo.F_DeptName;//交办单位
  300. // }
  301. // else
  302. // {
  303. // dns += "," + dinfo.F_DeptName;//交办单位
  304. // }
  305. // }
  306. // }
  307. // dr["OtherDeptName"] = dns;
  308. //}
  309. #endregion
  310. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  311. dr["LimitTime"] = lt;
  312. #region 超时时限
  313. //if (state < 6 || state == 8)
  314. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  315. {
  316. if (!string.IsNullOrWhiteSpace(lt))
  317. {
  318. var ltime = DateTime.Parse(lt);
  319. TimeSpan ts = ltime.Subtract(DateTime.Now);
  320. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  321. if (tss < 0) { tss = -tss; }
  322. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  323. if (ltime > DateTime.Now)
  324. {
  325. if (configcs != null)
  326. {
  327. int cs = Int32.Parse(configcs.F_ParamValue);
  328. if (ts.TotalHours > cs)
  329. {
  330. dr["OverState"] = 1;
  331. }
  332. else
  333. {
  334. dr["OverState"] = 2;
  335. }
  336. }
  337. dr["GapTime"] = "剩余" + gshsj;
  338. }
  339. else
  340. {
  341. dr["OverState"] = 3;
  342. dr["GapTime"] = "超时" + gshsj;
  343. }
  344. }
  345. ispd = dtjb.Rows[0]["F_IsNext"] != null ? dtjb.Rows[0]["F_IsNext"].ToString() : "";
  346. dr["PDState"] = ispd;
  347. }
  348. if (state == (int)EnumWorkState.finish)
  349. {
  350. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  351. var dttime = DateTime.Now;
  352. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  353. if (!string.IsNullOrWhiteSpace(lt))
  354. {
  355. var ltime = DateTime.Parse(lt);
  356. TimeSpan ts = ltime.Subtract(dttime);
  357. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  358. if (tss < 0) { tss = -tss; }
  359. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  360. if (ltime < dttime)
  361. {
  362. dr["OverState"] = 3;
  363. dr["GapTime"] = "超时" + gshsj;
  364. }
  365. }
  366. }
  367. #endregion
  368. }
  369. }
  370. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  371. {
  372. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  373. }
  374. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  375. {
  376. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  377. }
  378. var buttons= ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw, ispd);
  379. #region 判断是否存在待督办
  380. var recount = reminds.Where(r => r.F_WorkOrderId.Equals(dr["F_WorkOrderId"].ToString())).Count();
  381. var butt = buttons.Find(c => c.key == ButtonGroup.turnsee().key);
  382. if (recount > 0 && butt!=null)
  383. buttons.Remove(butt);
  384. #endregion
  385. dr["Buttons"] = buttons;
  386. }
  387. #endregion
  388. var obj = new
  389. {
  390. state = "success",
  391. message = "成功",
  392. rows = dt,
  393. total = recordCount
  394. };
  395. return Content(obj.ToJson());
  396. }
  397. /// <summary>
  398. /// 获取坐席处理列表
  399. /// </summary>
  400. /// <returns></returns>
  401. [Authority]
  402. public ActionResult GetZXDealList(int isdc = 0)
  403. {
  404. DataTable dt = new DataTable();
  405. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  406. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  407. string sql = " and F_IsDelete=0";
  408. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  409. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  410. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  411. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  412. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  413. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  414. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  415. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  416. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  417. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  418. int source = RequestString.GetInt("source", 0);
  419. int keyid = RequestString.GetInt("keyid", 0);
  420. int type = RequestString.GetInt("type", 0);
  421. int bigtype = RequestString.GetInt("bigtype", 0);
  422. int smalltype = RequestString.GetInt("smalltype", 0);
  423. int sourcearea = RequestString.GetInt("sourcearea", 0);
  424. int deptid = RequestString.GetInt("deptid", 0);
  425. int deptlevel = RequestString.GetInt("deptlevel", 0);
  426. string strpageindex = RequestString.GetQueryString("page");
  427. int pageindex = 1;
  428. string strpagesize = RequestString.GetQueryString("pagesize");
  429. int pagesize = 10;
  430. switch (strtab)
  431. {
  432. case "-1"://待处理工单(其他来源)
  433. sql = " and F_IsDelete=1 and F_IsEnabled=0 ";
  434. break;
  435. case "0"://待处理工单
  436. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  437. {
  438. if (userModel.F_RoleCode != "ZJZY")
  439. sql += " and F_CreateUser='" + userModel.F_UserCode + "'";
  440. }
  441. if (strstate.Trim() != "" && strstate != "undefined")
  442. {
  443. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString())
  444. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  445. else
  446. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  447. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  448. }
  449. else
  450. {
  451. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + "," + (int)EnumWorkState.dealed + ") ";
  452. //sql += " and F_WorkState in (0,6) ";
  453. }
  454. break;
  455. case "1"://已提交的工单
  456. //sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 ";
  457. sql += " and F_WorkState >0 ";
  458. if (strstate.Trim() != "" && strstate != "undefined")
  459. {
  460. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  461. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  462. else
  463. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  464. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  465. }
  466. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  467. {
  468. sql += " and F_CreateUser='" + userModel.F_UserCode + "'";
  469. }
  470. break;
  471. case "2"://已回访的工单
  472. if (strstate.Trim() != "" && strstate != "undefined")
  473. {
  474. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  475. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  476. else
  477. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  478. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  479. }
  480. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_VisitResult WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  481. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  482. {
  483. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  484. }
  485. else
  486. {
  487. sql += ")";
  488. }
  489. break;
  490. case "3"://已回退的工单
  491. //sql += " and F_WorkState=0 and F_IsReturn=1 ";
  492. sql += " and F_WorkState in (0,10) and F_IsReturn=1";
  493. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  494. {
  495. sql += " and F_CreateUser='" + userModel.F_UserCode;
  496. }
  497. break;
  498. }
  499. if (strworkid.Trim() != "" && strworkid != "undefined")
  500. {
  501. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  502. }
  503. if (strname.Trim() != "" && strname != "undefined")
  504. {
  505. sql += " and F_CusName like '%" + strname + "%' ";
  506. }
  507. if (strtel.Trim() != "" && strtel != "undefined")
  508. {
  509. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  510. }
  511. if (strkey.Trim() != "" && strkey != "undefined")
  512. {
  513. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  514. }
  515. #region 坐席&调度员
  516. if (strusercode.Trim() != "" && strusercode != "undefined")
  517. {//坐席
  518. var usercode = strusercode.Trim().Split(',');
  519. var newusercode = "";
  520. foreach (var item in usercode)
  521. {
  522. if (!string.IsNullOrWhiteSpace(item.Trim()))
  523. newusercode += "'" + item + "',";
  524. }
  525. newusercode = newusercode.Trim(',');
  526. if (newusercode.Trim() != "" && newusercode != "undefined")
  527. {
  528. sql += " and F_CreateUser in (" + newusercode + ") ";
  529. }
  530. }
  531. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  532. {//调度员
  533. var ddusercode = strddusercode.Trim().Split(',');
  534. var newusercode = "";
  535. foreach (var item in ddusercode)
  536. {
  537. if (!string.IsNullOrWhiteSpace(item.Trim()))
  538. newusercode += "'" + item + "',";
  539. }
  540. newusercode = newusercode.Trim(',');
  541. if (newusercode.Trim() != "" && newusercode != "undefined")
  542. {
  543. sql += " and F_AssignUser in(" + newusercode + ") ";
  544. }
  545. }
  546. //if (strusercode.Trim() != "" && strusercode != "undefined")
  547. //{
  548. // sql += " and F_CreateUser = '" + strusercode + "' ";
  549. //}
  550. #endregion
  551. if (source != 0)
  552. {
  553. sql += " and F_InfoSource = '" + source + "' ";
  554. }
  555. if (keyid != 0)
  556. {
  557. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  558. }
  559. if (type != 0)
  560. {
  561. sql += " and F_InfoType = '" + type + "' ";
  562. }
  563. if (bigtype != 0)
  564. {
  565. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  566. }
  567. if (smalltype != 0)
  568. {
  569. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  570. }
  571. if (sourcearea != 0)
  572. {
  573. sql += " and F_SourceArea = '" + sourcearea + "' ";
  574. }
  575. if (deptid != 0)
  576. {
  577. //sql += " and ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%'";
  578. //sql += " and isnull(F_MainDeptId,null)='" + deptid + "'";
  579. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  580. #region 20190924 zhengbingbing 主办单位查询以最后办理单位为准
  581. //if (deptlevel == 0)
  582. //{
  583. // string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  584. // sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  585. //}
  586. //else
  587. //{
  588. // string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  589. // sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  590. //}
  591. #endregion
  592. }
  593. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  594. {
  595. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  596. }
  597. if (strendtime.Trim() != "" && strendtime != "undefined")
  598. {
  599. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  600. }
  601. if (strpageindex.Trim() != "")
  602. {
  603. pageindex = Convert.ToInt32(strpageindex);
  604. }
  605. if (strpagesize.Trim() != "")
  606. {
  607. pagesize = Convert.ToInt32(strpagesize);
  608. }
  609. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  610. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  611. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  612. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  613. if (isdc > 0)
  614. {
  615. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  616. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  617. if (msg == "")
  618. {
  619. return Success("导出成功");
  620. }
  621. else
  622. {
  623. return Error("导出失败");
  624. }
  625. }
  626. int recordCount = 0;
  627. dt = BLL.PagerBLL.GetListPager(
  628. "T_Bus_WorkOrder WITH(NOLOCK)",
  629. "F_WorkOrderId",
  630. cols,
  631. sql,
  632. "ORDER BY F_CreateTime DESC",
  633. pagesize,
  634. pageindex,
  635. true,
  636. out recordCount);
  637. dt.Columns.Add("DeptName", typeof(string));//交办单位
  638. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  639. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  640. dt.Columns.Add("OverState", typeof(string));//超时状态
  641. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  642. dt.Columns.Add("GapTime", typeof(string));//时间差
  643. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  644. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  645. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  646. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  647. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  648. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  649. foreach (DataRow dr in dt.Rows)
  650. {
  651. //获取最新交办信息
  652. string iszbdw = "0";
  653. int state = Int32.Parse(dr["F_WorkState"].ToString());
  654. if (state > 1)
  655. {
  656. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  657. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  658. if (dtjb.Rows.Count > 0)
  659. {
  660. //if (dtjb.Rows[0]["F_MainDeptId"].ToString().Split(',').Contains(userModel.F_DeptId.ToString())) { iszbdw = "1"; }
  661. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  662. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  663. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  664. {
  665. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  666. }
  667. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  668. #region
  669. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  670. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  671. //if (deptinfo != null)
  672. //{
  673. // if (did == userModel.F_DeptId) { iszbdw = "1"; }
  674. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  675. //}
  676. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  677. //{
  678. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  679. // string dns = string.Empty;
  680. // foreach (string strid in strids)
  681. // {
  682. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  683. // if (dinfo != null)
  684. // {
  685. // if (string.IsNullOrEmpty(dns))
  686. // {
  687. // dns = dinfo.F_DeptName;//交办单位
  688. // }
  689. // else
  690. // {
  691. // dns += "," + dinfo.F_DeptName;//交办单位
  692. // }
  693. // }
  694. // }
  695. // dr["OtherDeptName"] = dns;
  696. //}
  697. #endregion
  698. #region
  699. //if (state < 6 || state == 8)
  700. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  701. {
  702. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  703. dr["LimitTime"] = lt;
  704. if (!string.IsNullOrWhiteSpace(lt))
  705. {
  706. var ltime = DateTime.Parse(lt);
  707. TimeSpan ts = ltime.Subtract(DateTime.Now);
  708. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  709. if (tss < 0) { tss = -tss; }
  710. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  711. if (ltime > DateTime.Now)
  712. {
  713. if (configcs != null)
  714. {
  715. int cs = Int32.Parse(configcs.F_ParamValue);
  716. if (ts.TotalHours > cs)
  717. {
  718. dr["OverState"] = 1;
  719. }
  720. else
  721. {
  722. dr["OverState"] = 2;
  723. }
  724. }
  725. dr["GapTime"] = "剩余" + gshsj;
  726. }
  727. else
  728. {
  729. dr["OverState"] = 3;
  730. dr["GapTime"] = "超时" + gshsj;
  731. }
  732. }
  733. }
  734. if (state == (int)EnumWorkState.finish)
  735. {
  736. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  737. var dttime = DateTime.Now;
  738. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  739. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  740. dr["LimitTime"] = lt;
  741. if (!string.IsNullOrWhiteSpace(lt))
  742. {
  743. var ltime = DateTime.Parse(lt);
  744. TimeSpan ts = ltime.Subtract(dttime);
  745. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  746. if (tss < 0) { tss = -tss; }
  747. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  748. if (ltime < dttime)
  749. {
  750. dr["OverState"] = 3;
  751. dr["GapTime"] = "超时" + gshsj;
  752. }
  753. }
  754. }
  755. #endregion
  756. }
  757. }
  758. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  759. {
  760. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  761. }
  762. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  763. {
  764. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  765. }
  766. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  767. if (Int32.Parse(strtab) == 0)
  768. {
  769. btns.Clear();
  770. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw);
  771. #region 判断是否存在待督办
  772. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  773. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  774. if (recount > 0 && butt != null)
  775. btns.Remove(butt);
  776. #endregion
  777. }
  778. else if (Int32.Parse(strtab) == -1)
  779. {
  780. btns.Clear();
  781. btns.Add(ButtonGroup.query());
  782. btns.Add(ButtonGroup.edit());
  783. }
  784. else
  785. {
  786. btns.Clear();
  787. btns.Add(ButtonGroup.query());
  788. }
  789. dr["Buttons"] = btns;
  790. }
  791. var obj = new
  792. {
  793. state = "success",
  794. message = "成功",
  795. rows = dt,
  796. total = recordCount
  797. };
  798. return Content(obj.ToJson());
  799. }
  800. /// <summary>
  801. /// 获取领导处理列表
  802. /// </summary>
  803. /// <returns></returns>
  804. [Authority]
  805. public ActionResult GetLDDealList(int isdc = 0)
  806. {
  807. DataTable dt = new DataTable();
  808. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  809. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  810. string sql = " and F_IsDelete=0";
  811. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  812. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  813. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  814. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  815. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  816. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  817. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  818. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  819. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  820. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  821. int source = RequestString.GetInt("source", 0);
  822. int keyid = RequestString.GetInt("keyid", 0);
  823. int type = RequestString.GetInt("type", 0);
  824. int bigtype = RequestString.GetInt("bigtype", 0);
  825. int smalltype = RequestString.GetInt("smalltype", 0);
  826. int sourcearea = RequestString.GetInt("sourcearea", 0);
  827. int deptid = RequestString.GetInt("deptid", 0);
  828. int deptlevel = RequestString.GetInt("deptlevel", 0);
  829. int issatisfie = RequestString.GetInt("issatisfie", -1);//0不满意 1满意
  830. string strpageindex = RequestString.GetQueryString("page");
  831. int pageindex = 1;
  832. string strpagesize = RequestString.GetQueryString("pagesize");
  833. int pagesize = 10;
  834. switch (strtab)
  835. {
  836. case "0"://待处理工单
  837. if (strstate.Trim() != "" && strstate != "undefined")
  838. {
  839. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  840. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  841. else
  842. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  843. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  844. if (strstate.Trim() == ((int)EnumWorkState.visit).ToString() && issatisfie != -1)
  845. {
  846. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_VisitResult WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  847. sql += " and F_IsSatisfie='" + issatisfie + "')";
  848. }
  849. if (strstate.Trim() != ((int)EnumWorkState.submit).ToString())
  850. {
  851. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  852. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  853. {
  854. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  855. }
  856. else
  857. {
  858. sql += ")";
  859. }
  860. }
  861. else
  862. {
  863. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  864. {
  865. sql += " and (F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State = 1 and F_IsDelete = 0 "
  866. + "and F_CreateUser = '" + userModel.F_UserCode + "') or (select top 1 F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where"
  867. + " F_State = 1 and F_IsDelete = 0 and T_Bus_AssignedInfo.F_WorkOrderId = T_Bus_WorkOrder.F_WorkOrderId) is null)";
  868. }
  869. }
  870. }
  871. else
  872. {
  873. //int[] sts = new int[] { (int)EnumWorkState.submit, (int)EnumWorkState.receive, (int)EnumWorkState.auditreback, (int)EnumWorkState.auditdelay, (int)EnumWorkState.visit, (int)EnumWorkState.reload };
  874. //sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  875. ////sql += " and F_WorkState in (1,2,3,5,7,8)";
  876. int[] sts = new int[] { (int)EnumWorkState.receive, (int)EnumWorkState.auditreback, (int)EnumWorkState.auditdelay, (int)EnumWorkState.visit, (int)EnumWorkState.reload };
  877. sql += " and (F_WorkState='" + (int)EnumWorkState.submit + "' or ( F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ") and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  878. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  879. {
  880. sql += " and F_CreateUser='" + userModel.F_UserCode + "')))";
  881. }
  882. else
  883. {
  884. sql += ")))";
  885. }
  886. }
  887. break;
  888. case "1"://已交办的工单
  889. string strjbstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("jbstarttime"));
  890. string strjbendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("jbendtime"));
  891. if (strstate.Trim() != "" && strstate != "undefined")
  892. {
  893. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  894. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  895. else
  896. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  897. // sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  898. }
  899. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  900. if (strjbstarttime.Trim() != "" && strjbstarttime != "undefined")
  901. {
  902. sql += " and datediff(day,F_CreateTime,'" + strjbstarttime + "')<=0 ";
  903. }
  904. if (strjbendtime.Trim() != "" && strjbendtime != "undefined")
  905. {
  906. sql += " and datediff(day,F_CreateTime,'" + strjbendtime + "')>=0 ";
  907. }
  908. //if (deptid != 0)
  909. //{
  910. // //sql += " and ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%'";
  911. // sql += " and F_MainDeptId = '" + deptid + "'";
  912. //}
  913. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  914. {
  915. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  916. }
  917. else
  918. {
  919. sql += ")";
  920. }
  921. break;
  922. case "2"://已审核退回的工单
  923. if (strstate.Trim() != "" && strstate != "undefined")
  924. {
  925. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  926. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  927. else
  928. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  929. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  930. }
  931. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsAudit>0 ";
  932. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  933. {
  934. sql += " and F_AuditUser='" + userModel.F_UserCode + "')";
  935. }
  936. else
  937. {
  938. sql += ")";
  939. }
  940. break;
  941. case "3"://已审核延时的工单
  942. if (strstate.Trim() != "" && strstate != "undefined")
  943. {
  944. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  945. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  946. else
  947. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  948. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  949. }
  950. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_DelayTime WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsAudit>0 ";
  951. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  952. {
  953. sql += " and F_AuditUser='" + userModel.F_UserCode + "')";
  954. }
  955. else
  956. {
  957. sql += ")";
  958. }
  959. break;
  960. case "4"://已重办的工单
  961. if (strstate.Trim() != "" && strstate != "undefined")
  962. {
  963. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  964. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  965. else
  966. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  967. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  968. }
  969. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsReload>0 ";
  970. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  971. {
  972. sql += " and F_ReloadUser='" + userModel.F_UserCode + "')";
  973. }
  974. else
  975. {
  976. sql += ")";
  977. }
  978. break;
  979. case "5"://已结案的工单
  980. string strwjstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("wjstarttime"));
  981. string strwjendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("wjendtime"));
  982. sql += " and F_WorkState =9 and F_IsDelete=0 and F_IsClosed=1 ";
  983. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  984. {
  985. sql += " and F_CloseUser='" + userModel.F_UserCode + "'";
  986. }
  987. if (strwjstarttime.Trim() != "" && strwjstarttime != "undefined")
  988. {
  989. sql += " and datediff(day,F_CloseTime,'" + strwjstarttime + "')<=0 ";
  990. }
  991. if (strwjendtime.Trim() != "" && strwjendtime != "undefined")
  992. {
  993. sql += " and datediff(day,F_CloseTime,'" + strwjendtime + "')>=0 ";
  994. }
  995. break;
  996. case "6"://已督办的工单
  997. if (strstate.Trim() != "" && strstate != "undefined")
  998. {
  999. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1000. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1001. else
  1002. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1003. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1004. }
  1005. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type =1 ";
  1006. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1007. {
  1008. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1009. }
  1010. else
  1011. {
  1012. sql += ")";
  1013. }
  1014. break;
  1015. case "7"://已监察的工单
  1016. if (strstate.Trim() != "" && strstate != "undefined")
  1017. {
  1018. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1019. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1020. else
  1021. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1022. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1023. }
  1024. //sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord where F_State=1 and F_IsDelete=0 and F_Type =2 ";
  1025. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_IsDelete=0 and F_Type =2 ";
  1026. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1027. {
  1028. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1029. }
  1030. else
  1031. {
  1032. sql += ")";
  1033. }
  1034. break;
  1035. case "8"://待督办列表
  1036. //20190315需求变动,由督办查看督办列表并监管 20190401 zhengbingbing
  1037. if (strstate.Trim() != "" && strstate != "undefined")
  1038. {
  1039. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1040. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1041. else
  1042. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1043. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1044. }
  1045. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_State=0 and F_IsDelete=0 and F_Type =1 ";
  1046. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode!= "DBZY" && userModel.F_RoleCode != "DDZG")
  1047. {
  1048. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1049. }
  1050. else
  1051. {
  1052. sql += ")";
  1053. }
  1054. break;
  1055. case "9"://重办驳回列表
  1056. sql += " and F_WorkState="+ (int)EnumWorkState.rejload;
  1057. sql += " and F_WorkOrderID in (select F_WorkOrderId from T_Bus_Operation WITH(NOLOCK) where F_Id in (select max(F_Id) from T_Bus_Operation WITH(NOLOCK) where F_State = " + (int)EnumWorkState.resubmit + " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_Operation WITH(NOLOCK) where F_State=" + (int)EnumWorkState.rejload + ") group by F_WorkOrderId)";
  1058. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1059. {
  1060. sql += " and F_CreateUser='" + userModel.F_UserCode + "'";
  1061. }
  1062. sql += ")";
  1063. break;
  1064. }
  1065. if (strworkid.Trim() != "" && strworkid != "undefined")
  1066. {
  1067. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  1068. }
  1069. if (strname.Trim() != "" && strname != "undefined")
  1070. {
  1071. sql += " and F_CusName like '%" + strname + "%' ";
  1072. }
  1073. if (strtel.Trim() != "" && strtel != "undefined")
  1074. {
  1075. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  1076. }
  1077. if (strkey.Trim() != "" && strkey != "undefined")
  1078. {
  1079. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  1080. }
  1081. #region 坐席&调度员
  1082. if (strusercode.Trim() != "" && strusercode != "undefined")
  1083. {//坐席
  1084. var usercode = strusercode.Trim().Split(',');
  1085. var newusercode = "";
  1086. foreach (var item in usercode)
  1087. {
  1088. if (!string.IsNullOrWhiteSpace(item.Trim()))
  1089. newusercode += "'" + item + "',";
  1090. }
  1091. newusercode = newusercode.Trim(',');
  1092. if (newusercode.Trim() != "" && newusercode != "undefined")
  1093. {
  1094. sql += " and F_CreateUser in (" + newusercode + ") ";
  1095. }
  1096. }
  1097. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  1098. {//调度员
  1099. var ddusercode = strddusercode.Trim().Split(',');
  1100. var newusercode = "";
  1101. foreach (var item in ddusercode)
  1102. {
  1103. if (!string.IsNullOrWhiteSpace(item.Trim()))
  1104. newusercode += "'" + item + "',";
  1105. }
  1106. newusercode = newusercode.Trim(',');
  1107. if (newusercode.Trim() != "" && newusercode != "undefined")
  1108. {
  1109. sql += " and F_AssignUser in(" + newusercode + ") ";
  1110. }
  1111. }
  1112. //if (strusercode.Trim() != "" && strusercode != "undefined")
  1113. //{
  1114. // sql += " and F_CreateUser = '" + strusercode + "' ";
  1115. //}
  1116. #endregion
  1117. if (source != 0)
  1118. {
  1119. sql += " and F_InfoSource = '" + source + "' ";
  1120. }
  1121. if (keyid != 0)
  1122. {
  1123. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  1124. }
  1125. if (type != 0)
  1126. {
  1127. sql += " and F_InfoType = '" + type + "' ";
  1128. }
  1129. if (bigtype != 0)
  1130. {
  1131. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  1132. }
  1133. if (smalltype != 0)
  1134. {
  1135. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  1136. }
  1137. if (sourcearea != 0)
  1138. {
  1139. sql += " and F_SourceArea = '" + sourcearea + "' ";
  1140. }
  1141. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1142. {
  1143. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  1144. }
  1145. if (strendtime.Trim() != "" && strendtime != "undefined")
  1146. {
  1147. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  1148. }
  1149. if (deptid != 0 && strtab != "1")
  1150. {
  1151. if (deptlevel == 0)
  1152. {
  1153. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  1154. //string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  1155. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  1156. }
  1157. else
  1158. {
  1159. //string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next where ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  1160. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  1161. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  1162. }
  1163. }
  1164. if(deptid!=0)
  1165. {
  1166. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  1167. }
  1168. if (strpageindex.Trim() != "")
  1169. {
  1170. pageindex = Convert.ToInt32(strpageindex);
  1171. }
  1172. if (strpagesize.Trim() != "")
  1173. {
  1174. pagesize = Convert.ToInt32(strpagesize);
  1175. }
  1176. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  1177. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  1178. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  1179. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  1180. if (isdc > 0)
  1181. {
  1182. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  1183. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  1184. if (msg == "")
  1185. {
  1186. return Success("导出成功");
  1187. }
  1188. else
  1189. {
  1190. return Error("导出失败");
  1191. }
  1192. }
  1193. int recordCount = 0;
  1194. dt = BLL.PagerBLL.GetListPager(
  1195. "T_Bus_WorkOrder WITH(NOLOCK)",
  1196. "F_WorkOrderId",
  1197. cols,
  1198. sql,
  1199. "ORDER BY F_CreateTime DESC",
  1200. pagesize,
  1201. pageindex,
  1202. true,
  1203. out recordCount);
  1204. #region 声音文件
  1205. dt.Columns.Add("DeptName", typeof(string));//交办单位
  1206. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  1207. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  1208. dt.Columns.Add("OverState", typeof(string));//超时状态
  1209. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  1210. dt.Columns.Add("GapTime", typeof(string));//时间差
  1211. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  1212. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  1213. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  1214. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  1215. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  1216. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  1217. foreach (DataRow dr in dt.Rows)
  1218. {
  1219. //获取最新交办信息
  1220. string iszbdw = "0";
  1221. int state = Int32.Parse(dr["F_WorkState"].ToString());
  1222. if (state > 1)
  1223. {
  1224. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  1225. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  1226. if (dtjb.Rows.Count > 0)
  1227. {
  1228. //if (dtjb.Rows[0]["F_MainDeptId"] != null && dtjb.Rows[0]["F_MainDeptId"].ToString().Split(',').Contains(userModel.F_DeptId.ToString())) { iszbdw = "1"; }
  1229. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  1230. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  1231. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  1232. {
  1233. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  1234. }
  1235. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  1236. #region
  1237. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  1238. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  1239. //if (deptinfo != null)
  1240. //{
  1241. // if (did == userModel.F_DeptId) { iszbdw = "1"; }
  1242. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  1243. //}
  1244. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  1245. //{
  1246. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  1247. // string dns = string.Empty;
  1248. // foreach (string strid in strids)
  1249. // {
  1250. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  1251. // if (dinfo != null)
  1252. // {
  1253. // if (string.IsNullOrEmpty(dns))
  1254. // {
  1255. // dns = dinfo.F_DeptName;//交办单位
  1256. // }
  1257. // else
  1258. // {
  1259. // dns += "," + dinfo.F_DeptName;//交办单位
  1260. // }
  1261. // }
  1262. // }
  1263. // dr["OtherDeptName"] = dns;
  1264. //}
  1265. #endregion
  1266. #region
  1267. //if (state < 6 || state == 8)
  1268. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  1269. {
  1270. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  1271. dr["LimitTime"] = lt;
  1272. if (!string.IsNullOrWhiteSpace(lt))
  1273. {
  1274. var ltime = DateTime.Parse(lt);
  1275. TimeSpan ts = ltime.Subtract(DateTime.Now);
  1276. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  1277. if (tss < 0) { tss = -tss; }
  1278. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  1279. if (ltime > DateTime.Now)
  1280. {
  1281. if (configcs != null)
  1282. {
  1283. int cs = Int32.Parse(configcs.F_ParamValue);
  1284. if (ts.TotalHours > cs)
  1285. {
  1286. dr["OverState"] = 1;
  1287. }
  1288. else
  1289. {
  1290. dr["OverState"] = 2;
  1291. }
  1292. }
  1293. dr["GapTime"] = "剩余" + gshsj;
  1294. }
  1295. else
  1296. {
  1297. dr["OverState"] = 3;
  1298. dr["GapTime"] = "超时" + gshsj;
  1299. }
  1300. }
  1301. }
  1302. if (state == (int)EnumWorkState.finish)
  1303. {
  1304. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  1305. var dttime = DateTime.Now;
  1306. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  1307. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  1308. dr["LimitTime"] = lt;
  1309. if (!string.IsNullOrWhiteSpace(lt))
  1310. {
  1311. var ltime = DateTime.Parse(lt);
  1312. TimeSpan ts = ltime.Subtract(dttime);
  1313. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  1314. if (tss < 0) { tss = -tss; }
  1315. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  1316. if (ltime < dttime)
  1317. {
  1318. dr["OverState"] = 3;
  1319. dr["GapTime"] = "超时" + gshsj;
  1320. }
  1321. }
  1322. }
  1323. #endregion
  1324. }
  1325. }
  1326. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  1327. {
  1328. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  1329. }
  1330. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  1331. {
  1332. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  1333. }
  1334. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  1335. if (Int32.Parse(strtab) <= 1)
  1336. {
  1337. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw);
  1338. #region 判断是否存在待督办
  1339. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  1340. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  1341. if (recount > 0 && butt != null)
  1342. btns.Remove(butt);
  1343. #endregion
  1344. }
  1345. else
  1346. {
  1347. btns.Clear();
  1348. if (Int32.Parse(strtab) == 8)
  1349. btns = ButtonGroup.GetButtons("12", userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw);
  1350. else
  1351. btns.Add(ButtonGroup.query());
  1352. }
  1353. dr["Buttons"] = btns;
  1354. }
  1355. #endregion
  1356. var obj = new
  1357. {
  1358. state = "success",
  1359. message = "成功",
  1360. rows = dt,
  1361. total = recordCount
  1362. };
  1363. return Content(obj.ToJson());
  1364. }
  1365. /// <summary>
  1366. /// 获取单位处理列表
  1367. /// </summary>
  1368. /// <returns></returns>
  1369. [Authority]
  1370. public ActionResult GetDWDealList(int isdc = 0)
  1371. {
  1372. DataTable dt = new DataTable();
  1373. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  1374. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  1375. string sql = " and F_IsDelete=0";
  1376. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  1377. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  1378. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  1379. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  1380. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  1381. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  1382. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  1383. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  1384. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  1385. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  1386. int source = RequestString.GetInt("source", 0);
  1387. int keyid = RequestString.GetInt("keyid", 0);
  1388. int type = RequestString.GetInt("type", 0);
  1389. int bigtype = RequestString.GetInt("bigtype", 0);
  1390. int smalltype = RequestString.GetInt("smalltype", 0);
  1391. int sourcearea = RequestString.GetInt("sourcearea", 0);
  1392. int deptid = RequestString.GetInt("deptid", 0);
  1393. int deptlevel = RequestString.GetInt("deptlevel", 0);
  1394. string strpageindex = RequestString.GetQueryString("page");
  1395. int pageindex = 1;
  1396. string strpagesize = RequestString.GetQueryString("pagesize");
  1397. int pagesize = 10;
  1398. #region 模块
  1399. switch (strtab)
  1400. {
  1401. case "0"://待处理工单
  1402. int isyq = RequestString.GetInt("isyq", -1);
  1403. if (strstate.Trim() != "" && strstate != "undefined")
  1404. {
  1405. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1406. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1407. else
  1408. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1409. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1410. }
  1411. else
  1412. {
  1413. int[] sts = new int[] { (int)EnumWorkState.receive, (int)EnumWorkState.dealing, (int)EnumWorkState.reload };
  1414. sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  1415. //sql += " and F_WorkState in (2,4,8)";
  1416. }
  1417. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1418. {
  1419. sql += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1420. //+ " ISNULL(F_FeedbackTime, '')='' and ((F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1)) or "
  1421. //+ "(','+F_OtherDeptIds+',' like '%," + userModel.F_DeptId + ",%' and F_IsSure=1))";
  1422. //+ " ISNULL(F_FeedbackTime, '')='' and ',' + F_MainDeptID + ',' like '%," + userModel.F_DeptId + ",%' and F_IsSure in (0,1)";
  1423. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1)";
  1424. if (isyq != -1)
  1425. {
  1426. sql += " and dbo.GetOverState(F_WorkOrderId)=" + isyq;
  1427. }
  1428. else
  1429. {
  1430. sql += ")";
  1431. }
  1432. }
  1433. break;
  1434. case "1"://已查收的工单
  1435. if (strstate.Trim() != "" && strstate != "undefined")
  1436. {
  1437. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1438. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1439. else
  1440. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1441. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1442. }
  1443. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsSure=1 ";
  1444. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1445. {
  1446. sql += " and F_SureUser='" + userModel.F_UserCode + "')";
  1447. }
  1448. else
  1449. {
  1450. sql += ")";
  1451. }
  1452. break;
  1453. case "2"://已申请退回的工单
  1454. if (strstate.Trim() != "" && strstate != "undefined")
  1455. {
  1456. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1457. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1458. else
  1459. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1460. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1461. }
  1462. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type = 3 ";
  1463. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1464. {
  1465. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1466. }
  1467. else
  1468. {
  1469. sql += ")";
  1470. }
  1471. break;
  1472. case "3"://已申请延时的工单
  1473. if (strstate.Trim() != "" && strstate != "undefined")
  1474. {
  1475. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1476. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1477. else
  1478. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1479. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1480. }
  1481. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_DelayTime WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1482. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1483. {
  1484. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1485. }
  1486. else
  1487. {
  1488. sql += ")";
  1489. }
  1490. break;
  1491. case "4"://已办理的工单
  1492. if (strstate.Trim() != "" && strstate != "undefined")
  1493. {
  1494. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1495. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1496. else
  1497. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1498. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1499. }
  1500. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type in (1,2) ";
  1501. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1502. {
  1503. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1504. }
  1505. else
  1506. {
  1507. sql += ")";
  1508. }
  1509. break;
  1510. case "5"://被督办的工单
  1511. if (strstate.Trim() != "" && strstate != "undefined")
  1512. {
  1513. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1514. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1515. else
  1516. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1517. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1518. }
  1519. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type =1 ";
  1520. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1521. {
  1522. sql += " and F_DeptId='" + userModel.F_DeptId + "')";
  1523. }
  1524. else
  1525. {
  1526. sql += ")";
  1527. }
  1528. break;
  1529. case "6"://被监察的工单
  1530. if (strstate.Trim() != "" && strstate != "undefined")
  1531. {
  1532. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1533. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1534. else
  1535. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1536. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1537. }
  1538. //sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord where F_State=1 and F_IsDelete=0 and F_Type =2 ";
  1539. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_RemindRecord WITH(NOLOCK) where F_IsDelete=0 and F_Type =2 ";
  1540. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1541. {
  1542. sql += " and F_DeptId='" + userModel.F_DeptId + "')";
  1543. }
  1544. else
  1545. {
  1546. sql += ")";
  1547. }
  1548. break;
  1549. case "7"://延时审核中的工单
  1550. sql += " and F_WorkState = '" + (int)EnumWorkState.auditdelay + "' ";
  1551. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1552. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1553. {
  1554. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1555. }
  1556. else
  1557. {
  1558. sql += ")";
  1559. }
  1560. break;
  1561. case "8"://退回审核中的工单
  1562. sql += " and F_WorkState = '" + (int)EnumWorkState.auditreback + "' ";
  1563. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsSure=2 and isnull(F_FeedbackTime,'')=''";
  1564. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1565. {
  1566. sql += " and F_SureUser='" + userModel.F_UserCode + "')";
  1567. }
  1568. else
  1569. {
  1570. sql += ")";
  1571. }
  1572. break;
  1573. case "9"://需履职界定表
  1574. sql += " and F_WorkState in ('" + (int)EnumWorkState.visit + "','" + (int)EnumWorkState.resubmit + "','" + (int)EnumWorkState.reload + "','" + (int)EnumWorkState.rejload + "','" + (int)EnumWorkState.finish + "' )";
  1575. sql += " and F_WorkOrderID not in(select F_WorkOrderID from T_Bus_PerformDuties WITH(NOLOCK) where F_IsDelete=0 and F_State=1 )";
  1576. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_VisitResult WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsSatisfie=0 and F_AssignedId in(select F_ID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1577. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1578. {
  1579. sql += " and F_MainDeptId='" + userModel.F_DeptId + "' ";
  1580. }
  1581. sql += "))";
  1582. break;
  1583. case "10"://履职界定待审核表
  1584. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_PerformDuties WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsAudit=0 )";
  1585. break;
  1586. case "11"://履职界定已审核表
  1587. sql += " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_PerformDuties WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_IsAudit>0 )";
  1588. break;
  1589. }
  1590. #endregion
  1591. #region 条件
  1592. if (strworkid.Trim() != "" && strworkid != "undefined")
  1593. {
  1594. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  1595. }
  1596. if (strname.Trim() != "" && strname != "undefined")
  1597. {
  1598. sql += " and F_CusName like '%" + strname + "%' ";
  1599. }
  1600. if (strtel.Trim() != "" && strtel != "undefined")
  1601. {
  1602. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  1603. }
  1604. if (strkey.Trim() != "" && strkey != "undefined")
  1605. {
  1606. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  1607. }
  1608. #region 坐席&调度员
  1609. if (strusercode.Trim() != "" && strusercode != "undefined")
  1610. {//坐席
  1611. var usercode = strusercode.Trim().Split(',');
  1612. var newusercode = "";
  1613. foreach (var item in usercode)
  1614. {
  1615. if (!string.IsNullOrWhiteSpace(item.Trim()))
  1616. newusercode += "'" + item + "',";
  1617. }
  1618. newusercode = newusercode.Trim(',');
  1619. if (newusercode.Trim() != "" && newusercode != "undefined")
  1620. {
  1621. sql += " and F_CreateUser in (" + newusercode + ") ";
  1622. }
  1623. }
  1624. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  1625. {//调度员
  1626. var ddusercode = strddusercode.Trim().Split(',');
  1627. var newusercode = "";
  1628. foreach (var item in ddusercode)
  1629. {
  1630. if (!string.IsNullOrWhiteSpace(item.Trim()))
  1631. newusercode += "'" + item + "',";
  1632. }
  1633. newusercode = newusercode.Trim(',');
  1634. if (newusercode.Trim() != "" && newusercode != "undefined")
  1635. {
  1636. sql += " and F_AssignUser in(" + newusercode + ") ";
  1637. }
  1638. }
  1639. //if (strusercode.Trim() != "" && strusercode != "undefined")
  1640. //{
  1641. // sql += " and F_CreateUser = '" + strusercode + "' ";
  1642. //}
  1643. #endregion
  1644. if (source != 0)
  1645. {
  1646. sql += " and F_InfoSource = '" + source + "' ";
  1647. }
  1648. if (keyid != 0)
  1649. {
  1650. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  1651. }
  1652. if (type != 0)
  1653. {
  1654. sql += " and F_InfoType = '" + type + "' ";
  1655. }
  1656. if (bigtype != 0)
  1657. {
  1658. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  1659. }
  1660. if (smalltype != 0)
  1661. {
  1662. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  1663. }
  1664. if (sourcearea != 0)
  1665. {
  1666. sql += " and F_SourceArea = '" + sourcearea + "' ";
  1667. }
  1668. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1669. {
  1670. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  1671. }
  1672. if (strendtime.Trim() != "" && strendtime != "undefined")
  1673. {
  1674. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  1675. }
  1676. if(deptid!=0)
  1677. {
  1678. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  1679. }
  1680. if (strpageindex.Trim() != "")
  1681. {
  1682. pageindex = Convert.ToInt32(strpageindex);
  1683. }
  1684. if (strpagesize.Trim() != "")
  1685. {
  1686. pagesize = Convert.ToInt32(strpagesize);
  1687. }
  1688. #endregion
  1689. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  1690. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  1691. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  1692. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  1693. if (isdc > 0)
  1694. {
  1695. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  1696. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  1697. if (msg == "")
  1698. {
  1699. return Success("导出成功");
  1700. }
  1701. else
  1702. {
  1703. return Error("导出失败");
  1704. }
  1705. }
  1706. int recordCount = 0;
  1707. dt = BLL.PagerBLL.GetListPager(
  1708. "T_Bus_WorkOrder WITH(NOLOCK)",
  1709. "F_WorkOrderId",
  1710. cols,
  1711. sql,
  1712. "ORDER BY F_CreateTime DESC",
  1713. pagesize,
  1714. pageindex,
  1715. true,
  1716. out recordCount);
  1717. #region 声音文件
  1718. dt.Columns.Add("DeptName", typeof(string));//交办单位
  1719. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  1720. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  1721. dt.Columns.Add("OverState", typeof(string));//超时状态
  1722. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  1723. dt.Columns.Add("GapTime", typeof(string));//时间差
  1724. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  1725. dt.Columns.Add("PDState", typeof(string));//派单状态
  1726. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  1727. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  1728. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  1729. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  1730. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  1731. foreach (DataRow dr in dt.Rows)
  1732. {
  1733. //获取最新交办信息
  1734. string iszbdw = "0";
  1735. string ispd = "";
  1736. int state = Int32.Parse(dr["F_WorkState"].ToString());
  1737. if (state > 1)
  1738. {
  1739. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  1740. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  1741. if (dtjb.Rows.Count > 0)
  1742. {
  1743. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  1744. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  1745. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  1746. {
  1747. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  1748. }
  1749. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  1750. #region
  1751. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  1752. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  1753. //if (deptinfo != null)
  1754. //{
  1755. // if (did == userModel.F_DeptId) { iszbdw = "1"; }
  1756. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  1757. //}
  1758. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  1759. //{
  1760. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  1761. // string dns = string.Empty;
  1762. // foreach (string strid in strids)
  1763. // {
  1764. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  1765. // if (dinfo != null)
  1766. // {
  1767. // if (string.IsNullOrEmpty(dns))
  1768. // {
  1769. // dns = dinfo.F_DeptName;//交办单位
  1770. // }
  1771. // else
  1772. // {
  1773. // dns += "," + dinfo.F_DeptName;//交办单位
  1774. // }
  1775. // }
  1776. // }
  1777. // dr["OtherDeptName"] = dns;
  1778. //}
  1779. #endregion
  1780. #region
  1781. //if (state < 6 || state == 8)
  1782. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  1783. {
  1784. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  1785. dr["LimitTime"] = lt;
  1786. if (!string.IsNullOrWhiteSpace(lt))
  1787. {
  1788. var ltime = DateTime.Parse(lt);
  1789. TimeSpan ts = ltime.Subtract(DateTime.Now);
  1790. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  1791. if (tss < 0) { tss = -tss; }
  1792. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  1793. if (ltime > DateTime.Now)
  1794. {
  1795. if (configcs != null)
  1796. {
  1797. int cs = Int32.Parse(configcs.F_ParamValue);
  1798. if (ts.TotalHours > cs)
  1799. {
  1800. dr["OverState"] = 1;
  1801. }
  1802. else
  1803. {
  1804. dr["OverState"] = 2;
  1805. }
  1806. }
  1807. dr["GapTime"] = "剩余" + gshsj;
  1808. }
  1809. else
  1810. {
  1811. dr["OverState"] = 3;
  1812. dr["GapTime"] = "超时" + gshsj;
  1813. }
  1814. }
  1815. ispd = dtjb.Rows[0]["F_IsNext"].ToString();
  1816. dr["PDState"] = ispd;
  1817. }
  1818. if (state == (int)EnumWorkState.finish)
  1819. {
  1820. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  1821. var dttime = DateTime.Now;
  1822. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  1823. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  1824. dr["LimitTime"] = lt;
  1825. if (!string.IsNullOrWhiteSpace(lt))
  1826. {
  1827. var ltime = DateTime.Parse(lt);
  1828. TimeSpan ts = ltime.Subtract(dttime);
  1829. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  1830. if (tss < 0) { tss = -tss; }
  1831. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  1832. if (ltime < dttime)
  1833. {
  1834. dr["OverState"] = 3;
  1835. dr["GapTime"] = "超时" + gshsj;
  1836. }
  1837. }
  1838. }
  1839. #endregion
  1840. }
  1841. }
  1842. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  1843. {
  1844. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  1845. }
  1846. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  1847. {
  1848. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  1849. }
  1850. //string sqlpd = "SELECT TOP 1 * FROM T_Bus_AssignedInfo_Next WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 ORDER BY F_Id DESC";
  1851. //var dtpd = DbHelperSQL.Query(sqlpd).Tables[0];
  1852. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  1853. if (Int32.Parse(strtab) < 1)
  1854. {
  1855. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw, ispd);
  1856. #region 判断是否存在待督办
  1857. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  1858. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  1859. if (recount > 0 && butt != null)
  1860. btns.Remove(butt);
  1861. #endregion
  1862. }
  1863. else
  1864. {
  1865. if (Int32.Parse(strtab) == 9)
  1866. {//需履职界定
  1867. btns.Add(ButtonGroup.perform());
  1868. }
  1869. else if (Int32.Parse(strtab) == 10)
  1870. {//履职界定待审核
  1871. btns.Add(ButtonGroup.performaudit());
  1872. }
  1873. btns.Add(ButtonGroup.query());
  1874. }
  1875. dr["Buttons"] = btns;
  1876. }
  1877. #endregion
  1878. var obj = new
  1879. {
  1880. state = "success",
  1881. message = "成功",
  1882. rows = dt,
  1883. total = recordCount
  1884. };
  1885. return Content(obj.ToJson());
  1886. }
  1887. /// <summary>
  1888. /// 获取单位处理列表
  1889. /// </summary>
  1890. /// <returns></returns>
  1891. [Authority]
  1892. public ActionResult GetXBDWDealList(int isdc = 0)
  1893. {
  1894. DataTable dt = new DataTable();
  1895. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  1896. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  1897. string sql = " and F_IsDelete=0";
  1898. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  1899. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  1900. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  1901. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  1902. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  1903. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  1904. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  1905. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  1906. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  1907. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  1908. int source = RequestString.GetInt("source", 0);
  1909. int keyid = RequestString.GetInt("keyid", 0);
  1910. int type = RequestString.GetInt("type", 0);
  1911. int bigtype = RequestString.GetInt("bigtype", 0);
  1912. int smalltype = RequestString.GetInt("smalltype", 0);
  1913. int sourcearea = RequestString.GetInt("sourcearea", 0);
  1914. int deptid = RequestString.GetInt("deptid", 0);
  1915. string strpageindex = RequestString.GetQueryString("page");
  1916. int pageindex = 1;
  1917. string strpagesize = RequestString.GetQueryString("pagesize");
  1918. int pagesize = 10;
  1919. switch (strtab)
  1920. {
  1921. case "0"://待处理工单
  1922. int isyq = RequestString.GetInt("isyq", -1);
  1923. if (strstate.Trim() != "" && strstate != "undefined")
  1924. {
  1925. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  1926. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  1927. else
  1928. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1929. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  1930. }
  1931. else
  1932. {
  1933. int[] sts = new int[] { (int)EnumWorkState.receive, (int)EnumWorkState.dealing, (int)EnumWorkState.reload };
  1934. sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  1935. //sql += " and F_WorkState in (2,4,8)";
  1936. }
  1937. sql += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedItemInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1938. + " ISNULL(F_FeedbackTime, '')='' ";
  1939. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1940. {
  1941. sql += " and F_DeptId =" + userModel.F_DeptId;
  1942. }
  1943. if (isyq != -1)
  1944. {
  1945. sql += " and dbo.GetOverState(F_WorkOrderId)=" + isyq;
  1946. }
  1947. else
  1948. {
  1949. sql += ")";
  1950. }
  1951. break;
  1952. case "1"://已办理的工单
  1953. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type in (1,2) ";
  1954. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1955. {
  1956. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1957. }
  1958. else
  1959. {
  1960. sql += ")";
  1961. }
  1962. break;
  1963. }
  1964. if(deptid!=0)
  1965. {
  1966. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  1967. }
  1968. if (strworkid.Trim() != "" && strworkid != "undefined")
  1969. {
  1970. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  1971. }
  1972. if (strname.Trim() != "" && strname != "undefined")
  1973. {
  1974. sql += " and F_CusName like '%" + strname + "%' ";
  1975. }
  1976. if (strtel.Trim() != "" && strtel != "undefined")
  1977. {
  1978. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  1979. }
  1980. if (strkey.Trim() != "" && strkey != "undefined")
  1981. {
  1982. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  1983. }
  1984. #region 坐席&调度员
  1985. if (strusercode.Trim() != "" && strusercode != "undefined")
  1986. {//坐席
  1987. var usercode = strusercode.Trim().Split(',');
  1988. var newusercode = "";
  1989. foreach (var item in usercode)
  1990. {
  1991. if (!string.IsNullOrWhiteSpace(item.Trim()))
  1992. newusercode += "'" + item + "',";
  1993. }
  1994. newusercode = newusercode.Trim(',');
  1995. if (newusercode.Trim() != "" && newusercode != "undefined")
  1996. {
  1997. sql += " and F_CreateUser in (" + newusercode + ") ";
  1998. }
  1999. }
  2000. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  2001. {//调度员
  2002. var ddusercode = strddusercode.Trim().Split(',');
  2003. var newusercode = "";
  2004. foreach (var item in ddusercode)
  2005. {
  2006. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2007. newusercode += "'" + item + "',";
  2008. }
  2009. newusercode = newusercode.Trim(',');
  2010. if (newusercode.Trim() != "" && newusercode != "undefined")
  2011. {
  2012. sql += " and F_AssignUser in(" + newusercode + ") ";
  2013. }
  2014. }
  2015. //if (strusercode.Trim() != "" && strusercode != "undefined")
  2016. //{
  2017. // sql += " and F_CreateUser = '" + strusercode + "' ";
  2018. //}
  2019. #endregion
  2020. if (source != 0)
  2021. {
  2022. sql += " and F_InfoSource = '" + source + "' ";
  2023. }
  2024. if (keyid != 0)
  2025. {
  2026. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  2027. }
  2028. if (type != 0)
  2029. {
  2030. sql += " and F_InfoType = '" + type + "' ";
  2031. }
  2032. if (bigtype != 0)
  2033. {
  2034. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  2035. }
  2036. if (smalltype != 0)
  2037. {
  2038. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  2039. }
  2040. if (sourcearea != 0)
  2041. {
  2042. sql += " and F_SourceArea = '" + sourcearea + "' ";
  2043. }
  2044. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  2045. {
  2046. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  2047. }
  2048. if (strendtime.Trim() != "" && strendtime != "undefined")
  2049. {
  2050. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  2051. }
  2052. if (strpageindex.Trim() != "")
  2053. {
  2054. pageindex = Convert.ToInt32(strpageindex);
  2055. }
  2056. if (strpagesize.Trim() != "")
  2057. {
  2058. pagesize = Convert.ToInt32(strpagesize);
  2059. }
  2060. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  2061. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  2062. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  2063. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  2064. if (isdc > 0)
  2065. {
  2066. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  2067. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  2068. if (msg == "")
  2069. {
  2070. return Success("导出成功");
  2071. }
  2072. else
  2073. {
  2074. return Error("导出失败");
  2075. }
  2076. }
  2077. int recordCount = 0;
  2078. dt = BLL.PagerBLL.GetListPager(
  2079. "T_Bus_WorkOrder WITH(NOLOCK)",
  2080. "F_WorkOrderId",
  2081. cols,
  2082. sql,
  2083. "ORDER BY F_CreateTime DESC",
  2084. pagesize,
  2085. pageindex,
  2086. true,
  2087. out recordCount);
  2088. #region 声音文件
  2089. dt.Columns.Add("DeptName", typeof(string));//交办单位
  2090. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  2091. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  2092. dt.Columns.Add("OverState", typeof(string));//超时状态
  2093. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  2094. dt.Columns.Add("GapTime", typeof(string));//时间差
  2095. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  2096. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  2097. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  2098. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  2099. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  2100. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  2101. foreach (DataRow dr in dt.Rows)
  2102. {
  2103. //获取最新交办信息
  2104. string iszbdw = "0";
  2105. int state = Int32.Parse(dr["F_WorkState"].ToString());
  2106. if (state > 1)
  2107. {
  2108. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  2109. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  2110. if (dtjb.Rows.Count > 0)
  2111. {
  2112. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  2113. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  2114. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  2115. {
  2116. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  2117. }
  2118. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  2119. #region
  2120. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  2121. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  2122. //if (deptinfo != null)
  2123. //{
  2124. // if (did == userModel.F_DeptId) { iszbdw = "1"; }
  2125. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  2126. //}
  2127. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  2128. //{
  2129. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  2130. // string dns = string.Empty;
  2131. // foreach (string strid in strids)
  2132. // {
  2133. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  2134. // if (dinfo != null)
  2135. // {
  2136. // if (string.IsNullOrEmpty(dns))
  2137. // {
  2138. // dns = dinfo.F_DeptName;//交办单位
  2139. // }
  2140. // else
  2141. // {
  2142. // dns += "," + dinfo.F_DeptName;//交办单位
  2143. // }
  2144. // }
  2145. // }
  2146. // dr["OtherDeptName"] = dns;
  2147. //}
  2148. #endregion
  2149. #region
  2150. //if (state < 6 || state == 8)
  2151. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  2152. {
  2153. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  2154. dr["LimitTime"] = lt;
  2155. if (!string.IsNullOrWhiteSpace(lt))
  2156. {
  2157. var ltime = DateTime.Parse(lt);
  2158. TimeSpan ts = ltime.Subtract(DateTime.Now);
  2159. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2160. if (tss < 0) { tss = -tss; }
  2161. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2162. if (ltime > DateTime.Now)
  2163. {
  2164. if (configcs != null)
  2165. {
  2166. int cs = Int32.Parse(configcs.F_ParamValue);
  2167. if (ts.TotalHours > cs)
  2168. {
  2169. dr["OverState"] = 1;
  2170. }
  2171. else
  2172. {
  2173. dr["OverState"] = 2;
  2174. }
  2175. }
  2176. dr["GapTime"] = "剩余" + gshsj;
  2177. }
  2178. else
  2179. {
  2180. dr["OverState"] = 3;
  2181. dr["GapTime"] = "超时" + gshsj;
  2182. }
  2183. }
  2184. }
  2185. if (state == (int)EnumWorkState.finish)
  2186. {
  2187. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  2188. var dttime = DateTime.Now;
  2189. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  2190. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  2191. dr["LimitTime"] = lt;
  2192. if (!string.IsNullOrWhiteSpace(lt))
  2193. {
  2194. var ltime = DateTime.Parse(lt);
  2195. TimeSpan ts = ltime.Subtract(dttime);
  2196. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2197. if (tss < 0) { tss = -tss; }
  2198. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2199. if (ltime < dttime)
  2200. {
  2201. dr["OverState"] = 3;
  2202. dr["GapTime"] = "超时" + gshsj;
  2203. }
  2204. }
  2205. }
  2206. #endregion
  2207. }
  2208. }
  2209. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  2210. {
  2211. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  2212. }
  2213. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  2214. {
  2215. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  2216. }
  2217. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  2218. if (Int32.Parse(strtab) < 1)
  2219. {
  2220. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw);
  2221. #region 判断是否存在待督办
  2222. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  2223. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  2224. if (recount > 0 && butt != null)
  2225. btns.Remove(butt);
  2226. #endregion
  2227. }
  2228. else
  2229. {
  2230. btns.Add(ButtonGroup.query());
  2231. }
  2232. dr["Buttons"] = btns;
  2233. }
  2234. #endregion
  2235. var obj = new
  2236. {
  2237. state = "success",
  2238. message = "成功",
  2239. rows = dt,
  2240. total = recordCount
  2241. };
  2242. return Content(obj.ToJson());
  2243. }
  2244. /// <summary>
  2245. /// 获取单位主办协办未处理工单列表
  2246. /// </summary>
  2247. /// <returns></returns>
  2248. [Authority]
  2249. public ActionResult GetDWNoDealList(int isdc = 0)
  2250. {
  2251. DataTable dt = new DataTable();
  2252. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  2253. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  2254. string sql = " and F_IsDelete=0";
  2255. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  2256. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  2257. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  2258. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  2259. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  2260. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  2261. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  2262. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  2263. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  2264. int source = RequestString.GetInt("source", 0);
  2265. int keyid = RequestString.GetInt("keyid", 0);
  2266. int type = RequestString.GetInt("type", 0);
  2267. int bigtype = RequestString.GetInt("bigtype", 0);
  2268. int smalltype = RequestString.GetInt("smalltype", 0);
  2269. int sourcearea = RequestString.GetInt("sourcearea", 0);
  2270. int deptid = RequestString.GetInt("deptid", 0);
  2271. string strpageindex = RequestString.GetQueryString("page");
  2272. int pageindex = 1;
  2273. string strpagesize = RequestString.GetQueryString("pagesize");
  2274. int pagesize = 10;
  2275. if (userModel.F_RoleCode == "ZXHWY")
  2276. {
  2277. sql += " and F_CreateUser = '" + userModel.F_UserCode + "' ";
  2278. }
  2279. #region 坐席&调度员
  2280. if (strusercode.Trim() != "" && strusercode != "undefined")
  2281. {//坐席
  2282. var usercode = strusercode.Trim().Split(',');
  2283. var newusercode = "";
  2284. foreach (var item in usercode)
  2285. {
  2286. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2287. newusercode += "'" + item + "',";
  2288. }
  2289. newusercode = newusercode.Trim(',');
  2290. if (newusercode.Trim() != "" && newusercode != "undefined")
  2291. {
  2292. sql += " and F_CreateUser in (" + newusercode + ") ";
  2293. }
  2294. }
  2295. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  2296. {//调度员
  2297. var ddusercode = strddusercode.Trim().Split(',');
  2298. var newusercode = "";
  2299. foreach (var item in ddusercode)
  2300. {
  2301. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2302. newusercode += "'" + item + "',";
  2303. }
  2304. newusercode = newusercode.Trim(',');
  2305. if (newusercode.Trim() != "" && newusercode != "undefined")
  2306. {
  2307. sql += " and F_AssignUser in(" + newusercode + ") ";
  2308. }
  2309. }
  2310. //if (strusercode.Trim() != "" && strusercode != "undefined")
  2311. //{
  2312. // sql += " and F_CreateUser = '" + strusercode + "' ";
  2313. //}
  2314. #endregion
  2315. sql += " and ( F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and isnull(F_FeedbackTime,'')='' and F_IsSure in (0,1) ";
  2316. if (userModel.F_RoleCode == "WLDW")
  2317. {
  2318. sql += " and (F_MainDeptId = '" + userModel.F_DeptId + "' or F_MainDeptID3='" + userModel.F_DeptId + "')";
  2319. }
  2320. else if (deptid != 0)
  2321. {
  2322. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  2323. }
  2324. sql += ") or F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedItemInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and ISNULL(F_FeedbackTime, '')='' ";
  2325. if (userModel.F_RoleCode == "WLDW")
  2326. {
  2327. sql += " and (F_DeptId = '" + userModel.F_DeptId + "' or F_MainDeptID3='" + userModel.F_DeptId + "')";
  2328. }
  2329. else if (deptid != 0)
  2330. {
  2331. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  2332. }
  2333. sql += "))";
  2334. if (strstate.Trim() != "" && strstate != "undefined")
  2335. {
  2336. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  2337. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  2338. else
  2339. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  2340. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  2341. }
  2342. else
  2343. {
  2344. sql += " and F_WorkState in (2,4,8)";
  2345. }
  2346. if (strworkid.Trim() != "" && strworkid != "undefined")
  2347. {
  2348. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  2349. }
  2350. if (strname.Trim() != "" && strname != "undefined")
  2351. {
  2352. sql += " and F_CusName like '%" + strname + "%' ";
  2353. }
  2354. if (strtel.Trim() != "" && strtel != "undefined")
  2355. {
  2356. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  2357. }
  2358. if (strkey.Trim() != "" && strkey != "undefined")
  2359. {
  2360. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  2361. }
  2362. if (source != 0)
  2363. {
  2364. sql += " and F_InfoSource = '" + source + "' ";
  2365. }
  2366. if (keyid != 0)
  2367. {
  2368. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  2369. }
  2370. if (type != 0)
  2371. {
  2372. sql += " and F_InfoType = '" + type + "' ";
  2373. }
  2374. if (bigtype != 0)
  2375. {
  2376. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  2377. }
  2378. if (smalltype != 0)
  2379. {
  2380. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  2381. }
  2382. if (sourcearea != 0)
  2383. {
  2384. sql += " and F_SourceArea = '" + sourcearea + "' ";
  2385. }
  2386. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  2387. {
  2388. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  2389. }
  2390. if (strendtime.Trim() != "" && strendtime != "undefined")
  2391. {
  2392. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  2393. }
  2394. if (strpageindex.Trim() != "")
  2395. {
  2396. pageindex = Convert.ToInt32(strpageindex);
  2397. }
  2398. if (strpagesize.Trim() != "")
  2399. {
  2400. pagesize = Convert.ToInt32(strpagesize);
  2401. }
  2402. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName ";
  2403. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  2404. if (isdc > 0)
  2405. {
  2406. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  2407. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  2408. if (msg == "")
  2409. {
  2410. return Success("导出成功");
  2411. }
  2412. else
  2413. {
  2414. return Error("导出失败");
  2415. }
  2416. }
  2417. int recordCount = 0;
  2418. dt = BLL.PagerBLL.GetListPager(
  2419. "T_Bus_WorkOrder WITH(NOLOCK)",
  2420. "F_WorkOrderId",
  2421. cols,
  2422. sql,
  2423. "ORDER BY F_CreateTime DESC",
  2424. pagesize,
  2425. pageindex,
  2426. true,
  2427. out recordCount);
  2428. #region 声音文件
  2429. dt.Columns.Add("DeptName", typeof(string));//交办单位
  2430. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  2431. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  2432. dt.Columns.Add("OverState", typeof(string));//超时状态
  2433. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  2434. dt.Columns.Add("GapTime", typeof(string));//时间差
  2435. dt.Columns.Add("FilePath", typeof(string));
  2436. dt.Columns.Add("Buttons", typeof(object));
  2437. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  2438. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  2439. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  2440. foreach (DataRow dr in dt.Rows)
  2441. {
  2442. //获取最新交办信息
  2443. string iszbdw = "0";
  2444. int state = Int32.Parse(dr["F_WorkState"].ToString());
  2445. if (state > 1)
  2446. {
  2447. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  2448. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  2449. if (dtjb.Rows.Count > 0)
  2450. {
  2451. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  2452. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  2453. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  2454. {
  2455. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  2456. }
  2457. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  2458. #region
  2459. //if (state < 6 || state == 8)
  2460. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  2461. {
  2462. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  2463. dr["LimitTime"] = lt;
  2464. if (!string.IsNullOrWhiteSpace(lt))
  2465. {
  2466. var ltime = DateTime.Parse(lt);
  2467. TimeSpan ts = ltime.Subtract(DateTime.Now);
  2468. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2469. if (tss < 0) { tss = -tss; }
  2470. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2471. if (ltime > DateTime.Now)
  2472. {
  2473. if (configcs != null)
  2474. {
  2475. int cs = Int32.Parse(configcs.F_ParamValue);
  2476. if (ts.TotalHours > cs)
  2477. {
  2478. dr["OverState"] = 1;
  2479. }
  2480. else
  2481. {
  2482. dr["OverState"] = 2;
  2483. }
  2484. }
  2485. dr["GapTime"] = "剩余" + gshsj;
  2486. }
  2487. else
  2488. {
  2489. dr["OverState"] = 3;
  2490. dr["GapTime"] = "超时" + gshsj;
  2491. }
  2492. }
  2493. }
  2494. if (state == (int)EnumWorkState.finish)
  2495. {
  2496. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  2497. var dttime = DateTime.Now;
  2498. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  2499. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  2500. dr["LimitTime"] = lt;
  2501. if (!string.IsNullOrWhiteSpace(lt))
  2502. {
  2503. var ltime = DateTime.Parse(lt);
  2504. TimeSpan ts = ltime.Subtract(dttime);
  2505. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2506. if (tss < 0) { tss = -tss; }
  2507. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2508. if (ltime < dttime)
  2509. {
  2510. dr["OverState"] = 3;
  2511. dr["GapTime"] = "超时" + gshsj;
  2512. }
  2513. }
  2514. }
  2515. #endregion
  2516. }
  2517. }
  2518. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  2519. {
  2520. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  2521. }
  2522. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  2523. {
  2524. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  2525. }
  2526. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  2527. btns.Add(ButtonGroup.query());
  2528. dr["Buttons"] = btns;
  2529. }
  2530. #endregion
  2531. var obj = new
  2532. {
  2533. state = "success",
  2534. message = "成功",
  2535. rows = dt,
  2536. total = recordCount
  2537. };
  2538. return Content(obj.ToJson());
  2539. }
  2540. /// <summary>
  2541. /// 获取二级单位处理列表
  2542. /// </summary>
  2543. /// <returns></returns>
  2544. [Authority]
  2545. public ActionResult GetEJDWDealList(int isdc = 0)
  2546. {
  2547. DataTable dt = new DataTable();
  2548. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  2549. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  2550. string sql = " and F_IsDelete=0";
  2551. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  2552. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  2553. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  2554. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  2555. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  2556. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  2557. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  2558. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  2559. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  2560. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  2561. int source = RequestString.GetInt("source", 0);
  2562. int keyid = RequestString.GetInt("keyid", 0);
  2563. int type = RequestString.GetInt("type", 0);
  2564. int bigtype = RequestString.GetInt("bigtype", 0);
  2565. int smalltype = RequestString.GetInt("smalltype", 0);
  2566. int sourcearea = RequestString.GetInt("sourcearea", 0);
  2567. int deptid = RequestString.GetInt("deptid", 0);
  2568. string strpageindex = RequestString.GetQueryString("page");
  2569. int pageindex = 1;
  2570. string strpagesize = RequestString.GetQueryString("pagesize");
  2571. int pagesize = 10;
  2572. #region 模块
  2573. switch (strtab)
  2574. {
  2575. case "0"://待处理工单
  2576. int[] sts = new int[] { (int)EnumWorkState.dealing, (int)EnumWorkState.auditdelay };
  2577. sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  2578. //sql += " and F_WorkState in (4,5) ";
  2579. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  2580. {
  2581. sql += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  2582. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1))";
  2583. }
  2584. break;
  2585. case "1"://已办理的工单
  2586. if (strstate.Trim() != "" && strstate != "undefined")
  2587. {
  2588. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  2589. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  2590. else
  2591. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  2592. //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  2593. }
  2594. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type in (1,2) ";
  2595. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  2596. {
  2597. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  2598. }
  2599. else
  2600. {
  2601. sql += ")";
  2602. }
  2603. break;
  2604. }
  2605. #endregion
  2606. #region 条件
  2607. if (strworkid.Trim() != "" && strworkid != "undefined")
  2608. {
  2609. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  2610. }
  2611. if (strname.Trim() != "" && strname != "undefined")
  2612. {
  2613. sql += " and F_CusName like '%" + strname + "%' ";
  2614. }
  2615. if (strtel.Trim() != "" && strtel != "undefined")
  2616. {
  2617. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  2618. }
  2619. if (strkey.Trim() != "" && strkey != "undefined")
  2620. {
  2621. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  2622. }
  2623. #region 坐席&调度员
  2624. if (strusercode.Trim() != "" && strusercode != "undefined")
  2625. {//坐席
  2626. var usercode = strusercode.Trim().Split(',');
  2627. var newusercode = "";
  2628. foreach (var item in usercode)
  2629. {
  2630. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2631. newusercode += "'" + item + "',";
  2632. }
  2633. newusercode = newusercode.Trim(',');
  2634. if (newusercode.Trim() != "" && newusercode != "undefined")
  2635. {
  2636. sql += " and F_CreateUser in (" + newusercode + ") ";
  2637. }
  2638. }
  2639. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  2640. {//调度员
  2641. var ddusercode = strddusercode.Trim().Split(',');
  2642. var newusercode = "";
  2643. foreach (var item in ddusercode)
  2644. {
  2645. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2646. newusercode += "'" + item + "',";
  2647. }
  2648. newusercode = newusercode.Trim(',');
  2649. if (newusercode.Trim() != "" && newusercode != "undefined")
  2650. {
  2651. sql += " and F_AssignUser in(" + newusercode + ") ";
  2652. }
  2653. }
  2654. //if (strusercode.Trim() != "" && strusercode != "undefined")
  2655. //{
  2656. // sql += " and F_CreateUser = '" + strusercode + "' ";
  2657. //}
  2658. #endregion
  2659. if (source != 0)
  2660. {
  2661. sql += " and F_InfoSource = '" + source + "' ";
  2662. }
  2663. if (keyid != 0)
  2664. {
  2665. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  2666. }
  2667. if (type != 0)
  2668. {
  2669. sql += " and F_InfoType = '" + type + "' ";
  2670. }
  2671. if (bigtype != 0)
  2672. {
  2673. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  2674. }
  2675. if (smalltype != 0)
  2676. {
  2677. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  2678. }
  2679. if (sourcearea != 0)
  2680. {
  2681. sql += " and F_SourceArea = '" + sourcearea + "' ";
  2682. }
  2683. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  2684. {
  2685. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  2686. }
  2687. if (strendtime.Trim() != "" && strendtime != "undefined")
  2688. {
  2689. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  2690. }
  2691. if (deptid != 0)
  2692. {
  2693. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='"+deptid+"')";
  2694. }
  2695. if (strpageindex.Trim() != "")
  2696. {
  2697. pageindex = Convert.ToInt32(strpageindex);
  2698. }
  2699. if (strpagesize.Trim() != "")
  2700. {
  2701. pagesize = Convert.ToInt32(strpagesize);
  2702. }
  2703. #endregion
  2704. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  2705. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  2706. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  2707. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  2708. if (isdc > 0)
  2709. {
  2710. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  2711. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  2712. if (msg == "")
  2713. {
  2714. return Success("导出成功");
  2715. }
  2716. else
  2717. {
  2718. return Error("导出失败");
  2719. }
  2720. }
  2721. int recordCount = 0;
  2722. dt = BLL.PagerBLL.GetListPager(
  2723. "T_Bus_WorkOrder WITH(NOLOCK)",
  2724. "F_WorkOrderId",
  2725. cols,
  2726. sql,
  2727. "ORDER BY F_CreateTime DESC",
  2728. pagesize,
  2729. pageindex,
  2730. true,
  2731. out recordCount);
  2732. #region 声音文件
  2733. dt.Columns.Add("DeptName", typeof(string));//交办单位
  2734. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  2735. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  2736. dt.Columns.Add("OverState", typeof(string));//超时状态
  2737. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  2738. dt.Columns.Add("GapTime", typeof(string));//时间差
  2739. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  2740. dt.Columns.Add("PDState", typeof(string));//派单状态
  2741. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  2742. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  2743. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  2744. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  2745. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  2746. foreach (DataRow dr in dt.Rows)
  2747. {
  2748. //获取最新交办信息
  2749. string iszbdw = "0";
  2750. string ispd = "";
  2751. int state = Int32.Parse(dr["F_WorkState"].ToString());
  2752. if (state > 1)
  2753. {
  2754. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  2755. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  2756. if (dtjb.Rows.Count > 0)
  2757. {
  2758. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  2759. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  2760. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  2761. {
  2762. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  2763. }
  2764. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  2765. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  2766. dr["LimitTime"] = lt;
  2767. #region
  2768. //if (state < 6 || state == 8)
  2769. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  2770. {
  2771. if (!string.IsNullOrWhiteSpace(lt))
  2772. {
  2773. var ltime = DateTime.Parse(lt);
  2774. TimeSpan ts = ltime.Subtract(DateTime.Now);
  2775. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2776. if (tss < 0) { tss = -tss; }
  2777. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2778. if (ltime > DateTime.Now)
  2779. {
  2780. if (configcs != null)
  2781. {
  2782. int cs = Int32.Parse(configcs.F_ParamValue);
  2783. if (ts.TotalHours > cs)
  2784. {
  2785. dr["OverState"] = 1;
  2786. }
  2787. else
  2788. {
  2789. dr["OverState"] = 2;
  2790. }
  2791. }
  2792. dr["GapTime"] = "剩余" + gshsj;
  2793. }
  2794. else
  2795. {
  2796. dr["OverState"] = 3;
  2797. dr["GapTime"] = "超时" + gshsj;
  2798. }
  2799. }
  2800. }
  2801. if (state == (int)EnumWorkState.finish)
  2802. {
  2803. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  2804. var dttime = DateTime.Now;
  2805. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  2806. if (!string.IsNullOrWhiteSpace(lt))
  2807. {
  2808. var ltime = DateTime.Parse(lt);
  2809. TimeSpan ts = ltime.Subtract(dttime);
  2810. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  2811. if (tss < 0) { tss = -tss; }
  2812. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  2813. if (ltime < dttime)
  2814. {
  2815. dr["OverState"] = 3;
  2816. dr["GapTime"] = "超时" + gshsj;
  2817. }
  2818. }
  2819. }
  2820. #endregion
  2821. ispd = dtjb.Rows[0]["F_IsNext"].ToString();
  2822. dr["PDState"] = ispd;
  2823. }
  2824. }
  2825. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  2826. {
  2827. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  2828. }
  2829. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  2830. {
  2831. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  2832. }
  2833. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  2834. if (Int32.Parse(strtab) < 1)
  2835. {
  2836. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw, ispd);
  2837. #region 判断是否存在待督办
  2838. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  2839. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  2840. if (recount > 0 && butt != null)
  2841. btns.Remove(butt);
  2842. #endregion
  2843. }
  2844. else
  2845. {
  2846. btns.Add(ButtonGroup.query());
  2847. }
  2848. dr["Buttons"] = btns;
  2849. }
  2850. #endregion
  2851. var obj = new
  2852. {
  2853. state = "success",
  2854. message = "成功",
  2855. rows = dt,
  2856. total = recordCount
  2857. };
  2858. return Content(obj.ToJson());
  2859. }
  2860. /// <summary>
  2861. /// 获取三级单位处理列表
  2862. /// </summary>
  2863. /// <returns></returns>
  2864. [Authority]
  2865. public ActionResult GetSJDWDealList(int isdc = 0)
  2866. {
  2867. DataTable dt = new DataTable();
  2868. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  2869. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  2870. string sql = " and F_IsDelete=0";
  2871. string strtab = HttpUtility.UrlDecode(RequestString.GetQueryString("tab"));
  2872. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  2873. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  2874. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  2875. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  2876. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  2877. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  2878. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  2879. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  2880. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  2881. int source = RequestString.GetInt("source", 0);
  2882. int keyid = RequestString.GetInt("keyid", 0);
  2883. int type = RequestString.GetInt("type", 0);
  2884. int bigtype = RequestString.GetInt("bigtype", 0);
  2885. int smalltype = RequestString.GetInt("smalltype", 0);
  2886. int sourcearea = RequestString.GetInt("sourcearea", 0);
  2887. int deptid = RequestString.GetInt("deptid", 0);
  2888. string strpageindex = RequestString.GetQueryString("page");
  2889. int pageindex = 1;
  2890. string strpagesize = RequestString.GetQueryString("pagesize");
  2891. int pagesize = 10;
  2892. #region 模块
  2893. switch (strtab)
  2894. {
  2895. case "0"://待处理工单
  2896. int[] sts = new int[] { (int)EnumWorkState.dealing, (int)EnumWorkState.auditdelay };
  2897. sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  2898. if (userModel.F_RoleCode == "EJWLDW")
  2899. {
  2900. sql += " and F_MainDeptID3 ='" + userModel.F_DeptId + "' ";
  2901. }
  2902. else if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  2903. {
  2904. sql += " and ((F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  2905. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptID='"+ userModel.F_DeptId + "' and F_IsSure in (0,1)))";
  2906. if(userModel.F_RoleCode== "WLDW")
  2907. {
  2908. sql += " or (F_MainDeptID3 ='" + userModel.F_DeptId + "')"
  2909. + " or (F_MainDeptID3 in (SELECT F_DeptId FROM T_Sys_Department WITH(NOLOCK) WHERE F_State=0 AND F_PartentId=" + userModel.F_DeptId + "))";
  2910. }
  2911. sql += ")";
  2912. }
  2913. break;
  2914. case "1"://已办理的工单
  2915. if (strstate.Trim() != "" && strstate != "undefined")
  2916. {
  2917. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString())
  2918. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  2919. else
  2920. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  2921. }
  2922. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type in (1,2) ";
  2923. if (userModel.F_RoleCode == "EJWLDW")
  2924. {
  2925. sql += " and F_MainDeptID3 ='" + userModel.F_DeptId + "' ";
  2926. }
  2927. else if (userModel.F_RoleCode == "WLDW")
  2928. {
  2929. sql += " and( (F_MainDeptID3 ='" + userModel.F_DeptId + "')"
  2930. + " or (F_MainDeptID3 in (SELECT F_DeptId FROM T_Sys_Department WITH(NOLOCK) WHERE F_State=0 AND F_PartentId=" + userModel.F_DeptId + ")) )";
  2931. }
  2932. else if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  2933. {
  2934. sql += " and F_CreateUser='" + userModel.F_UserCode + "')";
  2935. }
  2936. else
  2937. {
  2938. sql += ")";
  2939. }
  2940. break;
  2941. }
  2942. #endregion
  2943. #region 条件
  2944. if (strworkid.Trim() != "" && strworkid != "undefined")
  2945. {
  2946. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  2947. }
  2948. if (strname.Trim() != "" && strname != "undefined")
  2949. {
  2950. sql += " and F_CusName like '%" + strname + "%' ";
  2951. }
  2952. if (strtel.Trim() != "" && strtel != "undefined")
  2953. {
  2954. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  2955. }
  2956. if (strkey.Trim() != "" && strkey != "undefined")
  2957. {
  2958. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  2959. }
  2960. #region 坐席&调度员
  2961. if (strusercode.Trim() != "" && strusercode != "undefined")
  2962. {//坐席
  2963. var usercode = strusercode.Trim().Split(',');
  2964. var newusercode = "";
  2965. foreach (var item in usercode)
  2966. {
  2967. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2968. newusercode += "'" + item + "',";
  2969. }
  2970. newusercode = newusercode.Trim(',');
  2971. if (newusercode.Trim() != "" && newusercode != "undefined")
  2972. {
  2973. sql += " and F_CreateUser in (" + newusercode + ") ";
  2974. }
  2975. }
  2976. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  2977. {//调度员
  2978. var ddusercode = strddusercode.Trim().Split(',');
  2979. var newusercode = "";
  2980. foreach (var item in ddusercode)
  2981. {
  2982. if (!string.IsNullOrWhiteSpace(item.Trim()))
  2983. newusercode += "'" + item + "',";
  2984. }
  2985. newusercode = newusercode.Trim(',');
  2986. if (newusercode.Trim() != "" && newusercode != "undefined")
  2987. {
  2988. sql += " and F_AssignUser in(" + newusercode + ") ";
  2989. }
  2990. }
  2991. #endregion
  2992. if (source != 0)
  2993. {
  2994. sql += " and F_InfoSource = '" + source + "' ";
  2995. }
  2996. if (keyid != 0)
  2997. {
  2998. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  2999. }
  3000. if (type != 0)
  3001. {
  3002. sql += " and F_InfoType = '" + type + "' ";
  3003. }
  3004. if (bigtype != 0)
  3005. {
  3006. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  3007. }
  3008. if (smalltype != 0)
  3009. {
  3010. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  3011. }
  3012. if (sourcearea != 0)
  3013. {
  3014. sql += " and F_SourceArea = '" + sourcearea + "' ";
  3015. }
  3016. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  3017. {
  3018. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  3019. }
  3020. if (strendtime.Trim() != "" && strendtime != "undefined")
  3021. {
  3022. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  3023. }
  3024. if (deptid != 0)
  3025. {
  3026. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  3027. }
  3028. if (strpageindex.Trim() != "")
  3029. {
  3030. pageindex = Convert.ToInt32(strpageindex);
  3031. }
  3032. if (strpagesize.Trim() != "")
  3033. {
  3034. pagesize = Convert.ToInt32(strpagesize);
  3035. }
  3036. #endregion
  3037. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  3038. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  3039. if (isdc > 0)
  3040. {
  3041. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  3042. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  3043. if (msg == "")
  3044. {
  3045. return Success("导出成功");
  3046. }
  3047. else
  3048. {
  3049. return Error("导出失败");
  3050. }
  3051. }
  3052. int recordCount = 0;
  3053. dt = BLL.PagerBLL.GetListPager(
  3054. "T_Bus_WorkOrder WITH(NOLOCK)",
  3055. "F_WorkOrderId",
  3056. cols,
  3057. sql,
  3058. "ORDER BY F_CreateTime DESC",
  3059. pagesize,
  3060. pageindex,
  3061. true,
  3062. out recordCount);
  3063. #region 声音文件
  3064. dt.Columns.Add("DeptName", typeof(string));//交办单位
  3065. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  3066. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  3067. dt.Columns.Add("OverState", typeof(string));//超时状态
  3068. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  3069. dt.Columns.Add("GapTime", typeof(string));//时间差
  3070. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  3071. dt.Columns.Add("PDState", typeof(string));//派单状态
  3072. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  3073. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  3074. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  3075. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  3076. var reminds = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  3077. foreach (DataRow dr in dt.Rows)
  3078. {
  3079. //获取最新交办信息
  3080. string iszbdw = "0";
  3081. string ispd = "";
  3082. int state = Int32.Parse(dr["F_WorkState"].ToString());
  3083. if (state > 1)
  3084. {
  3085. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  3086. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  3087. if (dtjb.Rows.Count > 0)
  3088. {
  3089. if (dtjb.Rows[0]["F_MainDeptId"].ToString()==userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  3090. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  3091. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  3092. {
  3093. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  3094. }
  3095. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  3096. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  3097. dr["LimitTime"] = lt;
  3098. #region
  3099. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  3100. {
  3101. if (!string.IsNullOrWhiteSpace(lt))
  3102. {
  3103. var ltime = DateTime.Parse(lt);
  3104. TimeSpan ts = ltime.Subtract(DateTime.Now);
  3105. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3106. if (tss < 0) { tss = -tss; }
  3107. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3108. if (ltime > DateTime.Now)
  3109. {
  3110. if (configcs != null)
  3111. {
  3112. int cs = Int32.Parse(configcs.F_ParamValue);
  3113. if (ts.TotalHours > cs)
  3114. {
  3115. dr["OverState"] = 1;
  3116. }
  3117. else
  3118. {
  3119. dr["OverState"] = 2;
  3120. }
  3121. }
  3122. dr["GapTime"] = "剩余" + gshsj;
  3123. }
  3124. else
  3125. {
  3126. dr["OverState"] = 3;
  3127. dr["GapTime"] = "超时" + gshsj;
  3128. }
  3129. }
  3130. }
  3131. if (state == (int)EnumWorkState.finish)
  3132. {
  3133. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  3134. var dttime = DateTime.Now;
  3135. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  3136. if (!string.IsNullOrWhiteSpace(lt))
  3137. {
  3138. var ltime = DateTime.Parse(lt);
  3139. TimeSpan ts = ltime.Subtract(dttime);
  3140. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3141. if (tss < 0) { tss = -tss; }
  3142. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3143. if (ltime < dttime)
  3144. {
  3145. dr["OverState"] = 3;
  3146. dr["GapTime"] = "超时" + gshsj;
  3147. }
  3148. }
  3149. }
  3150. #endregion
  3151. ispd = dtjb.Rows[0]["F_IsNext"].ToString();
  3152. dr["PDState"] = ispd;
  3153. }
  3154. }
  3155. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  3156. {
  3157. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  3158. }
  3159. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  3160. {
  3161. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  3162. }
  3163. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  3164. if (Int32.Parse(strtab) < 1)
  3165. {
  3166. btns = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw, ispd);
  3167. #region 判断是否存在待督办
  3168. var recount = reminds.Where(r => r.F_WorkOrderId == dr["F_WorkOrderId"].ToString()).Count();
  3169. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  3170. if (recount > 0 && butt != null)
  3171. btns.Remove(butt);
  3172. #endregion
  3173. }
  3174. else
  3175. {
  3176. btns.Add(ButtonGroup.query());
  3177. }
  3178. dr["Buttons"] = btns;
  3179. }
  3180. #endregion
  3181. var obj = new
  3182. {
  3183. state = "success",
  3184. message = "成功",
  3185. rows = dt,
  3186. total = recordCount
  3187. };
  3188. return Content(obj.ToJson());
  3189. }
  3190. /// <summary>
  3191. /// 获取自己提交工单
  3192. /// </summary>
  3193. /// <param name="isdc"></param>
  3194. /// <returns></returns>
  3195. [Authority]
  3196. public ActionResult GetSelfList(int isdc = 0)
  3197. {
  3198. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  3199. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  3200. DataTable dt = new DataTable();
  3201. string sql = " and F_IsDelete=0 ";
  3202. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  3203. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  3204. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  3205. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  3206. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  3207. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  3208. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  3209. int source = RequestString.GetInt("source", 0);
  3210. int keyid = RequestString.GetInt("keyid", 0);
  3211. int type = RequestString.GetInt("type", 0);
  3212. int bigtype = RequestString.GetInt("bigtype", 0);
  3213. int smalltype = RequestString.GetInt("smalltype", 0);
  3214. int sourcearea = RequestString.GetInt("sourcearea", 0);
  3215. int deptid = RequestString.GetInt("deptid", 0);
  3216. int dealtype = RequestString.GetInt("dealtype", -1);
  3217. int issend = RequestString.GetInt("issend", -1);
  3218. int deptlevel = RequestString.GetInt("deptlevel", 0);
  3219. string strpageindex = RequestString.GetQueryString("page");
  3220. int pageindex = 1;
  3221. string strpagesize = RequestString.GetQueryString("pagesize");
  3222. int pagesize = 10;
  3223. #region sql 语句相关处理
  3224. if(userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  3225. sql += " and F_CreateUser ='" + userModel.F_UserCode + "' ";
  3226. if (strstate.Trim() != "" && strstate != "undefined")
  3227. {
  3228. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString())
  3229. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  3230. else
  3231. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  3232. }
  3233. if (strworkid.Trim() != "" && strworkid != "undefined")
  3234. {
  3235. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  3236. }
  3237. if (strname.Trim() != "" && strname != "undefined")
  3238. {
  3239. sql += " and F_CusName like '%" + strname + "%' ";
  3240. }
  3241. if (strtel.Trim() != "" && strtel != "undefined")
  3242. {
  3243. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  3244. }
  3245. if (strkey.Trim() != "" && strkey != "undefined")
  3246. {
  3247. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  3248. }
  3249. if (source != 0)
  3250. {
  3251. sql += " and F_InfoSource = '" + source + "' ";
  3252. }
  3253. if (keyid != 0)
  3254. {
  3255. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  3256. }
  3257. if (type != 0)
  3258. {
  3259. sql += " and F_InfoType = '" + type + "' ";
  3260. }
  3261. if (bigtype != 0)
  3262. {
  3263. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  3264. }
  3265. if (smalltype != 0)
  3266. {
  3267. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  3268. }
  3269. if (sourcearea != 0)
  3270. {
  3271. sql += " and F_SourceArea = '" + sourcearea + "' ";
  3272. }
  3273. if (deptid != 0)
  3274. {
  3275. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  3276. }
  3277. if (dealtype != -1)
  3278. {
  3279. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  3280. }
  3281. if (issend != -1)
  3282. {
  3283. sql += " and isnull(F_IsRelease,0) = '" + issend + "' ";
  3284. }
  3285. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  3286. {
  3287. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  3288. }
  3289. if (strendtime.Trim() != "" && strendtime != "undefined")
  3290. {
  3291. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  3292. }
  3293. #endregion
  3294. if (strpageindex.Trim() != "")
  3295. {
  3296. pageindex = Convert.ToInt32(strpageindex);
  3297. }
  3298. if (strpagesize.Trim() != "")
  3299. {
  3300. pagesize = Convert.ToInt32(strpagesize);
  3301. }
  3302. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  3303. #region 导出
  3304. if (isdc > 0)
  3305. {
  3306. var top = " "; var orderby = " order by F_CreateTime";
  3307. if (sql == " and F_IsDelete=0 ")
  3308. {
  3309. top = " top 1000 "; orderby += " desc ";
  3310. }
  3311. //20190715调整导出字段 zhengbingbing
  3312. //日期,工单号,诉求标题,诉求内容,承办单位,办理结果,是否满意,备注
  3313. var dtdc = DbHelperSQL.Query(" select " + top + " F_CreateTime 日期, F_WorkOrderId 工单号,F_ComTitle 诉求标题,F_ComContent 诉求内容,dbo.GetDictionaryName(F_Key) 主题词, "
  3314. + " dbo.GetDeptNames(convert(nvarchar,(select top 1 F_MainDeptId from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId=wo.F_WorkOrderId and F_IsDelete=0 and F_State=1 and F_IsSure<>3 order by F_Id desc))) 主办单位, "
  3315. + " dbo.GetDeptNames(convert(nvarchar,(select top 1 F_OtherDeptIds from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId=wo.F_WorkOrderId and F_IsDelete=0 and F_State=1 and F_IsSure<>3 order by F_Id desc))) 协办单位, "
  3316. + " (select top 1 F_Result from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId =wo.F_WorkOrderId order by F_Id desc) 办理结果, "
  3317. + " (select top 1 (case F_IsSatisfie when 1 then'满意' when 0 then '不满意' else '未评价' end) F_Satisfie from T_Bus_VisitResult WITH(NOLOCK) where F_State = 1 and F_IsDelete = 0 and F_WorkOrderId = wo.F_WorkOrderId order by F_Id desc) 是否满意 "
  3318. + " from T_Bus_WorkOrder wo WITH(NOLOCK) where 1=1 " + sql + orderby).Tables[0];
  3319. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  3320. if (msg == "")
  3321. {
  3322. return Success("导出成功");
  3323. }
  3324. else
  3325. {
  3326. return Error("导出失败");
  3327. }
  3328. }
  3329. #endregion
  3330. int recordCount = 0;
  3331. dt = BLL.PagerBLL.GetListPager(
  3332. "T_Bus_WorkOrder WITH(NOLOCK)",
  3333. "F_WorkOrderId",
  3334. cols,
  3335. sql,
  3336. "ORDER BY F_CreateTime DESC",
  3337. pagesize,
  3338. pageindex,
  3339. true,
  3340. out recordCount);
  3341. #region 声音文件和交办超时
  3342. dt.Columns.Add("DeptName", typeof(string));//交办单位
  3343. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  3344. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  3345. dt.Columns.Add("OverState", typeof(string));//超时状态
  3346. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  3347. dt.Columns.Add("GapTime", typeof(string));//时间差
  3348. dt.Columns.Add("PDState", typeof(string));//派单状态
  3349. dt.Columns.Add("FilePath", typeof(string));//语音文件路径
  3350. dt.Columns.Add("Buttons", typeof(object));//操作按钮
  3351. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  3352. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  3353. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  3354. var reminds = remindBLL.GetModelList(" F_State=0 and F_IsDelete=0 and F_Type =1").ToList();
  3355. foreach (DataRow dr in dt.Rows)
  3356. {
  3357. string iszbdw = "0";
  3358. string ispd = "";
  3359. int state = Int32.Parse(dr["F_WorkState"].ToString());
  3360. if (state > 1)
  3361. {
  3362. //获取最新交办信息
  3363. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  3364. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  3365. if (dtjb.Rows.Count > 0)
  3366. {
  3367. if (dr["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  3368. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dr["F_MainDeptId"].ToString() + "')");
  3369. if (dr["F_OtherDeptIds"] != null && dr["F_OtherDeptIds"].ToString() != "")
  3370. {
  3371. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dr["F_OtherDeptIds"].ToString() + "')");
  3372. }
  3373. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  3374. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  3375. dr["LimitTime"] = lt;
  3376. #region 超时时限
  3377. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  3378. {
  3379. if (!string.IsNullOrWhiteSpace(lt))
  3380. {
  3381. var ltime = DateTime.Parse(lt);
  3382. TimeSpan ts = ltime.Subtract(DateTime.Now);
  3383. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3384. if (tss < 0) { tss = -tss; }
  3385. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3386. if (ltime > DateTime.Now)
  3387. {
  3388. if (configcs != null)
  3389. {
  3390. int cs = Int32.Parse(configcs.F_ParamValue);
  3391. if (ts.TotalHours > cs)
  3392. {
  3393. dr["OverState"] = 1;
  3394. }
  3395. else
  3396. {
  3397. dr["OverState"] = 2;
  3398. }
  3399. }
  3400. dr["GapTime"] = "剩余" + gshsj;
  3401. }
  3402. else
  3403. {
  3404. dr["OverState"] = 3;
  3405. dr["GapTime"] = "超时" + gshsj;
  3406. }
  3407. }
  3408. ispd = dtjb.Rows[0]["F_IsNext"] != null ? dtjb.Rows[0]["F_IsNext"].ToString() : "";
  3409. dr["PDState"] = ispd;
  3410. }
  3411. if (state == (int)EnumWorkState.finish)
  3412. {
  3413. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  3414. var dttime = DateTime.Now;
  3415. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  3416. if (!string.IsNullOrWhiteSpace(lt))
  3417. {
  3418. var ltime = DateTime.Parse(lt);
  3419. TimeSpan ts = ltime.Subtract(dttime);
  3420. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3421. if (tss < 0) { tss = -tss; }
  3422. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3423. if (ltime < dttime)
  3424. {
  3425. dr["OverState"] = 3;
  3426. dr["GapTime"] = "超时" + gshsj;
  3427. }
  3428. }
  3429. }
  3430. #endregion
  3431. }
  3432. }
  3433. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  3434. {
  3435. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  3436. }
  3437. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  3438. {
  3439. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  3440. }
  3441. var buttons = ButtonGroup.GetButtons(dr["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dr["F_IsResult"].ToString(), iszbdw, ispd);
  3442. #region 判断是否存在待督办
  3443. var recount = reminds.Where(r => r.F_WorkOrderId.Equals(dr["F_WorkOrderId"].ToString())).Count();
  3444. var butt = buttons.Find(c => c.key == ButtonGroup.turnsee().key);
  3445. if (recount > 0 && butt != null)
  3446. buttons.Remove(butt);
  3447. #endregion
  3448. dr["Buttons"] = buttons;
  3449. }
  3450. #endregion
  3451. var obj = new
  3452. {
  3453. state = "success",
  3454. message = "成功",
  3455. rows = dt,
  3456. total = recordCount
  3457. };
  3458. return Content(obj.ToJson());
  3459. }
  3460. /// <summary>
  3461. /// 获取逾期未回复工单列表
  3462. /// </summary>
  3463. /// <returns></returns>
  3464. [Authority]
  3465. public ActionResult GetTimeOutList(int isdc = 0)
  3466. {
  3467. DataTable dt = new DataTable();
  3468. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  3469. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  3470. string sql = " and F_IsDelete=0";
  3471. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  3472. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  3473. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  3474. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  3475. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  3476. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  3477. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  3478. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  3479. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  3480. int source = RequestString.GetInt("source", 0);
  3481. int keyid = RequestString.GetInt("keyid", 0);
  3482. int type = RequestString.GetInt("type", 0);
  3483. int bigtype = RequestString.GetInt("bigtype", 0);
  3484. int smalltype = RequestString.GetInt("smalltype", 0);
  3485. int sourcearea = RequestString.GetInt("sourcearea", 0);
  3486. int deptid = RequestString.GetInt("deptid", 0);
  3487. string strpageindex = RequestString.GetQueryString("page");
  3488. int pageindex = 1;
  3489. string strpagesize = RequestString.GetQueryString("pagesize");
  3490. int pagesize = 10;
  3491. if (userModel.F_RoleCode == "ZXHWY")
  3492. {
  3493. sql += " and F_CreateUser = '" + userModel.F_UserCode + "' ";
  3494. }
  3495. else
  3496. {
  3497. #region 坐席&调度员
  3498. if (strusercode.Trim() != "" && strusercode != "undefined")
  3499. {//坐席
  3500. var usercode = strusercode.Trim().Split(',');
  3501. var newusercode = "";
  3502. foreach (var item in usercode)
  3503. {
  3504. if (!string.IsNullOrWhiteSpace(item.Trim()))
  3505. newusercode += "'" + item + "',";
  3506. }
  3507. newusercode = newusercode.Trim(',');
  3508. if (newusercode.Trim() != "" && newusercode != "undefined")
  3509. {
  3510. sql += " and F_CreateUser in (" + newusercode + ") ";
  3511. }
  3512. }
  3513. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  3514. {//调度员
  3515. var ddusercode = strddusercode.Trim().Split(',');
  3516. var newusercode = "";
  3517. foreach (var item in ddusercode)
  3518. {
  3519. if (!string.IsNullOrWhiteSpace(item.Trim()))
  3520. newusercode += "'" + item + "',";
  3521. }
  3522. newusercode = newusercode.Trim(',');
  3523. if (newusercode.Trim() != "" && newusercode != "undefined")
  3524. {
  3525. sql += " and F_AssignUser in(" + newusercode + ") ";
  3526. }
  3527. }
  3528. //if (strusercode.Trim() != "" && strusercode != "undefined")
  3529. //{
  3530. // sql += " and F_CreateUser = '" + strusercode + "' ";
  3531. //}
  3532. #endregion
  3533. }
  3534. string sqlwhere = "";string sqlwhere1 = "";
  3535. sqlwhere += " and ( F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_LimitTime<getdate() and isnull(F_FeedbackTime,'')='' and F_IsSure in (0,1) ";
  3536. if (userModel.F_RoleCode == "WLDW")
  3537. {
  3538. sqlwhere += " and F_MainDeptId = '" + userModel.F_DeptId + "') or F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedItemInfo WITH(NOLOCK) "
  3539. + " where F_State=1 and F_IsDelete=0 and F_LimitTime<getdate() and ISNULL(F_FeedbackTime, '')='' and F_DeptId = '" + userModel.F_DeptId + "' ";
  3540. sqlwhere1 += " and F_MainDeptId = '" + userModel.F_DeptId + "'";
  3541. }
  3542. else if (deptid != 0)
  3543. {
  3544. sqlwhere += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  3545. sqlwhere1 += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  3546. }
  3547. if (userModel.F_RoleCode == "ZXLD")
  3548. {
  3549. sqlwhere += " and F_CreateUser = '" + userModel.F_UserCode + "' ";
  3550. sqlwhere1 += " and F_CreateUser = '" + userModel.F_UserCode + "'";
  3551. }
  3552. sqlwhere += "))";
  3553. if (strstate.Trim() != "" && strstate != "undefined")
  3554. {
  3555. if (strstate.Trim() == ((int)EnumWorkState.neworder).ToString() )
  3556. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.audit + ") ";
  3557. else
  3558. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  3559. if (strstate.Trim() == ((int)EnumWorkState.finish).ToString())
  3560. sql += " and F_LimitTime<F_DealTime " + sqlwhere1;
  3561. else
  3562. sql += sqlwhere;
  3563. }
  3564. else
  3565. {
  3566. int[] sts = new int[] { (int)EnumWorkState.receive, (int)EnumWorkState.dealing, (int)EnumWorkState.reload };
  3567. sql += " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  3568. sql += sqlwhere;
  3569. //sql += " and F_WorkState in (2,4,8)";
  3570. }
  3571. if (strworkid.Trim() != "" && strworkid != "undefined")
  3572. {
  3573. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  3574. }
  3575. if (strname.Trim() != "" && strname != "undefined")
  3576. {
  3577. sql += " and F_CusName like '%" + strname + "%' ";
  3578. }
  3579. if (strtel.Trim() != "" && strtel != "undefined")
  3580. {
  3581. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  3582. }
  3583. if (strkey.Trim() != "" && strkey != "undefined")
  3584. {
  3585. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  3586. }
  3587. if (source != 0)
  3588. {
  3589. sql += " and F_InfoSource = '" + source + "' ";
  3590. }
  3591. if (keyid != 0)
  3592. {
  3593. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  3594. }
  3595. if (type != 0)
  3596. {
  3597. sql += " and F_InfoType = '" + type + "' ";
  3598. }
  3599. if (bigtype != 0)
  3600. {
  3601. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  3602. }
  3603. if (smalltype != 0)
  3604. {
  3605. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  3606. }
  3607. if (sourcearea != 0)
  3608. {
  3609. sql += " and F_SourceArea = '" + sourcearea + "' ";
  3610. }
  3611. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  3612. {
  3613. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  3614. }
  3615. if (strendtime.Trim() != "" && strendtime != "undefined")
  3616. {
  3617. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  3618. }
  3619. if (strpageindex.Trim() != "")
  3620. {
  3621. pageindex = Convert.ToInt32(strpageindex);
  3622. }
  3623. if (strpagesize.Trim() != "")
  3624. {
  3625. pagesize = Convert.ToInt32(strpagesize);
  3626. }
  3627. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName ";
  3628. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  3629. if (isdc > 0)
  3630. {
  3631. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  3632. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  3633. if (msg == "")
  3634. {
  3635. return Success("导出成功");
  3636. }
  3637. else
  3638. {
  3639. return Error("导出失败");
  3640. }
  3641. }
  3642. int recordCount = 0;
  3643. dt = BLL.PagerBLL.GetListPager(
  3644. "T_Bus_WorkOrder WITH(NOLOCK)",
  3645. "F_WorkOrderId",
  3646. cols,
  3647. sql,
  3648. "ORDER BY F_CreateTime DESC",
  3649. pagesize,
  3650. pageindex,
  3651. true,
  3652. out recordCount);
  3653. #region 声音文件
  3654. dt.Columns.Add("DeptName", typeof(string));//交办单位
  3655. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  3656. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  3657. dt.Columns.Add("OverState", typeof(string));//超时状态
  3658. dt.Columns.Add("LimitTime", typeof(string));//限制时间
  3659. dt.Columns.Add("GapTime", typeof(string));//时间差
  3660. dt.Columns.Add("FilePath", typeof(string));
  3661. dt.Columns.Add("Buttons", typeof(object));
  3662. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  3663. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  3664. var configcs = configBll.GetModelList(" F_ParamCode='CSYJ' ").FirstOrDefault();
  3665. foreach (DataRow dr in dt.Rows)
  3666. {
  3667. //获取最新交办信息
  3668. string iszbdw = "0";
  3669. int state = Int32.Parse(dr["F_WorkState"].ToString());
  3670. if (state > 1)
  3671. {
  3672. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  3673. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  3674. if (dtjb.Rows.Count > 0)
  3675. {
  3676. if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  3677. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  3678. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  3679. {
  3680. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  3681. }
  3682. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  3683. #region 时限
  3684. //if (state < 6 || state == 8)
  3685. if (state < (int)EnumWorkState.dealed || state == (int)EnumWorkState.reload)
  3686. {
  3687. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  3688. dr["LimitTime"] = lt;
  3689. if (!string.IsNullOrWhiteSpace(lt))
  3690. {
  3691. var ltime = DateTime.Parse(lt);
  3692. TimeSpan ts = ltime.Subtract(DateTime.Now);
  3693. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3694. if (tss < 0) { tss = -tss; }
  3695. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3696. if (ltime > DateTime.Now)
  3697. {
  3698. if (configcs != null)
  3699. {
  3700. int cs = Int32.Parse(configcs.F_ParamValue);
  3701. if (ts.TotalHours > cs)
  3702. {
  3703. dr["OverState"] = 1;
  3704. }
  3705. else
  3706. {
  3707. dr["OverState"] = 2;
  3708. }
  3709. }
  3710. dr["GapTime"] = "剩余" + gshsj;
  3711. }
  3712. else
  3713. {
  3714. dr["OverState"] = 3;
  3715. dr["GapTime"] = "超时" + gshsj;
  3716. }
  3717. }
  3718. }
  3719. if (state == (int)EnumWorkState.finish)
  3720. {
  3721. var closetime = dr["F_DealTime"].ToString();//关闭工单时间
  3722. var dttime = DateTime.Now;
  3723. if (!string.IsNullOrWhiteSpace(closetime)) { dttime = DateTime.Parse(closetime); }
  3724. var lt = dtjb.Rows[0]["F_LimitTime"].ToString();//限制时间
  3725. dr["LimitTime"] = lt;
  3726. if (!string.IsNullOrWhiteSpace(lt))
  3727. {
  3728. var ltime = DateTime.Parse(lt);
  3729. TimeSpan ts = ltime.Subtract(dttime);
  3730. int tss = Int32.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
  3731. if (tss < 0) { tss = -tss; }
  3732. string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);
  3733. if (ltime < dttime)
  3734. {
  3735. dr["OverState"] = 3;
  3736. dr["GapTime"] = "超时" + gshsj;
  3737. }
  3738. }
  3739. }
  3740. #endregion
  3741. }
  3742. }
  3743. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  3744. {
  3745. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  3746. }
  3747. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  3748. {
  3749. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  3750. }
  3751. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  3752. btns.Add(ButtonGroup.query());
  3753. dr["Buttons"] = btns;
  3754. }
  3755. #endregion
  3756. var obj = new
  3757. {
  3758. state = "success",
  3759. message = "成功",
  3760. rows = dt,
  3761. total = recordCount
  3762. };
  3763. return Content(obj.ToJson());
  3764. }
  3765. /// <summary>
  3766. /// 获取媒体工单列表
  3767. /// </summary>
  3768. /// <returns></returns>
  3769. [Authority]
  3770. public ActionResult GetMediaList(int isdc = 0)
  3771. {
  3772. DataTable dt = new DataTable();
  3773. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  3774. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  3775. string sql = " and F_IsDelete=0";
  3776. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  3777. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  3778. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  3779. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  3780. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  3781. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  3782. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  3783. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  3784. int source = RequestString.GetInt("source", 0);
  3785. int keyid = RequestString.GetInt("keyid", 0);
  3786. int type = RequestString.GetInt("type", 0);
  3787. int bigtype = RequestString.GetInt("bigtype", 0);
  3788. int smalltype = RequestString.GetInt("smalltype", 0);
  3789. int sourcearea = RequestString.GetInt("sourcearea", 0);
  3790. int deptid = RequestString.GetInt("deptid", 0);
  3791. string strpageindex = RequestString.GetQueryString("page");
  3792. int pageindex = 1;
  3793. string strpagesize = RequestString.GetQueryString("pagesize");
  3794. int pagesize = 10;
  3795. sql += " and isnull(F_IsRelease,0) =1 ";
  3796. if (strworkid.Trim() != "" && strworkid != "undefined")
  3797. {
  3798. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  3799. }
  3800. if (strname.Trim() != "" && strname != "undefined")
  3801. {
  3802. sql += " and F_CusName like '%" + strname + "%' ";
  3803. }
  3804. if (strtel.Trim() != "" && strtel != "undefined")
  3805. {
  3806. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  3807. }
  3808. if (strkey.Trim() != "" && strkey != "undefined")
  3809. {
  3810. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  3811. }
  3812. #region 坐席&调度员
  3813. if (strusercode.Trim() != "" && strusercode != "undefined")
  3814. {//坐席
  3815. var usercode = strusercode.Trim().Split(',');
  3816. var newusercode = "";
  3817. foreach (var item in usercode)
  3818. {
  3819. if (!string.IsNullOrWhiteSpace(item.Trim()))
  3820. newusercode += "'" + item + "',";
  3821. }
  3822. newusercode = newusercode.Trim(',');
  3823. if (newusercode.Trim() != "" && newusercode != "undefined")
  3824. {
  3825. sql += " and F_CreateUser in (" + newusercode + ") ";
  3826. }
  3827. }
  3828. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  3829. {//调度员
  3830. var ddusercode = strddusercode.Trim().Split(',');
  3831. var newusercode = "";
  3832. foreach (var item in ddusercode)
  3833. {
  3834. if (!string.IsNullOrWhiteSpace(item.Trim()))
  3835. newusercode += "'" + item + "',";
  3836. }
  3837. newusercode = newusercode.Trim(',');
  3838. if (newusercode.Trim() != "" && newusercode != "undefined")
  3839. {
  3840. sql += " and F_AssignUser in(" + newusercode + ") ";
  3841. }
  3842. }
  3843. //if (strusercode.Trim() != "" && strusercode != "undefined")
  3844. //{
  3845. // sql += " and F_CreateUser = '" + strusercode + "' ";
  3846. //}
  3847. #endregion
  3848. if (source != 0)
  3849. {
  3850. sql += " and F_InfoSource = '" + source + "' ";
  3851. }
  3852. if (keyid != 0)
  3853. {
  3854. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  3855. }
  3856. if (type != 0)
  3857. {
  3858. sql += " and F_InfoType = '" + type + "' ";
  3859. }
  3860. if (bigtype != 0)
  3861. {
  3862. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  3863. }
  3864. if (smalltype != 0)
  3865. {
  3866. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  3867. }
  3868. if (sourcearea != 0)
  3869. {
  3870. sql += " and F_SourceArea = '" + sourcearea + "' ";
  3871. }
  3872. if (deptid != 0)
  3873. {
  3874. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  3875. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  3876. }
  3877. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  3878. {
  3879. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  3880. }
  3881. if (strendtime.Trim() != "" && strendtime != "undefined")
  3882. {
  3883. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  3884. }
  3885. if (strpageindex.Trim() != "")
  3886. {
  3887. pageindex = Convert.ToInt32(strpageindex);
  3888. }
  3889. if (strpagesize.Trim() != "")
  3890. {
  3891. pagesize = Convert.ToInt32(strpagesize);
  3892. }
  3893. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,"
  3894. // + "dbo.GetDictionaryName(F_InfoSource) as SourceName ";
  3895. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  3896. if (isdc > 0)
  3897. {
  3898. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  3899. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  3900. if (msg == "")
  3901. {
  3902. return Success("导出成功");
  3903. }
  3904. else
  3905. {
  3906. return Error("导出失败");
  3907. }
  3908. }
  3909. int recordCount = 0;
  3910. dt = BLL.PagerBLL.GetListPager(
  3911. "T_Bus_WorkOrder WITH(NOLOCK)",
  3912. "F_WorkOrderId",
  3913. cols,
  3914. sql,
  3915. "ORDER BY F_CreateTime DESC",
  3916. pagesize,
  3917. pageindex,
  3918. true,
  3919. out recordCount);
  3920. #region 声音文件
  3921. dt.Columns.Add("DeptName", typeof(string));//交办单位
  3922. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  3923. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  3924. dt.Columns.Add("IsReturnMedia", typeof(string));
  3925. dt.Columns.Add("Buttons", typeof(object));
  3926. int IsReturnMedia = 0;
  3927. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  3928. {
  3929. IsReturnMedia = 1;
  3930. }
  3931. foreach (DataRow dr in dt.Rows)
  3932. {
  3933. int state = Int32.Parse(dr["F_WorkState"].ToString());
  3934. if (state > 1)
  3935. {
  3936. //获取最新交办信息
  3937. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  3938. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  3939. if (dtjb.Rows.Count > 0)
  3940. {
  3941. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  3942. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  3943. {
  3944. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  3945. }
  3946. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  3947. //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  3948. //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  3949. //if (deptinfo != null)
  3950. //{
  3951. // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  3952. //}
  3953. //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  3954. //{
  3955. // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  3956. // string dns = string.Empty;
  3957. // foreach (string strid in strids)
  3958. // {
  3959. // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  3960. // if (dinfo != null)
  3961. // {
  3962. // if (string.IsNullOrEmpty(dns))
  3963. // {
  3964. // dns = dinfo.F_DeptName;//交办单位
  3965. // }
  3966. // else
  3967. // {
  3968. // dns += "," + dinfo.F_DeptName;//交办单位
  3969. // }
  3970. // }
  3971. // }
  3972. // dr["OtherDeptName"] = dns;
  3973. //}
  3974. }
  3975. }
  3976. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  3977. btns.Add(ButtonGroup.query());
  3978. dr["Buttons"] = btns;
  3979. dr["IsReturnMedia"] = IsReturnMedia;
  3980. }
  3981. #endregion
  3982. var obj = new
  3983. {
  3984. state = "success",
  3985. message = "成功",
  3986. rows = dt,
  3987. total = recordCount
  3988. };
  3989. return Content(obj.ToJson());
  3990. }
  3991. ///// <summary>
  3992. ///// 获取通报工单列表
  3993. ///// </summary>
  3994. ///// <returns></returns>
  3995. //[Authority]
  3996. //public ActionResult GetNoticeList(int isdc = 0)
  3997. //{
  3998. // DataTable dt = new DataTable();
  3999. // int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  4000. // Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  4001. // string sql = " and F_IsDelete=0 and isnull(F_IsNotice,0) =1";
  4002. // string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  4003. // string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  4004. // string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  4005. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4006. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4007. // string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  4008. // string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  4009. // int source = RequestString.GetInt("source", 0);
  4010. // int keyid = RequestString.GetInt("keyid", 0);
  4011. // int type = RequestString.GetInt("type", 0);
  4012. // int bigtype = RequestString.GetInt("bigtype", 0);
  4013. // int smalltype = RequestString.GetInt("smalltype", 0);
  4014. // int sourcearea = RequestString.GetInt("sourcearea", 0);
  4015. // int deptid = RequestString.GetInt("deptid", 0);
  4016. // string strpageindex = RequestString.GetQueryString("page");
  4017. // int pageindex = 1;
  4018. // string strpagesize = RequestString.GetQueryString("pagesize");
  4019. // int pagesize = 10;
  4020. // if (strworkid.Trim() != "" && strworkid != "undefined")
  4021. // {
  4022. // sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  4023. // }
  4024. // if (strname.Trim() != "" && strname != "undefined")
  4025. // {
  4026. // sql += " and F_CusName like '%" + strname + "%' ";
  4027. // }
  4028. // if (strtel.Trim() != "" && strtel != "undefined")
  4029. // {
  4030. // sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  4031. // }
  4032. // if (strkey.Trim() != "" && strkey != "undefined")
  4033. // {
  4034. // sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  4035. // }
  4036. // if (strusercode.Trim() != "" && strusercode != "undefined")
  4037. // {
  4038. // sql += " and F_CreateUser = '" + strusercode + "' ";
  4039. // }
  4040. // if (source != 0)
  4041. // {
  4042. // sql += " and F_InfoSource = '" + source + "' ";
  4043. // }
  4044. // if (keyid != 0)
  4045. // {
  4046. // sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  4047. // }
  4048. // if (type != 0)
  4049. // {
  4050. // sql += " and F_InfoType = '" + type + "' ";
  4051. // }
  4052. // if (bigtype != 0)
  4053. // {
  4054. // sql += " and F_InfoConBigType = '" + bigtype + "' ";
  4055. // }
  4056. // if (smalltype != 0)
  4057. // {
  4058. // sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  4059. // }
  4060. // if (sourcearea != 0)
  4061. // {
  4062. // sql += " and F_SourceArea = '" + sourcearea + "' ";
  4063. // }
  4064. // if (deptid != 0)
  4065. // {
  4066. // string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  4067. // sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  4068. // }
  4069. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4070. // {
  4071. // sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  4072. // }
  4073. // if (strendtime.Trim() != "" && strendtime != "undefined")
  4074. // {
  4075. // sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  4076. // }
  4077. // if (strpageindex.Trim() != "")
  4078. // {
  4079. // pageindex = Convert.ToInt32(strpageindex);
  4080. // }
  4081. // if (strpagesize.Trim() != "")
  4082. // {
  4083. // pagesize = Convert.ToInt32(strpagesize);
  4084. // }
  4085. // string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  4086. // if (isdc > 0)
  4087. // {
  4088. // var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder where 1=1 " + sql).Tables[0];
  4089. // var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  4090. // if (msg == "")
  4091. // {
  4092. // return Success("导出成功");
  4093. // }
  4094. // else
  4095. // {
  4096. // return Error("导出失败");
  4097. // }
  4098. // }
  4099. // int recordCount = 0;
  4100. // dt = BLL.PagerBLL.GetListPager(
  4101. // "T_Bus_WorkOrder",
  4102. // "F_WorkOrderId",
  4103. // cols,
  4104. // sql,
  4105. // "ORDER BY F_CreateTime DESC",
  4106. // pagesize,
  4107. // pageindex,
  4108. // true,
  4109. // out recordCount);
  4110. // #region 声音文件
  4111. // dt.Columns.Add("DeptName", typeof(string));//交办单位
  4112. // dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  4113. // dt.Columns.Add("NoticeDeptName", typeof(string));//通报单位
  4114. // dt.Columns.Add("NoticeReson", typeof(string));//通报原因
  4115. // dt.Columns.Add("IsReturnNotice", typeof(string));
  4116. // dt.Columns.Add("FilePath", typeof(string));
  4117. // dt.Columns.Add("Buttons", typeof(object));
  4118. // var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  4119. // var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  4120. // int IsReturnNotice = 0;
  4121. // if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" ||userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY")
  4122. // {
  4123. // IsReturnNotice = 1;
  4124. // }
  4125. // foreach (DataRow dr in dt.Rows)
  4126. // {
  4127. // //获取最新交办信息
  4128. // //string iszbdw = "0";
  4129. // string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  4130. // var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  4131. // if (dtjb.Rows.Count > 0)
  4132. // {
  4133. // //if (dtjb.Rows[0]["F_MainDeptId"].ToString() == userModel.F_DeptId.ToString()) { iszbdw = "1"; }
  4134. // dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  4135. // if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  4136. // {
  4137. // dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  4138. // }
  4139. // //int did = Int32.Parse(dtjb.Rows[0]["F_MainDeptId"].ToString());
  4140. // //var deptinfo = new BLL.T_Sys_Department().GetModel(did);
  4141. // //if (deptinfo != null)
  4142. // //{
  4143. // // //if (did == userModel.F_DeptId) { iszbdw = "1"; }
  4144. // // dr["DeptName"] = deptinfo.F_DeptName;//交办单位
  4145. // //}
  4146. // //if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  4147. // //{
  4148. // // string[] strids = dtjb.Rows[0]["F_OtherDeptIds"].ToString().Split(',');
  4149. // // string dns = string.Empty;
  4150. // // foreach (string strid in strids)
  4151. // // {
  4152. // // var dinfo = new BLL.T_Sys_Department().GetModel(Int32.Parse(strid));
  4153. // // if (dinfo != null)
  4154. // // {
  4155. // // if (string.IsNullOrEmpty(dns))
  4156. // // {
  4157. // // dns = dinfo.F_DeptName;//交办单位
  4158. // // }
  4159. // // else
  4160. // // {
  4161. // // dns += "," + dinfo.F_DeptName;//交办单位
  4162. // // }
  4163. // // }
  4164. // // }
  4165. // // dr["OtherDeptName"] = dns;
  4166. // //}
  4167. // }
  4168. // //获取最新通报信息
  4169. // string sqltb = "SELECT TOP 1 * FROM T_Bus_NoticeCriticism WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 ORDER BY F_Id DESC";
  4170. // var dttb = DbHelperSQL.Query(sqltb).Tables[0];
  4171. // if (dttb.Rows.Count > 0)
  4172. // {
  4173. // if (dttb.Rows[0]["F_DeptIds"] != null && dttb.Rows[0]["F_DeptIds"].ToString() != "")
  4174. // {
  4175. // dr["NoticeDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dttb.Rows[0]["F_DeptIds"].ToString() + "')");
  4176. // }
  4177. // dr["NoticeReson"] = dttb.Rows[0]["F_Content"] != null? dttb.Rows[0]["F_Content"].ToString():"";
  4178. // }
  4179. // if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  4180. // {
  4181. // dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  4182. // }
  4183. // else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  4184. // {
  4185. // dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4186. // }
  4187. // List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  4188. // btns.Add(ButtonGroup.query());
  4189. // dr["Buttons"] = btns;
  4190. // dr["IsReturnNotice"] = IsReturnNotice;
  4191. // }
  4192. // #endregion
  4193. // var obj = new
  4194. // {
  4195. // state = "success",
  4196. // message = "成功",
  4197. // rows = dt,
  4198. // total = recordCount
  4199. // };
  4200. // return Content(obj.ToJson());
  4201. //}
  4202. /// <summary>
  4203. /// 获取通报工单列表
  4204. /// </summary>
  4205. /// <returns></returns>
  4206. [Authority]
  4207. public ActionResult GetNoticeList(string[] usercode, string[] ddusercode, int isdc = 0)//
  4208. {
  4209. DataTable dt = new DataTable();
  4210. //int userId = 8000;
  4211. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  4212. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  4213. string sql = " and F_IsDelete=0 ";
  4214. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  4215. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  4216. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  4217. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4218. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4219. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  4220. //string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  4221. //string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  4222. int source = RequestString.GetInt("source", 0);
  4223. int keyid = RequestString.GetInt("keyid", 0);
  4224. int type = RequestString.GetInt("type", 0);
  4225. int bigtype = RequestString.GetInt("bigtype", 0);
  4226. int smalltype = RequestString.GetInt("smalltype", 0);
  4227. int sourcearea = RequestString.GetInt("sourcearea", 0);
  4228. int deptid = RequestString.GetInt("deptid", 0);
  4229. string strpageindex = RequestString.GetQueryString("page");
  4230. int pageindex = 1;
  4231. string strpagesize = RequestString.GetQueryString("pagesize");
  4232. int pagesize = 10;
  4233. if (strworkid.Trim() != "" && strworkid != "undefined")
  4234. {
  4235. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  4236. }
  4237. if (strname.Trim() != "" && strname != "undefined")
  4238. {
  4239. sql += " and F_CusName like '%" + strname + "%' ";
  4240. }
  4241. if (strtel.Trim() != "" && strtel != "undefined")
  4242. {
  4243. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  4244. }
  4245. if (strkey.Trim() != "" && strkey != "undefined")
  4246. {
  4247. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  4248. }
  4249. #region 坐席&调度员
  4250. /*if (strusercode.Trim() != "" && strusercode != "undefined")
  4251. {//坐席
  4252. var usercode = strusercode.Trim().Split(',');
  4253. var newusercode = "";
  4254. foreach (var item in usercode)
  4255. {
  4256. if (!string.IsNullOrWhiteSpace(item.Trim()))
  4257. newusercode += "'" + item + "',";
  4258. }
  4259. newusercode = newusercode.Trim(',');
  4260. if (newusercode.Trim() != "" && newusercode != "undefined")
  4261. {
  4262. sql += " and F_CreateUser in (" + newusercode + ") ";
  4263. }
  4264. }*/
  4265. #region
  4266. if (usercode != null && usercode.Length > 0)
  4267. {
  4268. var newusercode = "";
  4269. //string codes = "";
  4270. for (int i = 0; i < usercode.Length; i++)
  4271. {
  4272. if (usercode[i] != "")
  4273. {
  4274. newusercode += "'" + usercode[i] + "',";
  4275. }
  4276. }
  4277. newusercode = newusercode.Trim(',');
  4278. if (newusercode.Trim() != "" && newusercode != "undefined")
  4279. {
  4280. sql += " and F_CreateUser in (" + newusercode + ") ";
  4281. }
  4282. }
  4283. if (ddusercode != null && ddusercode.Length > 0)
  4284. {
  4285. var newusercode = "";
  4286. //string codes = "";
  4287. for (int i = 0; i < ddusercode.Length; i++)
  4288. {
  4289. if (ddusercode[i] != "")
  4290. {
  4291. newusercode += "'" + ddusercode[i] + "',";
  4292. }
  4293. }
  4294. newusercode = newusercode.Trim(',');
  4295. if (newusercode.Trim() != "" && newusercode != "undefined")
  4296. {
  4297. sql += " and F_AssignUser in (" + newusercode + ") ";
  4298. }
  4299. }
  4300. #endregion
  4301. /*if (strddusercode.Trim() != "" && strddusercode != "undefined")
  4302. {//调度员
  4303. var ddusercode = strddusercode.Trim().Split(',');
  4304. var newusercode = "";
  4305. foreach (var item in ddusercode)
  4306. {
  4307. if (!string.IsNullOrWhiteSpace(item.Trim()))
  4308. newusercode += "'" + item + "',";
  4309. }
  4310. newusercode = newusercode.Trim(',');
  4311. if (newusercode.Trim() != "" && newusercode != "undefined")
  4312. {
  4313. sql += " and F_AssignUser in(" + newusercode + ") ";
  4314. }
  4315. }*/
  4316. //if (strusercode.Trim() != "" && strusercode != "undefined")
  4317. //{
  4318. // sql += " and F_CreateUser = '" + strusercode + "' ";
  4319. //}
  4320. #endregion
  4321. if (source != 0)
  4322. {
  4323. sql += " and F_InfoSource = '" + source + "' ";
  4324. }
  4325. if (keyid != 0)
  4326. {
  4327. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  4328. }
  4329. if (type != 0)
  4330. {
  4331. sql += " and F_InfoType = '" + type + "' ";
  4332. }
  4333. if (bigtype != 0)
  4334. {
  4335. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  4336. }
  4337. if (smalltype != 0)
  4338. {
  4339. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  4340. }
  4341. if (sourcearea != 0)
  4342. {
  4343. sql += " and F_SourceArea = '" + sourcearea + "' ";
  4344. }
  4345. if (deptid != 0)
  4346. {
  4347. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  4348. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  4349. }
  4350. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4351. {
  4352. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  4353. }
  4354. if (strendtime.Trim() != "" && strendtime != "undefined")
  4355. {
  4356. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  4357. }
  4358. if (userModel.F_RoleCode == "WLDW")
  4359. {
  4360. string sqlwhere = "select F_WorkOrderID from T_Bus_NoticeCriticism WITH(NOLOCK) where ','+F_DeptIds+',' like '%," + userModel.F_DeptId + ",%' and F_State=1 and F_IsDelete=0 ";
  4361. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  4362. }
  4363. else
  4364. {
  4365. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_NoticeCriticism WITH(NOLOCK) where F_State=1 and F_IsDelete=0) ";
  4366. }
  4367. if (strpageindex.Trim() != "")
  4368. {
  4369. pageindex = Convert.ToInt32(strpageindex);
  4370. }
  4371. if (strpagesize.Trim() != "")
  4372. {
  4373. pagesize = Convert.ToInt32(strpagesize);
  4374. }
  4375. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  4376. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  4377. if (isdc > 0)
  4378. {
  4379. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  4380. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  4381. if (msg == "")
  4382. {
  4383. return Success("导出成功");
  4384. }
  4385. else
  4386. {
  4387. return Error("导出失败");
  4388. }
  4389. }
  4390. int recordCount = 0;
  4391. dt = BLL.PagerBLL.GetListPager(
  4392. "T_Bus_WorkOrder WITH(NOLOCK)",
  4393. "F_WorkOrderId",
  4394. cols,
  4395. sql,
  4396. "ORDER BY F_CreateTime DESC",
  4397. pagesize,
  4398. pageindex,
  4399. true,
  4400. out recordCount);
  4401. #region 声音文件
  4402. dt.Columns.Add("DeptName", typeof(string));//交办单位
  4403. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  4404. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  4405. dt.Columns.Add("NoticeDeptName", typeof(string));//通报单位
  4406. dt.Columns.Add("NoticeReson", typeof(string));//通报原因
  4407. dt.Columns.Add("IsReturnNotice", typeof(string));
  4408. dt.Columns.Add("FilePath", typeof(string));
  4409. dt.Columns.Add("Buttons", typeof(object));
  4410. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  4411. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  4412. int IsReturnNotice = 0;
  4413. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  4414. {
  4415. IsReturnNotice = 1;
  4416. }
  4417. foreach (DataRow dr in dt.Rows)
  4418. {
  4419. //获取最新交办信息
  4420. //string iszbdw = "0";
  4421. int state = Int32.Parse(dr["F_WorkState"].ToString());
  4422. if (state > 1)
  4423. {
  4424. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  4425. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  4426. if (dtjb.Rows.Count > 0)
  4427. {
  4428. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  4429. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  4430. {
  4431. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  4432. }
  4433. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  4434. }
  4435. }
  4436. //获取最新通报信息
  4437. string sqltb = "SELECT TOP 1 * FROM T_Bus_NoticeCriticism WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 ORDER BY F_Id DESC";
  4438. var dttb = DbHelperSQL.Query(sqltb).Tables[0];
  4439. if (dttb.Rows.Count > 0)
  4440. {
  4441. if (dttb.Rows[0]["F_DeptIds"] != null && dttb.Rows[0]["F_DeptIds"].ToString() != "")
  4442. {
  4443. dr["NoticeDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dttb.Rows[0]["F_DeptIds"].ToString() + "')");
  4444. }
  4445. dr["NoticeReson"] = dttb.Rows[0]["F_Content"] != null ? dttb.Rows[0]["F_Content"].ToString() : "";
  4446. }
  4447. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  4448. {
  4449. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  4450. }
  4451. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  4452. {
  4453. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4454. }
  4455. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  4456. btns.Add(ButtonGroup.query());
  4457. dr["Buttons"] = btns;
  4458. dr["IsReturnNotice"] = IsReturnNotice;
  4459. }
  4460. #endregion
  4461. var obj = new
  4462. {
  4463. state = "success",
  4464. message = "成功",
  4465. rows = dt,
  4466. total = recordCount
  4467. };
  4468. return Content(obj.ToJson());
  4469. }
  4470. public ActionResult GetNoticeListOLD(int isdc = 0)
  4471. {
  4472. DataTable dt = new DataTable();
  4473. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  4474. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  4475. string sql = " and F_IsDelete=0 ";
  4476. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  4477. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  4478. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  4479. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4480. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4481. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  4482. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  4483. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  4484. int source = RequestString.GetInt("source", 0);
  4485. int keyid = RequestString.GetInt("keyid", 0);
  4486. int type = RequestString.GetInt("type", 0);
  4487. int bigtype = RequestString.GetInt("bigtype", 0);
  4488. int smalltype = RequestString.GetInt("smalltype", 0);
  4489. int sourcearea = RequestString.GetInt("sourcearea", 0);
  4490. int deptid = RequestString.GetInt("deptid", 0);
  4491. string strpageindex = RequestString.GetQueryString("page");
  4492. int pageindex = 1;
  4493. string strpagesize = RequestString.GetQueryString("pagesize");
  4494. int pagesize = 10;
  4495. if (strworkid.Trim() != "" && strworkid != "undefined")
  4496. {
  4497. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  4498. }
  4499. if (strname.Trim() != "" && strname != "undefined")
  4500. {
  4501. sql += " and F_CusName like '%" + strname + "%' ";
  4502. }
  4503. if (strtel.Trim() != "" && strtel != "undefined")
  4504. {
  4505. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  4506. }
  4507. if (strkey.Trim() != "" && strkey != "undefined")
  4508. {
  4509. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  4510. }
  4511. #region 坐席&调度员
  4512. if (strusercode.Trim() != "" && strusercode != "undefined")
  4513. {//坐席
  4514. var usercode = strusercode.Trim().Split(',');
  4515. var newusercode = "";
  4516. foreach (var item in usercode)
  4517. {
  4518. if (!string.IsNullOrWhiteSpace(item.Trim()))
  4519. newusercode += "'" + item + "',";
  4520. }
  4521. newusercode = newusercode.Trim(',');
  4522. if (newusercode.Trim() != "" && newusercode != "undefined")
  4523. {
  4524. sql += " and F_CreateUser in (" + newusercode + ") ";
  4525. }
  4526. }
  4527. if (strddusercode.Trim() != "" && strddusercode != "undefined")
  4528. {//调度员
  4529. var ddusercode = strddusercode.Trim().Split(',');
  4530. var newusercode = "";
  4531. foreach (var item in ddusercode)
  4532. {
  4533. if (!string.IsNullOrWhiteSpace(item.Trim()))
  4534. newusercode += "'" + item + "',";
  4535. }
  4536. newusercode = newusercode.Trim(',');
  4537. if (newusercode.Trim() != "" && newusercode != "undefined")
  4538. {
  4539. sql += " and F_AssignUser in(" + newusercode + ") ";
  4540. }
  4541. }
  4542. //if (strusercode.Trim() != "" && strusercode != "undefined")
  4543. //{
  4544. // sql += " and F_CreateUser = '" + strusercode + "' ";
  4545. //}
  4546. #endregion
  4547. if (source != 0)
  4548. {
  4549. sql += " and F_InfoSource = '" + source + "' ";
  4550. }
  4551. if (keyid != 0)
  4552. {
  4553. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  4554. }
  4555. if (type != 0)
  4556. {
  4557. sql += " and F_InfoType = '" + type + "' ";
  4558. }
  4559. if (bigtype != 0)
  4560. {
  4561. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  4562. }
  4563. if (smalltype != 0)
  4564. {
  4565. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  4566. }
  4567. if (sourcearea != 0)
  4568. {
  4569. sql += " and F_SourceArea = '" + sourcearea + "' ";
  4570. }
  4571. if (deptid != 0)
  4572. {
  4573. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  4574. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  4575. }
  4576. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4577. {
  4578. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  4579. }
  4580. if (strendtime.Trim() != "" && strendtime != "undefined")
  4581. {
  4582. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  4583. }
  4584. if (userModel.F_RoleCode == "WLDW")
  4585. {
  4586. string sqlwhere = "select F_WorkOrderID from T_Bus_NoticeCriticism WITH(NOLOCK) where ','+F_DeptIds+',' like '%," + userModel.F_DeptId + ",%' and F_State=1 and F_IsDelete=0 ";
  4587. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  4588. }
  4589. else
  4590. {
  4591. sql += " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_NoticeCriticism WITH(NOLOCK) where F_State=1 and F_IsDelete=0) ";
  4592. }
  4593. if (strpageindex.Trim() != "")
  4594. {
  4595. pageindex = Convert.ToInt32(strpageindex);
  4596. }
  4597. if (strpagesize.Trim() != "")
  4598. {
  4599. pagesize = Convert.ToInt32(strpagesize);
  4600. }
  4601. //string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  4602. string cols = "F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_OtherDeptIds,F_DealTime,F_LeaveRecordId,F_CallRecordId,F_IsResult,F_IsProtect,F_IsReturn,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  4603. if (isdc > 0)
  4604. {
  4605. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  4606. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  4607. if (msg == "")
  4608. {
  4609. return Success("导出成功");
  4610. }
  4611. else
  4612. {
  4613. return Error("导出失败");
  4614. }
  4615. }
  4616. int recordCount = 0;
  4617. dt = BLL.PagerBLL.GetListPager(
  4618. "T_Bus_WorkOrder WITH(NOLOCK)",
  4619. "F_WorkOrderId",
  4620. cols,
  4621. sql,
  4622. "ORDER BY F_CreateTime DESC",
  4623. pagesize,
  4624. pageindex,
  4625. true,
  4626. out recordCount);
  4627. #region 声音文件
  4628. dt.Columns.Add("DeptName", typeof(string));//交办单位
  4629. dt.Columns.Add("OtherDeptName", typeof(string));//协办单位
  4630. dt.Columns.Add("AssignTime", typeof(string));//交办时间
  4631. dt.Columns.Add("NoticeDeptName", typeof(string));//通报单位
  4632. dt.Columns.Add("NoticeReson", typeof(string));//通报原因
  4633. dt.Columns.Add("IsReturnNotice", typeof(string));
  4634. dt.Columns.Add("FilePath", typeof(string));
  4635. dt.Columns.Add("Buttons", typeof(object));
  4636. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  4637. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  4638. int IsReturnNotice = 0;
  4639. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  4640. {
  4641. IsReturnNotice = 1;
  4642. }
  4643. foreach (DataRow dr in dt.Rows)
  4644. {
  4645. //获取最新交办信息
  4646. //string iszbdw = "0";
  4647. int state = Int32.Parse(dr["F_WorkState"].ToString());
  4648. if (state > 1)
  4649. {
  4650. string sqljb = "SELECT TOP 1 * FROM T_Bus_AssignedInfo WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 and F_IsSure<>3 ORDER BY F_Id DESC";
  4651. var dtjb = DbHelperSQL.Query(sqljb).Tables[0];
  4652. if (dtjb.Rows.Count > 0)
  4653. {
  4654. dr["DeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_MainDeptId"].ToString() + "')");
  4655. if (dtjb.Rows[0]["F_OtherDeptIds"] != null && dtjb.Rows[0]["F_OtherDeptIds"].ToString() != "")
  4656. {
  4657. dr["OtherDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dtjb.Rows[0]["F_OtherDeptIds"].ToString() + "')");
  4658. }
  4659. dr["AssignTime"] = dtjb.Rows[0]["F_CreateTime"].ToString();
  4660. }
  4661. }
  4662. //获取最新通报信息
  4663. string sqltb = "SELECT TOP 1 * FROM T_Bus_NoticeCriticism WITH(NOLOCK) WHERE F_WorkOrderId='" + dr["F_WorkOrderId"].ToString() + "' and F_State=1 and F_IsDelete=0 ORDER BY F_Id DESC";
  4664. var dttb = DbHelperSQL.Query(sqltb).Tables[0];
  4665. if (dttb.Rows.Count > 0)
  4666. {
  4667. if (dttb.Rows[0]["F_DeptIds"] != null && dttb.Rows[0]["F_DeptIds"].ToString() != "")
  4668. {
  4669. dr["NoticeDeptName"] = DbHelperSQL.GetSingle(" select dbo.GetDeptNames('" + dttb.Rows[0]["F_DeptIds"].ToString() + "')");
  4670. }
  4671. dr["NoticeReson"] = dttb.Rows[0]["F_Content"] != null ? dttb.Rows[0]["F_Content"].ToString() : "";
  4672. }
  4673. if (dr["F_LeaveRecordId"] != null && dr["F_LeaveRecordId"].ToString() != "")
  4674. {
  4675. dr["FilePath"] = GetLeavePath(dr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  4676. }
  4677. else if (dr["F_CallRecordId"] != null && dr["F_CallRecordId"].ToString() != "")
  4678. {
  4679. dr["FilePath"] = GetCallPath(dr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4680. }
  4681. List<ButtonGroup.button> btns = new List<ButtonGroup.button>();
  4682. btns.Add(ButtonGroup.query());
  4683. dr["Buttons"] = btns;
  4684. dr["IsReturnNotice"] = IsReturnNotice;
  4685. }
  4686. #endregion
  4687. var obj = new
  4688. {
  4689. state = "success",
  4690. message = "成功",
  4691. rows = dt,
  4692. total = recordCount
  4693. };
  4694. return Content(obj.ToJson());
  4695. }
  4696. public ActionResult GetWorkorderSimp()
  4697. {
  4698. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  4699. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  4700. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  4701. if (!string.IsNullOrEmpty(strworkorderid))
  4702. {
  4703. string sql = "select F_WorkOrderId,F_CreateTime,F_ComTitle,F_Result,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDeptName(F_MainDeptId) deptname "
  4704. + " from T_Bus_WorkOrder WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "'";
  4705. var dt = DbHelperSQL.Query(sql).Tables[0];
  4706. if (dt.Rows.Count > 0)
  4707. {
  4708. return Success("成功", dt);
  4709. }
  4710. return Error("获取失败");
  4711. }
  4712. return Error("参数错误");
  4713. }
  4714. /// <summary>
  4715. /// 获取工单信息
  4716. /// </summary>
  4717. /// <returns></returns>
  4718. [Authority]
  4719. public ActionResult GetWorkOrder()
  4720. {
  4721. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  4722. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  4723. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  4724. //int type = RequestString.GetInt("type", 0);//0基本信息1监察意见2领导批示3办理情况4回访信息5督办信息6办理过程
  4725. if (!string.IsNullOrEmpty(strworkorderid))
  4726. {
  4727. string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,"
  4728. //+ "dbo.GetDictionaryName(F_InfoConBigType) as TypeName2,dbo.GetDictionaryName(F_InfoConSmallType) as TypeName3,"
  4729. //+ "dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName,dbo.GetDictionaryName(F_InfoSource) as SourceName ,"
  4730. + "dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) as KeyName,dbo.GetDeptName(F_MainDeptId) deptname "
  4731. + " from T_Bus_WorkOrder WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "'";
  4732. var dt = DbHelperSQL.Query(sql).Tables[0];
  4733. if (dt.Rows.Count > 0)
  4734. {
  4735. #region 结果汇总
  4736. //if (dt.Rows[0]["F_IsResult"] != null && dt.Rows[0]["F_IsResult"].ToString() == "0"){
  4737. // string result = "";
  4738. // string createtime = DateTime.Parse(dt.Rows[0]["F_CreateTime"].ToString()).ToString("yyyy年MM月dd日");
  4739. // string deptname = dt.Rows[0]["deptname"].ToString();
  4740. // string sourcename = dt.Rows[0]["SourceName"].ToString();
  4741. // string title = dt.Rows[0]["F_ComTitle"].ToString();
  4742. // string conresult= dt.Rows[0]["F_Result"].ToString();
  4743. // var blmodel = new BLL.T_Bus_Feedback().GetModelList("F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime desc").FirstOrDefault();
  4744. // if (blmodel != null)
  4745. // {
  4746. // string bljg = blmodel.F_IsProResult != null && blmodel.F_IsProResult == 1 ? "已办理" : "未办理";
  4747. // string hfcont = "";
  4748. // if (blmodel.F_IsProResult == 1)
  4749. // {
  4750. // hfcont = "";
  4751. // if (blmodel.F_IsProtect == 0)
  4752. // {
  4753. // string blmy = "未回访";
  4754. // switch (blmodel.F_IsSatisfied)
  4755. // {
  4756. // case 1:
  4757. // blmy = "满意";
  4758. // break;
  4759. // case 2:
  4760. // blmy = "基本满意";
  4761. // break;
  4762. // case 3:
  4763. // blmy = "不满意";
  4764. // break;
  4765. // }
  4766. // string connttime = "";
  4767. // if (blmodel.F_ConnectTime != null)
  4768. // connttime = "在" + blmodel.F_ConnectTime.Value.ToString("yyyy年MM月dd日HH时mm分");
  4769. // hfcont = " 回访:承办人 用" + blmodel.F_ConnectMode + connttime + "对反应人进行了回复,反应人对结果表示" + blmy + "。";
  4770. // }
  4771. // }
  4772. // else if (blmodel.F_IsProResult == 2)
  4773. // {
  4774. // hfcont = " 处理方案/进程:" + blmodel.F_ProSituation;
  4775. // }
  4776. // result = createtime + "," + deptname + "接到" + sourcename + "工单(编号:" + strworkorderid + ")反映" + title + ",经落实,具体情况回复如下:" + conresult + " 办理结果:" + bljg + " 承办人:" + blmodel.F_DealUser + " 职务:" + blmodel.F_Duties + " 联系电话:" + blmodel.F_DealUserContact + hfcont;
  4777. // dt.Rows[0]["F_Result"] = result;
  4778. // }
  4779. //}
  4780. #endregion
  4781. if (dt.Rows[0]["F_IsProtect"] != null && (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "EJWLDW"))
  4782. {
  4783. string isp = dt.Rows[0]["F_IsProtect"].ToString();
  4784. if (isp == "1")
  4785. {
  4786. dt.Rows[0]["F_CusName"] = "";
  4787. dt.Rows[0]["F_CusPhone"] = "";
  4788. dt.Rows[0]["F_ConPhone"] = "";
  4789. }
  4790. }
  4791. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  4792. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  4793. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  4794. //string jcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  4795. // + "from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=2 and F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  4796. string jcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  4797. + "from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=2 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4798. string dbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  4799. + "from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4800. string pssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4801. + "from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4802. string zssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4803. + "from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=2 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4804. string htsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4805. + "from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=3 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4806. string jbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName,dbo.GetDictionaryNames(F_StandardIDS) as StandardNames "
  4807. + "from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4808. string ejjbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName "
  4809. + "from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4810. string thsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  4811. + "from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4812. string yssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4813. + "from T_Bus_DelayTime WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4814. string blsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  4815. + "from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4816. string ejblsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  4817. + "from T_Bus_Feedback_Next WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4818. string hfsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4819. + "from T_Bus_VisitResult WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime ";
  4820. string gcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4821. + "from T_Bus_Operation WITH(NOLOCK) where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime ";
  4822. string cbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  4823. + "from T_Bus_Additional WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  4824. #region 声音文件
  4825. dt.Columns.Add("FilePath", typeof(string));
  4826. if (dt.Rows[0]["F_LeaveRecordId"] != null)
  4827. {
  4828. dt.Rows[0]["FilePath"] = GetLeavePath(dt.Rows[0]["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  4829. }
  4830. else if (dt.Rows[0]["F_CallRecordId"] != null)
  4831. {
  4832. dt.Rows[0]["FilePath"] = GetCallPath(dt.Rows[0]["F_CallRecordId"].ToString(), config.F_ParamValue);
  4833. }
  4834. #endregion
  4835. #region 附件
  4836. if (configfj != null)
  4837. {
  4838. dt = BindFileData(dt, configfj.F_ParamValue);
  4839. }
  4840. #endregion
  4841. #region 监察信息
  4842. var jcdt = DbHelperSQL.Query(jcsql).Tables[0];
  4843. if (configfj != null)
  4844. {
  4845. jcdt = BindFileData(jcdt, configfj.F_ParamValue);
  4846. }
  4847. #endregion
  4848. #region 批示信息
  4849. var psdt = DbHelperSQL.Query(pssql).Tables[0];
  4850. if (configfj != null)
  4851. {
  4852. psdt = BindFileData(psdt, configfj.F_ParamValue);
  4853. }
  4854. #endregion
  4855. #region 指示信息
  4856. var zsdt = DbHelperSQL.Query(zssql).Tables[0];
  4857. if (configfj != null)
  4858. {
  4859. zsdt = BindFileData(zsdt, configfj.F_ParamValue);
  4860. }
  4861. #endregion
  4862. #region 回退信息
  4863. var htdt = DbHelperSQL.Query(htsql).Tables[0];
  4864. #endregion
  4865. #region 督办信息
  4866. var dbdt = DbHelperSQL.Query(dbsql).Tables[0];
  4867. if (configfj != null)
  4868. {
  4869. dbdt = BindFileData(dbdt, configfj.F_ParamValue);
  4870. }
  4871. #endregion
  4872. #region 交办信息
  4873. var jbdt = DbHelperSQL.Query(jbsql).Tables[0];
  4874. if (configfj != null)
  4875. {
  4876. jbdt = BindFileData(jbdt, configfj.F_ParamValue);
  4877. }
  4878. var ejjbdt = DbHelperSQL.Query(ejjbsql).Tables[0];
  4879. if (configfj != null)
  4880. {
  4881. ejjbdt = BindFileData(ejjbdt, configfj.F_ParamValue);
  4882. }
  4883. #endregion
  4884. #region 退回信息
  4885. var thdt = DbHelperSQL.Query(thsql).Tables[0];
  4886. #endregion
  4887. #region 延时信息
  4888. var ysdt = DbHelperSQL.Query(yssql).Tables[0];
  4889. if (configfj != null)
  4890. {
  4891. ysdt = BindFileData(ysdt, configfj.F_ParamValue);
  4892. }
  4893. #endregion
  4894. #region 办理情况
  4895. var bldt = DbHelperSQL.Query(blsql).Tables[0];
  4896. if (configfj != null)
  4897. {
  4898. bldt = BindFileData(bldt, configfj.F_ParamValue);
  4899. }
  4900. var ejbldt = DbHelperSQL.Query(ejblsql).Tables[0];
  4901. if (configfj != null)
  4902. {
  4903. ejbldt = BindFileData(ejbldt, configfj.F_ParamValue);
  4904. }
  4905. #endregion
  4906. #region 回访信息
  4907. var hfdt = DbHelperSQL.Query(hfsql).Tables[0];
  4908. hfdt.Columns.Add("FilePath", typeof(string));
  4909. foreach (DataRow bldr in hfdt.Rows)
  4910. {
  4911. if (bldr["F_CallRecordId"] != null && config != null)
  4912. {
  4913. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4914. }
  4915. }
  4916. #endregion
  4917. #region 市民催单
  4918. var cbdt = DbHelperSQL.Query(cbsql).Tables[0];
  4919. cbdt.Columns.Add("FilePath", typeof(string));
  4920. foreach (DataRow bldr in cbdt.Rows)
  4921. {
  4922. if (bldr["F_CallRecordId"] != null && config != null)
  4923. {
  4924. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4925. }
  4926. }
  4927. #endregion
  4928. #region 办理过程
  4929. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  4930. gcdt.Columns.Add("File", typeof(object));
  4931. gcdt.Columns.Add("FilePath", typeof(string));
  4932. if (configfj != null || configly != null || config != null)
  4933. {
  4934. foreach (DataRow bldr in gcdt.Rows)
  4935. {
  4936. if (bldr["F_File"] != null && bldr["F_File"].ToString() != "" && configfj != null)
  4937. {
  4938. bldr["File"] = GetFileData(bldr["F_File"].ToString(), configfj.F_ParamValue);
  4939. }
  4940. if (bldr["F_LeaveRecordId"] != null && configly != null)
  4941. {
  4942. bldr["FilePath"] = GetLeavePath(bldr["F_LeaveRecordId"].ToString(), config.F_ParamValue);
  4943. }
  4944. else if (bldr["F_CallRecordId"] != null && config != null)
  4945. {
  4946. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  4947. }
  4948. }
  4949. }
  4950. #endregion
  4951. #region 操作按钮
  4952. var btns = new List<ButtonGroup.button>();
  4953. if (jbdt.Rows.Count > 0)
  4954. {
  4955. var jbzx = jbdt.Rows[jbdt.Rows.Count - 1];
  4956. string ispd = jbzx["F_IsNext"].ToString();
  4957. string iszbdw = "0";
  4958. string fmd = jbzx["F_MainDeptId"].ToString();
  4959. string fod = jbzx["F_OtherDeptIds"] == null ? "" : jbzx["F_OtherDeptIds"].ToString();
  4960. if (fmd == userModel.F_DeptId.ToString())
  4961. { iszbdw = "1"; }
  4962. else if (fod != "" && fod.Split(',').Contains(userModel.F_DeptId.ToString()))
  4963. {
  4964. iszbdw = "2";
  4965. }
  4966. if (!(userModel.F_RoleCode == "WLDW" && iszbdw == "0"))
  4967. {
  4968. btns = ButtonGroup.GetButtons(dt.Rows[0]["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dt.Rows[0]["F_IsResult"].ToString(), iszbdw, ispd);
  4969. }
  4970. }
  4971. else
  4972. {
  4973. btns = ButtonGroup.GetButtons(dt.Rows[0]["F_WorkState"].ToString(), userModel.F_RoleCode.ToUpper(), dt.Rows[0]["F_IsResult"].ToString(), "0");
  4974. }
  4975. #region 判断是否存在待督办
  4976. var recount = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "'").ToList().Count();
  4977. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  4978. if (recount > 0)
  4979. {
  4980. if (butt != null)
  4981. btns.Remove(butt);
  4982. if(userModel.F_RoleCode == "DBZY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  4983. {
  4984. btns.Add(ButtonGroup.oversee());
  4985. btns.Add(ButtonGroup.turnnosee());
  4986. }
  4987. }
  4988. if (btns == null)
  4989. {
  4990. btns.Add(ButtonGroup.query());
  4991. }
  4992. else
  4993. {
  4994. if (btns.Count == 0)
  4995. btns.Add(ButtonGroup.query());
  4996. }
  4997. #endregion
  4998. #endregion
  4999. #region 其他权限
  5000. int issend = 0;
  5001. if (dt.Rows[0]["F_IsRelease"] != null && (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG"))
  5002. {
  5003. if (dt.Rows[0]["F_IsRelease"].ToString() != "1")
  5004. {
  5005. issend = 1;
  5006. }
  5007. }
  5008. int isnotice = 0;
  5009. if (dt.Rows[0]["F_IsNotice"] != null && (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG"))
  5010. {
  5011. if (dt.Rows[0]["F_IsNotice"].ToString() != "1")
  5012. {
  5013. isnotice = 1;
  5014. }
  5015. }
  5016. int isedit = 0;
  5017. if (dt.Rows[0]["F_IsRelease"] != null && (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG"))
  5018. {
  5019. isedit = 1;
  5020. }
  5021. #endregion
  5022. var obj = new
  5023. {
  5024. data = dt,
  5025. jcdata = jcdt,
  5026. psdata = psdt,
  5027. zsdata = zsdt,
  5028. htdata = htdt,
  5029. dbdata = dbdt,
  5030. jbdata = jbdt,
  5031. ejjbdata = ejjbdt,
  5032. thdata = thdt,
  5033. ysdata = ysdt,
  5034. bldata = bldt,
  5035. ejbldata = ejbldt,
  5036. hfdata = hfdt,
  5037. cbdata = cbdt,
  5038. gcdata = gcdt,
  5039. issend = issend,
  5040. isedit = isedit,
  5041. isnotice = isnotice,
  5042. btndata = btns
  5043. };
  5044. return Success("获取成功", obj);
  5045. }
  5046. else
  5047. {
  5048. return Error("获取失败");
  5049. }
  5050. }
  5051. else
  5052. {
  5053. return Error("参数传输失败");
  5054. }
  5055. }
  5056. /// <summary>
  5057. /// 获取草稿信息
  5058. /// </summary>
  5059. /// <returns></returns>
  5060. [Authority]
  5061. public ActionResult GetDraftInfo()
  5062. {
  5063. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5064. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5065. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5066. int type = RequestString.GetInt("type", 0);//1交办信息 2反馈信息 3回访信息 4履职界定信息
  5067. if (!string.IsNullOrEmpty(strworkorderid) && type != 0)
  5068. {
  5069. string sql = string.Empty;
  5070. switch (type)
  5071. {
  5072. case 1:
  5073. sql = "select top 1 *,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName,dbo.GetDictionaryName(F_StandardIDS) as StandardNames from T_Bus_AssignedInfo WITH(NOLOCK)"; break;
  5074. case 2: sql = "select top 1 * from T_Bus_Feedback WITH(NOLOCK)"; break;
  5075. case 3: sql = "select top 1 * from T_Bus_VisitResult WITH(NOLOCK)"; break;
  5076. case 4: sql = "select top 1 * from T_Bus_PerformDuties WITH(NOLOCK)"; break;
  5077. }
  5078. sql += " where F_WorkOrderId='" + strworkorderid + "' and F_State=0 and F_IsDelete=0 and F_CreateUser=" + userModel.F_UserCode + " order by F_CreateTime desc";
  5079. var dt = DbHelperSQL.Query(sql).Tables[0];
  5080. if (dt.Rows.Count > 0)
  5081. {
  5082. #region 附件
  5083. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  5084. if (!string.IsNullOrEmpty(configfj.F_ParamValue))
  5085. {
  5086. BindFileData(dt, configfj.F_ParamValue);
  5087. }
  5088. #endregion
  5089. }
  5090. return Success("获取成功", dt);
  5091. }
  5092. else
  5093. {
  5094. return Error("参数传输失败");
  5095. }
  5096. }
  5097. /// <summary>
  5098. /// 获取审核信息
  5099. /// </summary>
  5100. /// <returns></returns>
  5101. [Authority]
  5102. public ActionResult GetAuditInfo()
  5103. {
  5104. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5105. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5106. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5107. int type = RequestString.GetInt("type", 0);//1退回信息2延时信息
  5108. if (!string.IsNullOrEmpty(strworkorderid) && type != 0)
  5109. {
  5110. string sql = string.Empty;
  5111. switch (type)
  5112. {
  5113. case 1: sql = "select top 1 * from T_Bus_Feedback WITH(NOLOCK) where F_Type=3 and "; break;
  5114. case 2: sql = "select top 1 * from T_Bus_DelayTime WITH(NOLOCK) where "; break;
  5115. case 3: sql = "select top 1 * from T_Bus_PerformDuties WITH(NOLOCK) where "; break;
  5116. }
  5117. sql += " F_WorkOrderId='" + strworkorderid + "' and F_State=1 and F_IsDelete=0 and F_IsAudit=0 order by F_CreateTime desc";
  5118. var dt = DbHelperSQL.Query(sql).Tables[0];
  5119. if (dt.Rows.Count > 0)
  5120. {
  5121. #region 附件
  5122. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  5123. if (!string.IsNullOrEmpty(configfj.F_ParamValue))
  5124. {
  5125. BindFileData(dt, configfj.F_ParamValue);
  5126. }
  5127. #endregion
  5128. }
  5129. return Success("获取成功", dt);
  5130. }
  5131. else
  5132. {
  5133. return Error("参数传输失败");
  5134. }
  5135. }
  5136. /// <summary>
  5137. /// 获取所有交办单位
  5138. /// </summary>
  5139. /// <returns></returns>
  5140. [Authority]
  5141. public ActionResult GetAllAssignDept()
  5142. {
  5143. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5144. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5145. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5146. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(strworkorderid);
  5147. if (modelT_Bus_WorkOrder != null)
  5148. {
  5149. string ids = string.Empty;
  5150. var Assigns = assignBLL.GetModelList(" F_WorkOrderId='" + strworkorderid + "' and F_IsDelete=0 and F_IsSure in (0,1,2) ");
  5151. foreach (var assign in Assigns)
  5152. {
  5153. if (string.IsNullOrEmpty(ids))
  5154. {
  5155. ids = assign.F_MainDeptId.Value.ToString();
  5156. if (!string.IsNullOrEmpty(assign.F_OtherDeptIds))
  5157. {
  5158. ids += "," + assign.F_OtherDeptIds;
  5159. }
  5160. }
  5161. else
  5162. {
  5163. ids += "," + assign.F_MainDeptId.Value.ToString();
  5164. if (!string.IsNullOrEmpty(assign.F_OtherDeptIds))
  5165. {
  5166. ids += "," + assign.F_OtherDeptIds;
  5167. }
  5168. }
  5169. }
  5170. if (string.IsNullOrEmpty(ids))
  5171. {
  5172. ids = "0";
  5173. }
  5174. var dt = new BLL.T_Sys_Department().GetModelList(" F_DeptId in ( " + ids + " ) ");
  5175. return Success("获取成功", dt);
  5176. }
  5177. else
  5178. {
  5179. return Error("操作失败");
  5180. }
  5181. }
  5182. /// <summary>
  5183. /// 获取二级单位处理信息
  5184. /// </summary>
  5185. /// <returns></returns>
  5186. [Authority]
  5187. public ActionResult GetSecondDealInfo()
  5188. {
  5189. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5190. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5191. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5192. if (!string.IsNullOrEmpty(strworkorderid))
  5193. {
  5194. //string sql = "SELECT an.F_Id, an.F_WorkOrderId, an.F_MainDeptId, an.F_OtherDeptIds, an.F_AssignedOpinion, an.F_Remark, an.F_CreateUser, an.F_CreateTime, an.F_IsSure, an.F_State, ";
  5195. //sql += " an.F_SureTime, an.F_IsDelete, an.F_DeleteUser, an.F_DeleteTime, an.F_SureUser, an.F_FeedbackTime, an.F_LimitTime, an.F_IsOverdue, an.F_IsSatisfie, ";
  5196. //sql += " an.F_IsReload, an.F_ReloadUser, an.F_ReloadTime, an.F_File, an.F_IsNotice, an.F_NoticeUser, an.F_NoticeTime, fn.F_AssignedId, ";
  5197. //sql += " fn.F_Result, fn.F_CreateDeptId, fn.F_IsFeedEnd, fn.F_IsAudit, fn.F_AuditUser, fn.F_AuditTime, fn.F_AuditReason ";
  5198. //sql += " FROM T_Bus_AssignedInfo_Next AS an LEFT OUTER JOIN T_Bus_Feedback_Next AS fn ON an.F_Id = fn.F_AssignedId AND an.F_IsDelete = 0 AND fn.F_IsDelete = 0";
  5199. //sql += " where an.F_WorkOrderId='" + strworkorderid + "' order by F_CreateTime desc";
  5200. //var dt = DbHelperSQL.Query(sql).Tables[0];
  5201. string sql = "select top 1 * from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_WorkOrderId='" + strworkorderid + "' and F_IsDelete = 0 order by F_CreateTime desc";
  5202. string sql1 = "select * from T_Bus_Feedback_Next WITH(NOLOCK) where F_WorkOrderId='" + strworkorderid + "' and F_IsDelete = 0 ";
  5203. var bldt = DbHelperSQL.Query(sql1).Tables[0];
  5204. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  5205. if (configfj != null)
  5206. {
  5207. bldt = BindFileData(bldt, configfj.F_ParamValue);
  5208. }
  5209. var obj = new {
  5210. pdinfo = DbHelperSQL.Query(sql).Tables[0],
  5211. fkinfo = bldt
  5212. };
  5213. return Success("获取成功", obj);
  5214. }
  5215. else
  5216. {
  5217. return Error("参数传输失败");
  5218. }
  5219. }
  5220. /// <summary>
  5221. /// 获取二级单位最新处理信息
  5222. /// </summary>
  5223. /// <returns></returns>
  5224. [Authority]
  5225. public ActionResult GetNewSecondDealInfo()
  5226. {
  5227. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5228. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5229. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5230. if (!string.IsNullOrEmpty(strworkorderid))
  5231. {
  5232. string sql = "select top 1 * from T_Bus_Feedback_Next WITH(NOLOCK) where F_WorkOrderId='" + strworkorderid + "' and F_IsDelete = 0 order by F_CreateTime desc";
  5233. var bldt = DbHelperSQL.Query(sql).Tables[0];
  5234. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  5235. if (configfj != null)
  5236. {
  5237. bldt = BindFileData(bldt, configfj.F_ParamValue);
  5238. }
  5239. return Success("获取成功", bldt);
  5240. }
  5241. else
  5242. {
  5243. return Error("参数传输失败");
  5244. }
  5245. }
  5246. /// <summary>
  5247. /// 查看回访信息
  5248. /// </summary>
  5249. /// <returns></returns>
  5250. [Authority]
  5251. public ActionResult GetVisitInfo()
  5252. {
  5253. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5254. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5255. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5256. if (!string.IsNullOrEmpty(strworkorderid))
  5257. {
  5258. string sqlvisit = "select * from T_Bus_VisitResult WITH(NOLOCK) where F_WorkOrderId='" + strworkorderid + "' and F_State=1 and F_IsDelete=0 and F_IsSatisfie=0 order by F_CreateTime";
  5259. string sqlassgin = "select * from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "' and F_State=1 and F_IsDelete=0 order by F_CreateTime";
  5260. var dtvisit = DbHelperSQL.Query(sqlvisit).Tables[0];
  5261. var dtassgin = DbHelperSQL.Query(sqlassgin).Tables[0];
  5262. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  5263. dtvisit.Columns.Add("FilePath", typeof(string));
  5264. dtvisit.Columns.Add("IsShowCheck", typeof(string));
  5265. if (dtvisit.Rows.Count > 0)
  5266. {
  5267. foreach (DataRow bldr in dtvisit.Rows)
  5268. {
  5269. #region 是否可勾选
  5270. var IsShowCheck = 0;
  5271. var drass = dtassgin.Select(" F_ID='" + bldr["F_AssignedId"].ToString() + "'");
  5272. if (drass.Length > 0)
  5273. {
  5274. var ass = (from DataRow dr in drass select dr.Field<int>("F_MainDeptId")).FirstOrDefault();
  5275. if(ass>0)
  5276. {
  5277. if (ass == userModel.F_DeptId)
  5278. IsShowCheck = 1;
  5279. }
  5280. }
  5281. bldr["IsShowCheck"] = IsShowCheck;
  5282. #endregion
  5283. #region 录音
  5284. if (bldr["F_CallRecordId"] != null && config != null)
  5285. {
  5286. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  5287. }
  5288. #endregion
  5289. }
  5290. }
  5291. return Success("获取成功", dtvisit);
  5292. }
  5293. else
  5294. {
  5295. return Error("参数传输失败");
  5296. }
  5297. }
  5298. #endregion
  5299. #region 新增工单
  5300. /// <summary>
  5301. /// 上传附件
  5302. /// </summary>
  5303. /// <returns></returns>
  5304. [Authority]
  5305. public ActionResult UploadFile()
  5306. {
  5307. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5308. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5309. #region 单个上传 no use
  5310. //string path = string.Empty;
  5311. //HttpPostedFile _upfile = RequestString.GetFile("upFile");
  5312. //if (_upfile != null)
  5313. //{
  5314. // //byte[] buffer = new Byte[(int)_upfile.InputStream.Length]; //声明文件长度的二进制类型
  5315. // //_upfile.InputStream.Read(buffer, 0, buffer.Length); //将文件转成二进制
  5316. // string name = string.Empty;
  5317. // FileUp fu = new FileUp();
  5318. // var model = configBll.GetModelList(" F_ParamCode='FilePath' ").FirstOrDefault();
  5319. // if (model != null)
  5320. // {
  5321. // name = fu.Upload(_upfile, model.F_ParamValue);
  5322. // Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  5323. // model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  5324. // model_T_Sys_Accessories.F_FileName = name;//附件名称
  5325. // model_T_Sys_Accessories.F_FileType = System.IO.Path.GetExtension(_upfile.FileName);//附件类型
  5326. // model_T_Sys_Accessories.F_FileUrl = model.F_ParamValue + name;//附件地址
  5327. // model_T_Sys_Accessories.F_Size = _upfile.ContentLength;
  5328. // model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  5329. // int p_fuId = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  5330. // return Success("成功", model_T_Sys_Accessories);
  5331. // }
  5332. // else
  5333. // {
  5334. // return Error("上传失败");
  5335. // }
  5336. //}
  5337. //else
  5338. //{
  5339. // return Error("请选择要上传的文件");
  5340. //}
  5341. #endregion
  5342. #region 多个上传
  5343. HttpFileCollection files = RequestString.GetFiles();
  5344. if (files.Count > 0)
  5345. {
  5346. List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
  5347. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  5348. for (int i = 0; i < files.Count; i++)
  5349. {
  5350. HttpPostedFile file = files[i];
  5351. FileUp fu = new FileUp();
  5352. string name = fu.Upload(file, path);
  5353. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  5354. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  5355. model_T_Sys_Accessories.F_FileName = name;//附件名称
  5356. model_T_Sys_Accessories.F_FileType = System.IO.Path.GetExtension(file.FileName);//附件类型
  5357. model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
  5358. model_T_Sys_Accessories.F_Size = file.ContentLength;
  5359. model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  5360. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  5361. model_T_Sys_Accessories.F_FileId = id;
  5362. acs.Add(model_T_Sys_Accessories);
  5363. }
  5364. return Success("成功", acs);
  5365. }
  5366. else
  5367. {
  5368. return Error("请选择要上传的文件");
  5369. }
  5370. #endregion
  5371. }
  5372. /// <summary>
  5373. /// 添加工单信息
  5374. /// </summary>
  5375. /// <returns></returns>
  5376. [Authority]
  5377. public ActionResult AddWorkOrder()
  5378. {
  5379. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5380. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5381. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ"
  5382. || userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY"
  5383. || userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "DBZY"
  5384. || userModel.F_RoleCode == "11" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG"
  5385. || userModel.F_RoleCode == "DFZF") //增加新闻媒体(编号11)的添加工单权限
  5386. {
  5387. int source = RequestString.GetInt("source", 0);
  5388. string cusname = RequestString.GetFormString("cusname");
  5389. string cussex = RequestString.GetFormString("cussex");
  5390. string cusphone = RequestString.GetFormString("cusphone");
  5391. string cusaddress = RequestString.GetFormString("cusaddress");
  5392. string email = RequestString.GetFormString("email");
  5393. string zipcode = RequestString.GetFormString("zipcode");
  5394. string conname = RequestString.GetFormString("conname");
  5395. string conphone = RequestString.GetFormString("conphone");
  5396. string title = RequestString.GetFormString("title");
  5397. string content = RequestString.GetFormString("content");
  5398. string files = RequestString.GetFormString("files");
  5399. int sourcearea = RequestString.GetInt("sourcearea", 0);
  5400. string sourceaddress = RequestString.GetFormString("sourceaddress");
  5401. int isresult = RequestString.GetInt("isresult", 0);
  5402. string result = RequestString.GetFormString("result");
  5403. string keys = RequestString.GetFormString("keys");
  5404. string splituser = RequestString.GetFormString("splituser");
  5405. int type = RequestString.GetInt("type", 0);
  5406. int bigtype = RequestString.GetInt("bigtype", 0);
  5407. int smalltype = RequestString.GetInt("smalltype", 0);
  5408. int isprotect = RequestString.GetInt("isprotect", 0);
  5409. int level = RequestString.GetInt("level", 0);
  5410. int issubmit = RequestString.GetInt("issubmit", 0);
  5411. string callid = RequestString.GetFormString("callid");
  5412. string longitude = RequestString.GetFormString("longitude");//经度
  5413. string latitude = RequestString.GetFormString("latitude");//纬度
  5414. using (TransactionScope trans = new TransactionScope())
  5415. {
  5416. #region 保存工单信息
  5417. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
  5418. modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(userModel.F_UserCode);
  5419. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  5420. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  5421. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  5422. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  5423. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  5424. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  5425. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  5426. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  5427. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  5428. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  5429. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  5430. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  5431. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  5432. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  5433. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  5434. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  5435. modelT_Bus_WorkOrder.F_File = files;//附件
  5436. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  5437. modelT_Bus_WorkOrder.F_Key = keys;
  5438. modelT_Bus_WorkOrder.F_SplitUser = splituser;
  5439. modelT_Bus_WorkOrder.F_Level = level;
  5440. modelT_Bus_WorkOrder.F_Latitude = latitude != "" ? decimal.Parse(latitude) : 0;//纬度
  5441. modelT_Bus_WorkOrder.F_Longitude = longitude != "" ? decimal.Parse(longitude) : 0;//经度
  5442. //是否直办(即时答复)0:,否1: 是
  5443. modelT_Bus_WorkOrder.F_IsResult = isresult;
  5444. modelT_Bus_WorkOrder.F_Result = result;//处理结果
  5445. modelT_Bus_WorkOrder.F_CreateUser = userModel.F_UserCode;//登记人工号
  5446. modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
  5447. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
  5448. modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
  5449. modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
  5450. modelT_Bus_WorkOrder.F_IsDelete = 0;//是否删除(0:否,1:是)
  5451. //如果选择即刻答复:是,即为直办,工单结束
  5452. if (isresult == 1)
  5453. {
  5454. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;// 9;//已结案
  5455. modelT_Bus_WorkOrder.F_DealDeptId = userModel.F_DeptId;
  5456. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  5457. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  5458. modelT_Bus_WorkOrder.F_IsClosed = 1;
  5459. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  5460. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  5461. }
  5462. else if (issubmit == 1)
  5463. {
  5464. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5465. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5466. }
  5467. #region
  5468. //20190715需求变动,去掉审核环节 提交后直接调度指派 zhengbingbing
  5469. //else
  5470. //{
  5471. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;//待审核
  5472. //}
  5473. #region
  5474. //20190315需求变动,保存并提交按钮取消,保存后提交待审核 20190329 zhengbingbing
  5475. //else if (issubmit == 1)
  5476. //{
  5477. // modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5478. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5479. //}
  5480. #endregion
  5481. #endregion
  5482. if (!string.IsNullOrEmpty(callid))
  5483. {
  5484. modelT_Bus_WorkOrder.F_CallId = callid;
  5485. var rd = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  5486. if (rd != null)
  5487. {
  5488. rd.IsExitWorkOrder = true;
  5489. new BLL.T_Call_CallRecords().Update(rd);
  5490. modelT_Bus_WorkOrder.F_CallRecordId = rd.CallRecordsId;
  5491. }
  5492. }
  5493. workorderBLL.Add(modelT_Bus_WorkOrder);
  5494. #endregion
  5495. #region 插入操作记录
  5496. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  5497. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  5498. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  5499. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  5500. oper.F_File = modelT_Bus_WorkOrder.F_File;
  5501. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  5502. //if (modelT_Bus_WorkOrder.F_WorkState == 0)
  5503. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  5504. {
  5505. oper.F_Message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5506. }
  5507. //if (modelT_Bus_WorkOrder.F_WorkState == 1)
  5508. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  5509. {
  5510. oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5511. }
  5512. //if (modelT_Bus_WorkOrder.F_WorkState == 9)
  5513. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)
  5514. {
  5515. oper.F_Message = userinfo + " 登记并结案了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5516. }
  5517. oper.F_CreateUser = userModel.F_UserCode;
  5518. oper.F_CreateTime = DateTime.Now;
  5519. oper.F_IsDelete = 0;
  5520. operBLL.Add(oper);
  5521. //推送消息表
  5522. if (modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.neworder && modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.audit) //0)
  5523. {
  5524. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  5525. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  5526. foreach (var u in users)
  5527. {
  5528. msg.AddInternalMessagesInfo("工单消息", oper.F_Message, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  5529. }
  5530. }
  5531. #endregion
  5532. trans.Complete();
  5533. }
  5534. return Success("操作成功");
  5535. }
  5536. else
  5537. {
  5538. return Error("权限不足");
  5539. }
  5540. }
  5541. /// <summary>
  5542. /// 添加工单信息
  5543. /// </summary>
  5544. /// <returns></returns>
  5545. public string AddWorkOrderBySource(int source, string cusname, string cussex, string cusphone, string cusaddress, string email,
  5546. string zipcode, string conname, string conphone, string title, string content, int sourcearea, string sourceaddress,
  5547. string keys, string splituser, int type, int bigtype, int smalltype, int isprotect, int level, string files = null)
  5548. {
  5549. string workorderid = string.Empty;
  5550. using (TransactionScope trans = new TransactionScope())
  5551. {
  5552. #region 保存工单信息
  5553. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
  5554. modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(source.ToString().PadLeft(4, '0'));
  5555. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  5556. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  5557. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  5558. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  5559. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  5560. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  5561. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  5562. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  5563. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  5564. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  5565. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  5566. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  5567. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  5568. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  5569. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  5570. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  5571. modelT_Bus_WorkOrder.F_File = files;//附件
  5572. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  5573. modelT_Bus_WorkOrder.F_Key = keys;
  5574. modelT_Bus_WorkOrder.F_SplitUser = splituser;
  5575. modelT_Bus_WorkOrder.F_Level = level;
  5576. //modelT_Bus_WorkOrder.F_Latitude = latitude != "" ? decimal.Parse(latitude) : 0;//纬度
  5577. //modelT_Bus_WorkOrder.F_Longitude = longitude != "" ? decimal.Parse(longitude) : 0;//经度
  5578. //modelT_Bus_WorkOrder.F_CreateUser = userModel.F_UserCode;//登记人工号
  5579. modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
  5580. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
  5581. //modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;//审核环节去掉 20190715
  5582. modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
  5583. modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
  5584. modelT_Bus_WorkOrder.F_IsDelete = 1;//是否删除(0:否,1:是)
  5585. modelT_Bus_WorkOrder.F_IsEnabled = 0;//是否处理
  5586. workorderBLL.Add(modelT_Bus_WorkOrder);
  5587. workorderid = modelT_Bus_WorkOrder.F_WorkOrderId;
  5588. #endregion
  5589. #region 插入操作记录
  5590. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  5591. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  5592. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  5593. string userinfo = "";
  5594. var sourceinfo = new BLL.T_Sys_DictionaryValue().GetModel(source);
  5595. if (sourceinfo != null) { userinfo = "由 " + sourceinfo.F_Value; }
  5596. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)//0)
  5597. {
  5598. oper.F_Message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5599. }
  5600. //oper.F_CreateUser = userModel.F_UserCode;
  5601. oper.F_CreateTime = DateTime.Now;
  5602. oper.F_IsDelete = 0;
  5603. operBLL.Add(oper);
  5604. #endregion
  5605. trans.Complete();
  5606. }
  5607. return workorderid;
  5608. }
  5609. /// <summary>
  5610. /// 添加工单信息留言
  5611. /// </summary>
  5612. /// <returns></returns>
  5613. [Authority]
  5614. public ActionResult AddWorkOrderByLY()
  5615. {
  5616. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5617. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5618. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  5619. {
  5620. int source = RequestString.GetInt("source", 0);
  5621. string cusname = RequestString.GetFormString("cusname");
  5622. string cussex = RequestString.GetFormString("cussex");
  5623. string cusphone = RequestString.GetFormString("cusphone");
  5624. string cusaddress = RequestString.GetFormString("cusaddress");
  5625. string email = RequestString.GetFormString("email");
  5626. string zipcode = RequestString.GetFormString("zipcode");
  5627. string conname = RequestString.GetFormString("conname");
  5628. string conphone = RequestString.GetFormString("conphone");
  5629. string title = RequestString.GetFormString("title");
  5630. string content = RequestString.GetFormString("content");
  5631. string files = RequestString.GetFormString("files");
  5632. int sourcearea = RequestString.GetInt("sourcearea", 0);
  5633. string sourceaddress = RequestString.GetFormString("sourceaddress");
  5634. int isresult = RequestString.GetInt("isresult", 0);
  5635. string result = RequestString.GetFormString("result");
  5636. string keys = RequestString.GetFormString("keys");
  5637. string splituser = RequestString.GetFormString("splituser");
  5638. int type = RequestString.GetInt("type", 0);
  5639. int bigtype = RequestString.GetInt("bigtype", 0);
  5640. int smalltype = RequestString.GetInt("smalltype", 0);
  5641. int isprotect = RequestString.GetInt("isprotect", 0);
  5642. int level = RequestString.GetInt("level", 0);
  5643. int issubmit = RequestString.GetInt("issubmit", 0);
  5644. int lyid = RequestString.GetInt("lyid", 0);
  5645. using (TransactionScope trans = new TransactionScope())
  5646. {
  5647. #region 保存工单信息
  5648. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
  5649. modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(userModel.F_UserCode);
  5650. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  5651. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  5652. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  5653. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  5654. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  5655. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  5656. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  5657. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  5658. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  5659. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  5660. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  5661. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  5662. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  5663. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  5664. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  5665. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  5666. modelT_Bus_WorkOrder.F_File = files;//附件
  5667. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  5668. modelT_Bus_WorkOrder.F_Key = keys;
  5669. modelT_Bus_WorkOrder.F_Level = level;
  5670. //是否直办(即时答复)0:,否1: 是
  5671. modelT_Bus_WorkOrder.F_IsResult = isresult;
  5672. modelT_Bus_WorkOrder.F_Result = result;//处理结果
  5673. modelT_Bus_WorkOrder.F_CreateUser = userModel.F_UserCode;//登记人工号
  5674. modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
  5675. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
  5676. modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
  5677. modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
  5678. modelT_Bus_WorkOrder.F_IsDelete = 0;//是否删除(0:否,1:是)
  5679. //如果选择即刻答复:是,即为直办,工单结束
  5680. if (isresult == 1)
  5681. {
  5682. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;// 9;//已结案
  5683. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  5684. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  5685. modelT_Bus_WorkOrder.F_IsClosed = 1;
  5686. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  5687. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  5688. }
  5689. else if (issubmit == 1)
  5690. {
  5691. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5692. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5693. }
  5694. #region
  5695. //20190715去掉审核环节
  5696. //else
  5697. //{
  5698. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;//待审核
  5699. //}
  5700. //else if (issubmit == 1)
  5701. //{
  5702. // modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5703. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5704. //}
  5705. #endregion
  5706. if (lyid != 0)
  5707. {
  5708. var rd = new BLL.T_Call_LeaveRecord().GetModel(lyid);
  5709. if (rd != null)
  5710. {
  5711. modelT_Bus_WorkOrder.F_LeaveRecordId = rd.F_Id;
  5712. }
  5713. }
  5714. workorderBLL.Add(modelT_Bus_WorkOrder);
  5715. #endregion
  5716. #region 插入操作记录
  5717. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  5718. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  5719. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  5720. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  5721. oper.F_File = modelT_Bus_WorkOrder.F_File;
  5722. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  5723. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)//0)
  5724. {
  5725. oper.F_Message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5726. }
  5727. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)//1)
  5728. {
  5729. oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5730. }
  5731. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)//9)
  5732. {
  5733. oper.F_Message = userinfo + " 登记并结案了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  5734. }
  5735. oper.F_CreateUser = userModel.F_UserCode;
  5736. oper.F_CreateTime = DateTime.Now;
  5737. oper.F_IsDelete = 0;
  5738. operBLL.Add(oper);
  5739. //推送消息表
  5740. if (modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.neworder && modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.audit)//0)
  5741. {
  5742. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  5743. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  5744. foreach (var u in users)
  5745. {
  5746. msg.AddInternalMessagesInfo("工单消息", oper.F_Message, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  5747. }
  5748. }
  5749. #endregion
  5750. trans.Complete();
  5751. }
  5752. return Success("操作成功");
  5753. }
  5754. else
  5755. {
  5756. return Error("权限不足");
  5757. }
  5758. }
  5759. /// <summary>
  5760. /// 添加工单信息
  5761. /// </summary>
  5762. /// <returns></returns>
  5763. [Authority]
  5764. public ActionResult AddWorkOrderByAPP()
  5765. {
  5766. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5767. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5768. int source = RequestString.GetInt("source", 6);
  5769. string cusname = RequestString.GetFormString("cusname");
  5770. string cussex = RequestString.GetFormString("cussex");
  5771. string cusphone = RequestString.GetFormString("cusphone");
  5772. string cusaddress = RequestString.GetFormString("cusaddress");
  5773. string email = RequestString.GetFormString("email");
  5774. string zipcode = RequestString.GetFormString("zipcode");
  5775. string conname = RequestString.GetFormString("conname");
  5776. string conphone = RequestString.GetFormString("conphone");
  5777. string title = RequestString.GetFormString("title");
  5778. string content = RequestString.GetFormString("content");
  5779. string files = RequestString.GetFormString("files");
  5780. int sourcearea = RequestString.GetInt("sourcearea", 0);
  5781. string sourceaddress = RequestString.GetFormString("sourceaddress");
  5782. int isresult = RequestString.GetInt("isresult", 0);
  5783. string result = RequestString.GetFormString("result");
  5784. string keys = RequestString.GetFormString("keys");
  5785. string splituser = RequestString.GetFormString("splituser");
  5786. int type = RequestString.GetInt("type", 0);
  5787. int bigtype = RequestString.GetInt("bigtype", 0);
  5788. int smalltype = RequestString.GetInt("smalltype", 0);
  5789. int isprotect = RequestString.GetInt("isprotect", 0);
  5790. int level = RequestString.GetInt("level", 0);
  5791. string workorderid = AddWorkOrderBySource(6, cusname, cussex, cusphone, cusaddress, email, zipcode, conname,
  5792. conphone, title, content, sourcearea, sourceaddress, keys, splituser, type, bigtype, smalltype, isprotect, level, files);
  5793. if (!string.IsNullOrEmpty(workorderid))
  5794. {
  5795. using (TransactionScope trans = new TransactionScope())
  5796. {
  5797. #region 保存用户工单信息
  5798. var model = new BLL.T_Sys_Users().GetModel(userModel.F_UserCode);
  5799. if (model == null)
  5800. {
  5801. model = new Model.T_Sys_Users();
  5802. model.F_OpenId = userModel.F_UserCode;
  5803. model.F_Type = (int)EnumUserType.app;//3;
  5804. model.F_CreateTime = DateTime.Now;
  5805. model.F_Id = new BLL.T_Sys_Users().Add(model);
  5806. }
  5807. Model.T_Bus_UserWorkOrder tbu = new Model.T_Bus_UserWorkOrder();
  5808. tbu.F_UserId = model.F_Id;
  5809. tbu.F_WorkOrderId = workorderid;
  5810. new BLL.T_Bus_UserWorkOrder().Add(tbu);
  5811. #endregion
  5812. trans.Complete();
  5813. }
  5814. return Success("操作成功");
  5815. }
  5816. else
  5817. {
  5818. return Error("操作失败");
  5819. }
  5820. }
  5821. #endregion
  5822. #region 操作工单
  5823. /// <summary>
  5824. /// 修改工单信息
  5825. /// </summary>
  5826. /// <returns></returns>
  5827. [Authority]
  5828. public ActionResult EditWorkOrder()
  5829. {
  5830. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5831. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5832. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  5833. {
  5834. string workorderid = RequestString.GetFormString("workorderid");
  5835. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  5836. //if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState == 1 || modelT_Bus_WorkOrder.F_WorkState == 0))
  5837. if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit))
  5838. {
  5839. int source = RequestString.GetInt("source", 0);
  5840. string cusname = RequestString.GetFormString("cusname");
  5841. string cussex = RequestString.GetFormString("cussex");
  5842. string cusphone = RequestString.GetFormString("cusphone");
  5843. string cusaddress = RequestString.GetFormString("cusaddress");
  5844. string email = RequestString.GetFormString("email");
  5845. string zipcode = RequestString.GetFormString("zipcode");
  5846. string conname = RequestString.GetFormString("conname");
  5847. string conphone = RequestString.GetFormString("conphone");
  5848. string title = RequestString.GetFormString("title");
  5849. string content = RequestString.GetFormString("content");
  5850. string files = RequestString.GetFormString("files");
  5851. int sourcearea = RequestString.GetInt("sourcearea", 0);
  5852. string sourceaddress = RequestString.GetFormString("sourceaddress");
  5853. int isresult = RequestString.GetInt("isresult", 0);
  5854. string result = RequestString.GetFormString("result");
  5855. string keys = RequestString.GetFormString("keys");
  5856. string splituser = RequestString.GetFormString("splituser");
  5857. int type = RequestString.GetInt("type", 0);
  5858. int bigtype = RequestString.GetInt("bigtype", 0);
  5859. int smalltype = RequestString.GetInt("smalltype", 0);
  5860. int isprotect = RequestString.GetInt("isprotect", 0);
  5861. int level = RequestString.GetInt("level", 0);
  5862. int issubmit = RequestString.GetInt("issubmit", 0);
  5863. using (TransactionScope trans = new TransactionScope())
  5864. {
  5865. #region 保存工单信息
  5866. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  5867. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  5868. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  5869. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  5870. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  5871. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  5872. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  5873. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  5874. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  5875. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  5876. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  5877. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  5878. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  5879. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  5880. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  5881. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  5882. modelT_Bus_WorkOrder.F_File = files;//附件
  5883. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  5884. modelT_Bus_WorkOrder.F_Key = keys;
  5885. modelT_Bus_WorkOrder.F_Level = level;
  5886. //是否直办(即时答复)0:,否1: 是
  5887. modelT_Bus_WorkOrder.F_IsResult = isresult;
  5888. modelT_Bus_WorkOrder.F_Result = result;//处理结果
  5889. //如果选择即刻答复:是,即为直办,工单结束
  5890. if (isresult == 1)
  5891. {
  5892. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;// 9;//已结案
  5893. modelT_Bus_WorkOrder.F_DealDeptId = userModel.F_DeptId;
  5894. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  5895. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  5896. modelT_Bus_WorkOrder.F_IsClosed = 1;
  5897. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  5898. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  5899. }
  5900. else if (issubmit == 1)
  5901. {
  5902. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5903. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5904. }
  5905. #region
  5906. //20190715 审核环节去掉 zhengbingbing
  5907. //else
  5908. //{
  5909. // if(modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  5910. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;
  5911. //}
  5912. //else if (issubmit == 1)
  5913. //{
  5914. // modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  5915. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  5916. //}
  5917. #endregion
  5918. workorderBLL.Update(modelT_Bus_WorkOrder);
  5919. #endregion
  5920. #region 插入操作记录
  5921. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  5922. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  5923. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  5924. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  5925. oper.F_File = modelT_Bus_WorkOrder.F_File;
  5926. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  5927. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)//0)
  5928. {
  5929. oper.F_Message = userinfo + " 修改了工单";
  5930. }
  5931. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)//1)
  5932. {
  5933. oper.F_Message = userinfo + " 修改并提交了工单";
  5934. }
  5935. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)//9)
  5936. {
  5937. oper.F_Message = userinfo + " 修改并结案了工单";
  5938. }
  5939. oper.F_CreateUser = userModel.F_UserCode;
  5940. oper.F_CreateTime = DateTime.Now;
  5941. oper.F_IsDelete = 0;
  5942. operBLL.Add(oper);
  5943. //推送消息表
  5944. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)//1)
  5945. {
  5946. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  5947. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  5948. foreach (var u in users)
  5949. {
  5950. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  5951. }
  5952. }
  5953. //调用科大讯飞
  5954. if (modelT_Bus_WorkOrder.F_InfoSource == 7 && modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)//9)
  5955. {
  5956. ShangQiuWorkOrderController sqwo = new ShangQiuWorkOrderController();
  5957. bool bl = sqwo.SaveReplyInfo(oper.F_WorkOrderId, userModel.F_UserCode, userModel.depname, modelT_Bus_WorkOrder.F_Result, "3", modelT_Bus_WorkOrder.F_InfoType.Value.ToString());
  5958. if (bl)
  5959. {
  5960. Success("调用成功,工单号:" + oper.F_WorkOrderId);
  5961. }
  5962. else
  5963. {
  5964. Error("调用失败,工单号:" + oper.F_WorkOrderId);
  5965. }
  5966. }
  5967. #endregion
  5968. trans.Complete();
  5969. }
  5970. return Success("操作成功");
  5971. }
  5972. else
  5973. {
  5974. return Error("操作失败");
  5975. }
  5976. }
  5977. else
  5978. {
  5979. return Success("权限不足");
  5980. }
  5981. }
  5982. /// <summary>
  5983. /// 修改工单信息
  5984. /// </summary>
  5985. /// <returns></returns>
  5986. [Authority]
  5987. public ActionResult EditWorkOrderBySource()
  5988. {
  5989. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  5990. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  5991. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  5992. {
  5993. string workorderid = RequestString.GetFormString("workorderid");
  5994. int source = RequestString.GetInt("source", 0);
  5995. string cusname = RequestString.GetFormString("cusname");
  5996. string cussex = RequestString.GetFormString("cussex");
  5997. string cusphone = RequestString.GetFormString("cusphone");
  5998. string cusaddress = RequestString.GetFormString("cusaddress");
  5999. string email = RequestString.GetFormString("email");
  6000. string zipcode = RequestString.GetFormString("zipcode");
  6001. string conname = RequestString.GetFormString("conname");
  6002. string conphone = RequestString.GetFormString("conphone");
  6003. string title = RequestString.GetFormString("title");
  6004. string content = RequestString.GetFormString("content");
  6005. string files = RequestString.GetFormString("files");
  6006. int sourcearea = RequestString.GetInt("sourcearea", 0);
  6007. string sourceaddress = RequestString.GetFormString("sourceaddress");
  6008. int isresult = RequestString.GetInt("isresult", 0);
  6009. string result = RequestString.GetFormString("result");
  6010. string keys = RequestString.GetFormString("keys");
  6011. string splituser = RequestString.GetFormString("splituser");
  6012. int type = RequestString.GetInt("type", 0);
  6013. int bigtype = RequestString.GetInt("bigtype", 0);
  6014. int smalltype = RequestString.GetInt("smalltype", 0);
  6015. int isprotect = RequestString.GetInt("isprotect", 0);
  6016. int level = RequestString.GetInt("level", 0);
  6017. int issubmit = RequestString.GetInt("issubmit", 0);
  6018. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6019. if (modelT_Bus_WorkOrder != null)
  6020. {
  6021. if (modelT_Bus_WorkOrder.F_IsEnabled == 0)
  6022. {
  6023. using (TransactionScope trans = new TransactionScope())
  6024. {
  6025. #region 保存工单信息
  6026. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  6027. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  6028. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  6029. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  6030. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  6031. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  6032. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  6033. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  6034. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  6035. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  6036. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  6037. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  6038. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  6039. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  6040. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  6041. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  6042. modelT_Bus_WorkOrder.F_File = files;//附件
  6043. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  6044. modelT_Bus_WorkOrder.F_Key = keys;
  6045. modelT_Bus_WorkOrder.F_Level = level;
  6046. //是否直办(即时答复)0:,否1: 是
  6047. modelT_Bus_WorkOrder.F_IsResult = isresult;
  6048. modelT_Bus_WorkOrder.F_Result = result;//处理结果
  6049. //如果选择即刻答复:是,即为直办,工单结束
  6050. if (isresult == 1)
  6051. {
  6052. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;// 9;//已结案
  6053. modelT_Bus_WorkOrder.F_DealDeptId = userModel.F_DeptId;
  6054. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  6055. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  6056. modelT_Bus_WorkOrder.F_IsClosed = 1;
  6057. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  6058. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  6059. }
  6060. else if (issubmit == 1)
  6061. {
  6062. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  6063. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  6064. }
  6065. #region
  6066. //20190715 去掉审核环节 zhengbingbing
  6067. //else
  6068. //{
  6069. // if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  6070. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;
  6071. //}
  6072. //20190329
  6073. //else if (issubmit == 1)
  6074. //{
  6075. // modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  6076. // modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;// 1;//提交领导
  6077. //}
  6078. #endregion
  6079. modelT_Bus_WorkOrder.F_CreateUser = userModel.F_UserCode;
  6080. modelT_Bus_WorkOrder.F_IsEnabled = 1;
  6081. modelT_Bus_WorkOrder.F_EnableTime = DateTime.Now;
  6082. modelT_Bus_WorkOrder.F_IsDelete = 0;
  6083. workorderBLL.Update(modelT_Bus_WorkOrder);
  6084. #endregion
  6085. #region 插入操作记录
  6086. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6087. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6088. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6089. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  6090. oper.F_File = modelT_Bus_WorkOrder.F_File;
  6091. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6092. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)//0)
  6093. {
  6094. oper.F_Message = userinfo + " 处理了工单";
  6095. }
  6096. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)//1)
  6097. {
  6098. oper.F_Message = userinfo + " 处理并提交了工单";
  6099. }
  6100. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)//9)
  6101. {
  6102. oper.F_Message = userinfo + " 处理并结案了工单";
  6103. }
  6104. oper.F_CreateUser = userModel.F_UserCode;
  6105. oper.F_CreateTime = DateTime.Now;
  6106. oper.F_IsDelete = 0;
  6107. operBLL.Add(oper);
  6108. //推送消息表
  6109. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)//1)
  6110. {
  6111. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  6112. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  6113. foreach (var u in users)
  6114. {
  6115. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6116. }
  6117. }
  6118. //调用科大讯飞
  6119. if (modelT_Bus_WorkOrder.F_InfoSource == 7 && modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)//9)
  6120. {
  6121. ShangQiuWorkOrderController sqwo = new ShangQiuWorkOrderController();
  6122. bool bl = sqwo.SaveReplyInfo(oper.F_WorkOrderId, userModel.F_UserCode, userModel.depname, modelT_Bus_WorkOrder.F_Result, "3", modelT_Bus_WorkOrder.F_InfoType.Value.ToString());
  6123. if (bl)
  6124. {
  6125. Success("调用成功,工单号:" + oper.F_WorkOrderId);
  6126. }
  6127. else
  6128. {
  6129. Error("调用失败,工单号:" + oper.F_WorkOrderId);
  6130. }
  6131. }
  6132. #endregion
  6133. trans.Complete();
  6134. }
  6135. return Success("操作成功");
  6136. }
  6137. else
  6138. {
  6139. return Error("已经处理过了");
  6140. }
  6141. }
  6142. else
  6143. {
  6144. return Error("操作失败");
  6145. }
  6146. }
  6147. else
  6148. {
  6149. return Success("权限不足");
  6150. }
  6151. }
  6152. #region 新增审核工单流程
  6153. /// <summary>
  6154. /// 20190315需求变动,新增审核工单,由组长审核
  6155. /// </summary>
  6156. /// <param name="ids"></param>
  6157. /// <returns></returns>
  6158. [Authority]
  6159. public ActionResult AuditWorkOrder()
  6160. {
  6161. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6162. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6163. if (userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  6164. {
  6165. string workorderid = RequestString.GetFormString("workorderid");
  6166. int state = RequestString.GetInt("state", 0);
  6167. string reason = RequestString.GetFormString("reason");
  6168. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6169. if (modelT_Bus_WorkOrder != null)
  6170. {
  6171. using (TransactionScope trans = new TransactionScope())
  6172. {
  6173. if (modelT_Bus_WorkOrder != null)
  6174. {
  6175. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  6176. {
  6177. var opt = "审核并提交"; var re = "";
  6178. #region 保存工单信息
  6179. if (state == 1)
  6180. {
  6181. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  6182. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;//待交办
  6183. }
  6184. else
  6185. {
  6186. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;
  6187. opt = "审核并退回";
  6188. re = ",退回原因:" + reason;
  6189. }
  6190. workorderBLL.Update(modelT_Bus_WorkOrder);
  6191. #endregion
  6192. #region 插入操作记录
  6193. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6194. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6195. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6196. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6197. oper.F_Message = userinfo + " " + opt + "了工单" + re;
  6198. oper.F_CreateUser = userModel.F_UserCode;
  6199. oper.F_CreateTime = DateTime.Now;
  6200. oper.F_IsDelete = 0;
  6201. operBLL.Add(oper);
  6202. //推送消息表
  6203. //if (modelT_Bus_WorkOrder.F_WorkState == 1)
  6204. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  6205. {
  6206. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  6207. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  6208. foreach (var u in users)
  6209. {
  6210. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6211. }
  6212. }
  6213. #endregion
  6214. }
  6215. }
  6216. trans.Complete();
  6217. }
  6218. return Success("操作成功");
  6219. }
  6220. else
  6221. {
  6222. return Error("操作失败");
  6223. }
  6224. }
  6225. else
  6226. {
  6227. return Error("权限不足");
  6228. }
  6229. }
  6230. #endregion
  6231. /// <summary>
  6232. /// 提交工单
  6233. /// </summary>
  6234. /// <param name="ids"></param>
  6235. /// <returns></returns>
  6236. [Authority]
  6237. public ActionResult SubmitWorkOrder(string[] ids)
  6238. {
  6239. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6240. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6241. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  6242. {
  6243. if (ids != null && ids.Length > 0)
  6244. {
  6245. foreach (string str in ids)
  6246. {
  6247. using (TransactionScope trans = new TransactionScope())
  6248. {
  6249. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(str);
  6250. if (modelT_Bus_WorkOrder != null)
  6251. {
  6252. //if (modelT_Bus_WorkOrder.F_WorkState == 0)
  6253. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  6254. {
  6255. #region 保存工单信息
  6256. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  6257. //modelT_Bus_WorkOrder.F_WorkState = 1;//待交办
  6258. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;//待交办
  6259. workorderBLL.Update(modelT_Bus_WorkOrder);
  6260. #endregion
  6261. #region 插入操作记录
  6262. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6263. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6264. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6265. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6266. oper.F_Message = userinfo + " 提交了工单";
  6267. oper.F_CreateUser = userModel.F_UserCode;
  6268. oper.F_CreateTime = DateTime.Now;
  6269. oper.F_IsDelete = 0;
  6270. operBLL.Add(oper);
  6271. //推送消息表
  6272. //if (modelT_Bus_WorkOrder.F_WorkState == 1)
  6273. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  6274. {
  6275. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY') ").Select(p => p.F_RoleId);
  6276. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  6277. foreach (var u in users)
  6278. {
  6279. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6280. }
  6281. }
  6282. #endregion
  6283. }
  6284. }
  6285. trans.Complete();
  6286. }
  6287. }
  6288. return Success("操作成功");
  6289. }
  6290. else
  6291. {
  6292. return Error("操作失败");
  6293. }
  6294. }
  6295. else
  6296. {
  6297. return Error("权限不足");
  6298. }
  6299. }
  6300. /// <summary>
  6301. /// 回退工单
  6302. /// </summary>
  6303. /// <returns></returns>
  6304. [Authority]
  6305. public ActionResult ReturnWorkOrder()
  6306. {
  6307. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6308. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  6309. string workorderid = RequestString.GetFormString("workorderid");
  6310. string backuser = RequestString.GetFormString("backuser");
  6311. string backreason = RequestString.GetFormString("backreason");
  6312. string files = RequestString.GetFormString("files");
  6313. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  6314. if (modelT_Bus_WorkOrder != null)
  6315. {
  6316. //if (modelT_Bus_WorkOrder.F_WorkState == 1 || (modelT_Bus_WorkOrder.F_WorkState == 9 && modelT_Bus_WorkOrder.F_IsResult==1))
  6317. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit || (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish && modelT_Bus_WorkOrder.F_IsResult == 1))
  6318. {
  6319. using (TransactionScope trans = new TransactionScope())
  6320. {
  6321. #region 保存工单信息
  6322. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;
  6323. //modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.audit;// 0;
  6324. modelT_Bus_WorkOrder.F_IsResult = 0;
  6325. modelT_Bus_WorkOrder.F_IsReturn = 1;
  6326. modelT_Bus_WorkOrder.F_AssignUser = userModel.F_UserCode;
  6327. modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
  6328. workorderBLL.Update(modelT_Bus_WorkOrder);
  6329. #endregion
  6330. #region 插入批示记录
  6331. //批示记录
  6332. Model.T_Bus_SubmitSuper model_T_Bus_SubmitSuper = new Model.T_Bus_SubmitSuper();
  6333. model_T_Bus_SubmitSuper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
  6334. model_T_Bus_SubmitSuper.F_Type = 3;//1领导批示 2市长指示 3回退
  6335. model_T_Bus_SubmitSuper.F_BatchReason = backuser;//批示人
  6336. model_T_Bus_SubmitSuper.F_SuperOpinion = backreason;//批示内容
  6337. model_T_Bus_SubmitSuper.F_File = files;//附件
  6338. model_T_Bus_SubmitSuper.F_CreateUser = userModel.F_UserCode;//呈批人
  6339. model_T_Bus_SubmitSuper.F_CreateTime = DateTime.Now;//呈批时间
  6340. model_T_Bus_SubmitSuper.F_IsDelete = 0;
  6341. model_T_Bus_SubmitSuper.F_State = 1;//审批状态(0:未处理,1:通过)
  6342. new BLL.T_Bus_SubmitSuper().Add(model_T_Bus_SubmitSuper);
  6343. #endregion
  6344. #region 插入操作记录
  6345. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6346. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6347. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6348. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6349. oper.F_Message = userinfo + " 回退了工单";
  6350. oper.F_CreateUser = userModel.F_UserCode;
  6351. oper.F_CreateTime = DateTime.Now;
  6352. oper.F_IsDelete = 0;
  6353. operBLL.Add(oper);
  6354. #endregion
  6355. trans.Complete();
  6356. }
  6357. return Success("操作成功");
  6358. }
  6359. else
  6360. {
  6361. return Error("已经处理过了");
  6362. }
  6363. }
  6364. else
  6365. {
  6366. return Error("操作失败");
  6367. }
  6368. }
  6369. /// <summary>
  6370. /// 领导批示/市长指示
  6371. /// </summary>
  6372. /// <param name="ids"></param>
  6373. /// <returns></returns>
  6374. [Authority]
  6375. public ActionResult SuperWorkOrder()
  6376. {
  6377. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6378. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6379. string workorderid = RequestString.GetFormString("workorderid");
  6380. int type = RequestString.GetInt("type", 0);//1领导批示 2市长指示 3转督办
  6381. string superuser = RequestString.GetFormString("superuser");
  6382. string superopinion = RequestString.GetFormString("superopinion");
  6383. string files = RequestString.GetFormString("files");
  6384. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6385. if (modelT_Bus_WorkOrder != null)
  6386. {
  6387. using (TransactionScope trans = new TransactionScope())
  6388. {
  6389. #region 保存工单信息 no use
  6390. //modelT_Bus_WorkOrder.F_WorkState = 2;//领导批示
  6391. //workorderBLL.Update(modelT_Bus_WorkOrder);
  6392. #endregion
  6393. #region 插入批示记录
  6394. //批示记录
  6395. Model.T_Bus_SubmitSuper model_T_Bus_SubmitSuper = new Model.T_Bus_SubmitSuper();
  6396. model_T_Bus_SubmitSuper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
  6397. model_T_Bus_SubmitSuper.F_Type = type;//1领导批示 2市长指示
  6398. model_T_Bus_SubmitSuper.F_BatchReason = superuser;//批示人
  6399. model_T_Bus_SubmitSuper.F_SuperOpinion = superopinion;//批示内容
  6400. model_T_Bus_SubmitSuper.F_File = files;//附件
  6401. model_T_Bus_SubmitSuper.F_CreateUser = userModel.F_UserCode;//呈批人
  6402. model_T_Bus_SubmitSuper.F_CreateTime = DateTime.Now;//呈批时间
  6403. model_T_Bus_SubmitSuper.F_IsDelete = 0;
  6404. model_T_Bus_SubmitSuper.F_State = 1;//审批状态(0:未处理,1:通过)
  6405. new BLL.T_Bus_SubmitSuper().Add(model_T_Bus_SubmitSuper);
  6406. #endregion
  6407. #region 插入操作记录
  6408. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6409. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6410. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6411. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6412. oper.F_Message = userinfo+ " 批示了工单";
  6413. oper.F_CreateUser = userModel.F_UserCode;
  6414. oper.F_CreateTime = DateTime.Now;
  6415. oper.F_IsDelete = 0;
  6416. operBLL.Add(oper);
  6417. #endregion
  6418. trans.Complete();
  6419. }
  6420. return Success("操作成功");
  6421. }
  6422. else
  6423. {
  6424. return Error("操作失败");
  6425. }
  6426. }
  6427. /// <summary>
  6428. /// 交办工单
  6429. /// </summary>
  6430. /// <returns></returns>
  6431. [Authority]
  6432. public ActionResult AssignWorkOrder()
  6433. {
  6434. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6435. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6436. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  6437. {
  6438. string workorderid = RequestString.GetFormString("workorderid");
  6439. int state = RequestString.GetInt("state", 0);
  6440. int assignid = RequestString.GetInt("assignid", 0);
  6441. int maindeptid = RequestString.GetInt("maindeptid", 0);
  6442. //string maindeptid = RequestString.GetFormString("maindeptid");
  6443. string otherdeptids = RequestString.GetFormString("otherdeptids");
  6444. DateTime limittime = DateTime.Parse(RequestString.GetFormString("limittime") + " 23:59:59");
  6445. string assignedopinion = RequestString.GetFormString("assignedopinion");
  6446. var modelT_Bus_AssignedInfoLasts = assignBLL.GetList(0, $" F_WorkOrderId='{workorderid}' and F_IsDelete='0' and F_State='1' ", " F_CreateTime desc").Tables[0];
  6447. if (modelT_Bus_AssignedInfoLasts.Rows.Count > 0)
  6448. {
  6449. if (modelT_Bus_AssignedInfoLasts.Rows[0]["F_CreateUser"].ToString() != userModel.F_UserCode)
  6450. {
  6451. return Error("操作失败");
  6452. }
  6453. }
  6454. if (!string.IsNullOrEmpty(otherdeptids))
  6455. {
  6456. if (otherdeptids.Split(',').Contains(maindeptid.ToString()))
  6457. {
  6458. return Error("主办单位不能出现在协办单位");
  6459. }
  6460. }
  6461. if (limittime < DateTime.Now)
  6462. {
  6463. return Error("办理时限不能小于当前时间");
  6464. }
  6465. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6466. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = new Model.T_Bus_AssignedInfo();
  6467. var deptinfo = new BLL.T_Sys_Department().GetModel(maindeptid);
  6468. if (modelT_Bus_WorkOrder != null && deptinfo != null)
  6469. {
  6470. //if (modelT_Bus_WorkOrder.F_WorkState == 1)
  6471. //if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  6472. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  6473. {
  6474. int aid = 0;
  6475. using (TransactionScope trans = new TransactionScope())
  6476. {
  6477. if (assignid == 0)
  6478. {
  6479. #region 插入交办记录
  6480. modelT_Bus_AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6481. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  6482. modelT_Bus_AssignedInfo.F_MainDeptId = maindeptid;//主办单位id
  6483. modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  6484. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  6485. modelT_Bus_AssignedInfo.F_State = state;//0草稿 1正式
  6486. modelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  6487. modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  6488. modelT_Bus_AssignedInfo.F_IsDelete = 0;
  6489. modelT_Bus_AssignedInfo.F_IsOverdue = 0;
  6490. modelT_Bus_AssignedInfo.F_IsSure = 0;
  6491. modelT_Bus_AssignedInfo.F_IsReload = 0;
  6492. modelT_Bus_AssignedInfo.F_IsNext = 0;
  6493. modelT_Bus_AssignedInfo.F_TimeResp= assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
  6494. aid = assignBLL.Add(modelT_Bus_AssignedInfo);
  6495. #endregion
  6496. }
  6497. else
  6498. {
  6499. #region 修改交办记录
  6500. modelT_Bus_AssignedInfo = assignBLL.GetModel(assignid);
  6501. if (modelT_Bus_AssignedInfo != null)
  6502. {
  6503. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  6504. modelT_Bus_AssignedInfo.F_MainDeptId = maindeptid;//主办单位id
  6505. modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  6506. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  6507. modelT_Bus_AssignedInfo.F_TimeResp = assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
  6508. modelT_Bus_AssignedInfo.F_State = state;//0草稿 1正式
  6509. modelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  6510. modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  6511. assignBLL.Update(modelT_Bus_AssignedInfo);
  6512. aid = modelT_Bus_AssignedInfo.F_Id;
  6513. }
  6514. #endregion
  6515. }
  6516. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_State == 1)
  6517. {
  6518. #region 保存工单信息
  6519. //modelT_Bus_WorkOrder.F_WorkState = 2;//待查收
  6520. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.receive;//待查收
  6521. modelT_Bus_WorkOrder.F_LimitTime = limittime;
  6522. modelT_Bus_WorkOrder.F_MainDeptId = maindeptid;
  6523. modelT_Bus_WorkOrder.F_OtherDeptIds = otherdeptids;
  6524. modelT_Bus_WorkOrder.F_AssignUser = userModel.F_UserCode;
  6525. modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
  6526. workorderBLL.Update(modelT_Bus_WorkOrder);
  6527. #endregion
  6528. #region 删除草稿信息
  6529. var cglist = assignBLL.GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  6530. foreach (var cg in cglist)
  6531. {
  6532. cg.F_IsDelete = 1;
  6533. cg.F_DeleteUser = userModel.F_UserCode;
  6534. cg.F_DeleteTime = DateTime.Now;
  6535. assignBLL.Update(cg);
  6536. }
  6537. #endregion
  6538. #region 插入操作记录
  6539. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  6540. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6541. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  6542. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  6543. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6544. oper.F_Message = userinfo + " 交办了工单,主办单位:" + deptinfo.F_DeptName;
  6545. if (!string.IsNullOrEmpty(otherdeptids))
  6546. {
  6547. string sql = "select dbo.GetDeptNames('" + otherdeptids + "')";
  6548. oper.F_Message += ",协办单位:" + DbHelperSQL.GetSingle(sql);
  6549. }
  6550. oper.F_CreateUser = userModel.F_UserCode;
  6551. oper.F_CreateTime = DateTime.Now;
  6552. oper.F_IsDelete = 0;
  6553. operBLL.Add(oper);
  6554. //推送消息表
  6555. var users = userBLL.GetModelList(" F_DeptId='" + deptinfo.F_DeptId + "' ");
  6556. foreach (var u in users)
  6557. {
  6558. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6559. }
  6560. #endregion
  6561. }
  6562. trans.Complete();
  6563. }
  6564. return Success("操作成功", modelT_Bus_AssignedInfo.F_Id);
  6565. }
  6566. else
  6567. {
  6568. return Error("已经交办过了");
  6569. }
  6570. }
  6571. else
  6572. {
  6573. return Error("操作失败");
  6574. }
  6575. }
  6576. else
  6577. {
  6578. return Error("权限不足");
  6579. }
  6580. }
  6581. [Authority]
  6582. public ActionResult AssignWorkOrderNew()
  6583. {
  6584. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6585. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6586. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  6587. {
  6588. string workorderid = RequestString.GetFormString("workorderid");
  6589. int state = RequestString.GetInt("state", 0);
  6590. int assignid = RequestString.GetInt("assignid", 0);
  6591. string maindeptid = RequestString.GetFormString("maindeptid");
  6592. string otherdeptids = RequestString.GetFormString("otherdeptids");
  6593. DateTime limittime = DateTime.Parse(RequestString.GetFormString("limittime") + " 23:59:59");
  6594. string assignedopinion = RequestString.GetFormString("assignedopinion");
  6595. var modelT_Bus_AssignedInfoLasts = assignBLL.GetList(0, $" F_WorkOrderId='{workorderid}' and F_IsDelete='0' and F_State='1' ", " F_CreateTime desc").Tables[0];
  6596. if (modelT_Bus_AssignedInfoLasts.Rows.Count > 0)
  6597. {
  6598. if (modelT_Bus_AssignedInfoLasts.Rows[0]["F_CreateUser"].ToString() != userModel.F_UserCode)
  6599. {
  6600. return Error("操作失败");
  6601. }
  6602. }
  6603. if (!string.IsNullOrEmpty(otherdeptids))
  6604. {
  6605. var both = otherdeptids.Split(',').Intersect(maindeptid.Split(','));
  6606. if (both.Count()>0)
  6607. //if (otherdeptids.Split(',').Contains(maindeptid.ToString()))
  6608. {
  6609. return Error("主办单位不能出现在协办单位");
  6610. }
  6611. }
  6612. if (limittime < DateTime.Now)
  6613. {
  6614. return Error("办理时限不能小于当前时间");
  6615. }
  6616. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  6617. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6618. Model.T_Bus_WorkOrder tempT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6619. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = new Model.T_Bus_AssignedInfo();
  6620. var deptlist = new BLL.T_Sys_Department().GetModelList("F_DeptId in (" + maindeptid+")");
  6621. if (modelT_Bus_WorkOrder != null && deptlist != null&& deptlist.Count>0)
  6622. {
  6623. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  6624. {
  6625. int aid = 0; var rre = "";
  6626. using (TransactionScope trans = new TransactionScope())
  6627. {
  6628. if (deptlist.Count == 1)
  6629. {
  6630. var deptinfo = deptlist.FirstOrDefault();
  6631. if (assignid == 0)
  6632. {
  6633. #region 插入交办记录
  6634. modelT_Bus_AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6635. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  6636. modelT_Bus_AssignedInfo.F_MainDeptId = deptinfo.F_DeptId;//主办单位id
  6637. modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  6638. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  6639. modelT_Bus_AssignedInfo.F_State = state;//0草稿 1正式
  6640. modelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  6641. modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  6642. modelT_Bus_AssignedInfo.F_IsDelete = 0;
  6643. modelT_Bus_AssignedInfo.F_IsOverdue = 0;
  6644. modelT_Bus_AssignedInfo.F_IsSure = 0;
  6645. modelT_Bus_AssignedInfo.F_IsReload = 0;
  6646. modelT_Bus_AssignedInfo.F_IsNext = 0;
  6647. modelT_Bus_AssignedInfo.F_TimeResp = assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
  6648. aid = assignBLL.Add(modelT_Bus_AssignedInfo);
  6649. #endregion
  6650. }
  6651. else
  6652. {
  6653. #region 修改交办记录
  6654. modelT_Bus_AssignedInfo = assignBLL.GetModel(assignid);
  6655. if (modelT_Bus_AssignedInfo != null)
  6656. {
  6657. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  6658. modelT_Bus_AssignedInfo.F_MainDeptId = deptinfo.F_DeptId;//主办单位id
  6659. modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  6660. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  6661. modelT_Bus_AssignedInfo.F_TimeResp = assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
  6662. modelT_Bus_AssignedInfo.F_State = state;//0草稿 1正式
  6663. modelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  6664. modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  6665. assignBLL.Update(modelT_Bus_AssignedInfo);
  6666. aid = modelT_Bus_AssignedInfo.F_Id;
  6667. }
  6668. #endregion
  6669. }
  6670. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_State == 1)
  6671. {
  6672. #region 保存工单信息
  6673. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.receive;//待查收
  6674. modelT_Bus_WorkOrder.F_LimitTime = limittime;
  6675. modelT_Bus_WorkOrder.F_MainDeptId = deptinfo.F_DeptId;
  6676. modelT_Bus_WorkOrder.F_OtherDeptIds = otherdeptids;
  6677. modelT_Bus_WorkOrder.F_AssignUser = userModel.F_UserCode;
  6678. modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
  6679. workorderBLL.Update(modelT_Bus_WorkOrder);
  6680. #endregion
  6681. #region 删除草稿信息
  6682. var cglist = assignBLL.GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  6683. foreach (var cg in cglist)
  6684. {
  6685. cg.F_IsDelete = 1;
  6686. cg.F_DeleteUser = userModel.F_UserCode;
  6687. cg.F_DeleteTime = DateTime.Now;
  6688. assignBLL.Update(cg);
  6689. }
  6690. #endregion
  6691. #region 插入操作记录
  6692. var msgss = userinfo + " 交办了工单,主办单位:" + deptinfo.F_DeptName;
  6693. if (!string.IsNullOrEmpty(otherdeptids))
  6694. {
  6695. string sql = "select dbo.GetDeptNames('" + otherdeptids + "')";
  6696. msgss += ",协办单位:" + DbHelperSQL.GetSingle(sql);
  6697. }
  6698. addoptlog(modelT_Bus_WorkOrder.F_WorkOrderId, modelT_Bus_WorkOrder.F_WorkState, modelT_Bus_AssignedInfo.F_Id, msgss, userModel.F_UserCode);
  6699. //推送消息表
  6700. var users = userBLL.GetModelList(" F_DeptId='" + deptinfo.F_DeptId + "' ");
  6701. foreach (var u in users)
  6702. {
  6703. msg.AddInternalMessagesInfo("工单消息", msgss + ",工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6704. }
  6705. #endregion
  6706. }
  6707. }
  6708. else
  6709. {
  6710. string newids = ""; string errdeptid = ""; string deptname = "";
  6711. foreach (var deptinfo in deptlist)
  6712. {
  6713. deptname += deptinfo.F_DeptName + ",";
  6714. #region 新增工单
  6715. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder1 = new Model.T_Bus_WorkOrder();
  6716. modelT_Bus_WorkOrder1 = tempT_Bus_WorkOrder;
  6717. modelT_Bus_WorkOrder1.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(modelT_Bus_WorkOrder.F_CreateUser);
  6718. modelT_Bus_WorkOrder1.F_Id = workorderBLL.Add(modelT_Bus_WorkOrder1);
  6719. if (modelT_Bus_WorkOrder1.F_Id <= 0)
  6720. {
  6721. errdeptid += deptinfo.F_DeptName + ",";
  6722. continue;
  6723. }
  6724. #endregion
  6725. #region 交办
  6726. #region 插入交办记录
  6727. modelT_Bus_AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder1.F_WorkOrderId;
  6728. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  6729. modelT_Bus_AssignedInfo.F_MainDeptId = deptinfo.F_DeptId;//主办单位id
  6730. modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  6731. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  6732. modelT_Bus_AssignedInfo.F_TimeResp = assignBLL.GetRepTimly(DateTime.Now);//及时查收时间点
  6733. modelT_Bus_AssignedInfo.F_State = state;//0草稿 1正式
  6734. modelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  6735. modelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  6736. modelT_Bus_AssignedInfo.F_IsDelete = 0;
  6737. modelT_Bus_AssignedInfo.F_IsOverdue = 0;
  6738. modelT_Bus_AssignedInfo.F_IsSure = 0;
  6739. modelT_Bus_AssignedInfo.F_IsReload = 0;
  6740. modelT_Bus_AssignedInfo.F_IsNext = 0;
  6741. aid = assignBLL.Add(modelT_Bus_AssignedInfo);
  6742. #endregion
  6743. #endregion
  6744. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_State == 1)
  6745. {
  6746. #region 保存工单信息
  6747. modelT_Bus_WorkOrder1.F_WorkState = (int)EnumWorkState.receive;//待查收
  6748. modelT_Bus_WorkOrder1.F_LimitTime = limittime;
  6749. modelT_Bus_WorkOrder1.F_MainDeptId = deptinfo.F_DeptId;
  6750. modelT_Bus_WorkOrder1.F_OtherDeptIds = otherdeptids;
  6751. modelT_Bus_WorkOrder1.F_AssignUser = userModel.F_UserCode;
  6752. modelT_Bus_WorkOrder1.F_AssignTime = DateTime.Now;
  6753. workorderBLL.Update(modelT_Bus_WorkOrder1);
  6754. #endregion
  6755. #region 删除草稿信息
  6756. var cglist = assignBLL.GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder1.F_WorkOrderId + "'");
  6757. foreach (var cg in cglist)
  6758. {
  6759. cg.F_IsDelete = 1;
  6760. cg.F_DeleteUser = userModel.F_UserCode;
  6761. cg.F_DeleteTime = DateTime.Now;
  6762. assignBLL.Update(cg);
  6763. }
  6764. #endregion
  6765. #region 插入操作记录
  6766. var msgss = userinfo + " 交办了工单,主办单位:" + deptinfo.F_DeptName;
  6767. if (!string.IsNullOrEmpty(otherdeptids))
  6768. {
  6769. string sql = "select dbo.GetDeptNames('" + otherdeptids + "')";
  6770. msgss += ",协办单位:" + DbHelperSQL.GetSingle(sql);
  6771. }
  6772. addoptlog(modelT_Bus_WorkOrder1.F_WorkOrderId, modelT_Bus_WorkOrder1.F_WorkState, modelT_Bus_AssignedInfo.F_Id, msgss, userModel.F_UserCode);
  6773. //推送消息表
  6774. var users = userBLL.GetModelList(" F_DeptId='" + deptinfo.F_DeptId + "' ");
  6775. foreach (var u in users)
  6776. {
  6777. msg.AddInternalMessagesInfo("工单消息", msgss + ",工单编号:" + modelT_Bus_WorkOrder1.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  6778. }
  6779. #endregion
  6780. }
  6781. newids += modelT_Bus_WorkOrder1.F_WorkOrderId + ",";
  6782. }
  6783. newids = newids.Trim(','); deptname = deptname.Trim(',');
  6784. var msgs = "";
  6785. if (errdeptid == "")
  6786. {
  6787. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;//待查收
  6788. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  6789. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  6790. workorderBLL.Update(modelT_Bus_WorkOrder);
  6791. msgs = userinfo + " 交办多单位,关闭此工单并生成新工单,新工单编号为:" + newids;
  6792. }
  6793. else
  6794. {
  6795. errdeptid = errdeptid.Trim(',');
  6796. msgs = userinfo + " 交办的单位有" + deptname + ",部分操作成功,新工单编号为:" + newids + ",交办失败的部门为:" + errdeptid;
  6797. }
  6798. #region 插入操作记录
  6799. addoptlog(modelT_Bus_WorkOrder.F_WorkOrderId, modelT_Bus_WorkOrder.F_WorkState, modelT_Bus_AssignedInfo.F_Id, msgs, userModel.F_UserCode);
  6800. #endregion
  6801. }
  6802. trans.Complete();
  6803. #region
  6804. if (("," + maindeptid + ",").Contains(",304,"))
  6805. {
  6806. var conname = modelT_Bus_WorkOrder.F_CusName; var conphone = modelT_Bus_WorkOrder.F_ConPhone;
  6807. if(modelT_Bus_WorkOrder.F_IsProtect==1)
  6808. {
  6809. conphone = "保密";
  6810. conname= "保密";
  6811. }
  6812. rre = new ShangQiuWorkOrderController().SendToGrdding(modelT_Bus_AssignedInfo.F_Id, workorderid, modelT_Bus_WorkOrder.F_ComTitle, modelT_Bus_WorkOrder.F_ComContent, modelT_Bus_WorkOrder.F_SourceAddress, conphone, conname, modelT_Bus_WorkOrder.F_File, userModel.F_UserCode, modelT_Bus_WorkOrder.F_InfoType.Value,modelT_Bus_WorkOrder.F_Latitude.ToString(),modelT_Bus_WorkOrder.F_Longitude.ToString()).ToString();
  6813. }
  6814. #endregion
  6815. }
  6816. return Success("操作成功"+ rre, modelT_Bus_AssignedInfo.F_Id);
  6817. }
  6818. else
  6819. {
  6820. return Error("已经交办过了");
  6821. }
  6822. }
  6823. else
  6824. {
  6825. return Error("操作失败");
  6826. }
  6827. }
  6828. else
  6829. {
  6830. return Error("权限不足");
  6831. }
  6832. }
  6833. /// <summary>
  6834. /// 工单提醒
  6835. /// </summary>
  6836. /// <param name="workordercode"></param>
  6837. /// <param name="deptid"></param>
  6838. /// <param name="type"></param>
  6839. /// <returns></returns>
  6840. [HttpPost]
  6841. public ActionResult SendSms(string workordercode,int deptid,int type=0)
  6842. {
  6843. if (deptid <= 0)
  6844. return Error("请选择部门");
  6845. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6846. string msg = "";
  6847. var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId=" + deptid + "and F_DeleteFlag=0");
  6848. if (user !=null )
  6849. {
  6850. foreach (var it in user)
  6851. {
  6852. if (!string .IsNullOrEmpty (it .F_Mobile))
  6853. {
  6854. string count = "";
  6855. string templetid = "";
  6856. if (type ==0)
  6857. {
  6858. templetid = "26157";
  6859. count = "您有新的工单,请及时查收处理,工单编号" + workordercode;
  6860. }
  6861. else if (type == 1)
  6862. {
  6863. templetid = "26155";
  6864. count = "您有工单正在被督办,请及时处理,工单编号" + workordercode;
  6865. }
  6866. else if (type == 2)
  6867. {
  6868. templetid = "26154";
  6869. count = "您有紧急工单,请及时处理,工单编号" + workordercode;
  6870. }
  6871. else
  6872. {
  6873. templetid = "29265";
  6874. count = "您有工单已经超时,请尽快处理,工单编号" + workordercode;
  6875. }
  6876. bool n = SMSController.AddSmS(userId, count, workordercode, it.F_Mobile, templetid);
  6877. if (n == false)
  6878. msg += it.F_UserName + "发送短信失败。";
  6879. }
  6880. }
  6881. if (msg != "")
  6882. return Error(msg);
  6883. else
  6884. return Success("发送成功");
  6885. }
  6886. else
  6887. {
  6888. return Error("暂无人员");
  6889. }
  6890. }
  6891. /// <summary>
  6892. /// 办理结果通知
  6893. /// </summary>
  6894. /// <param name="msg1"></param>
  6895. /// <param name="msg2"></param>
  6896. /// <param name="msg3"></param>
  6897. /// <param name="msg4"></param>
  6898. /// <param name="mobile"></param>
  6899. /// <returns></returns>
  6900. public ActionResult SmsHand(string msg1 , string msg2 , string msg3,string msg4,string mobile)
  6901. {
  6902. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6903. string msg = msg1+","+ msg2 + "," + msg3 + "," + msg4;
  6904. string count = "尊敬的市民,您于" + msg1 + "反映的" + msg2 + "问题,工单号:" + msg3 + ",处理结果如下:" + msg4 + "。如有异议,请您再次致电12345,感谢您的支持。";
  6905. bool n = SMSController.AddSmS(userId, count, msg, mobile, "26213");
  6906. if (n)
  6907. return Success("发送成功");
  6908. else
  6909. return Error ("发送失败");
  6910. }
  6911. public ActionResult SmsOverTime()
  6912. {
  6913. var workorder = new BLL.T_Bus_WorkOrder().GetModelList("F_IsDelete=0 and F_WorkState in (2,4) and (F_IsSms!=1 or F_IsSms is null)");
  6914. if (workorder != null)
  6915. {
  6916. foreach (var it in workorder)
  6917. {
  6918. System.TimeSpan time = DateTime.Parse(it.F_LimitTime.ToString()) - DateTime.Now ;
  6919. if (time.TotalHours <=6)
  6920. {
  6921. var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId=" + it.F_MainDeptId + "and F_DeleteFlag=0");
  6922. if (user != null)
  6923. {
  6924. foreach (var iv in user)
  6925. {
  6926. if (!string.IsNullOrEmpty(iv.F_Mobile))
  6927. {
  6928. string count = " 您有工单6小时后超期,请及时处理,工单号" + it.F_WorkOrderId;
  6929. bool n = SMSController.AddSmS(0, count, it.F_WorkOrderId, iv.F_Mobile, "26147");
  6930. if (n )
  6931. {
  6932. it.F_IsSms = 1;
  6933. bool t = new BLL.T_Bus_WorkOrder().Update(it);
  6934. }
  6935. }
  6936. }
  6937. }
  6938. }
  6939. }
  6940. }
  6941. return Success("发送成功");
  6942. }
  6943. /// <summary>
  6944. /// 收回工单
  6945. /// </summary>
  6946. /// <returns></returns>
  6947. [Authority]
  6948. public ActionResult TakeBackWorkOrder()
  6949. {
  6950. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  6951. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  6952. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  6953. {
  6954. string workorderid = RequestString.GetFormString("workorderid");
  6955. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  6956. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  6957. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null)
  6958. {
  6959. if (modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  6960. {
  6961. return Error("操作失败");
  6962. }
  6963. //if (modelT_Bus_AssignedInfo.F_IsSure == 0 || (modelT_Bus_AssignedInfo.F_IsSure == 1 && modelT_Bus_WorkOrder.F_WorkState == 4))
  6964. if (modelT_Bus_AssignedInfo.F_IsSure == 0 || (modelT_Bus_AssignedInfo.F_IsSure == 1 && modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing))
  6965. {
  6966. using (TransactionScope trans = new TransactionScope())
  6967. {
  6968. #region 插入交办记录
  6969. Model.T_Bus_AssignedInfo AssignedInfo = new Model.T_Bus_AssignedInfo();
  6970. AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  6971. AssignedInfo.F_LimitTime = modelT_Bus_AssignedInfo.F_LimitTime;//办理时限
  6972. AssignedInfo.F_MainDeptId = modelT_Bus_AssignedInfo.F_MainDeptId;//主办单位id
  6973. AssignedInfo.F_OtherDeptIds = modelT_Bus_AssignedInfo.F_OtherDeptIds;//协办单位id
  6974. AssignedInfo.F_AssignedOpinion = modelT_Bus_AssignedInfo.F_AssignedOpinion;//交办意见
  6975. AssignedInfo.F_State = 0;//0草稿 1正式
  6976. AssignedInfo.F_CreateUser = modelT_Bus_AssignedInfo.F_CreateUser;
  6977. AssignedInfo.F_CreateTime = modelT_Bus_AssignedInfo.F_CreateTime;
  6978. AssignedInfo.F_IsDelete = 0;
  6979. AssignedInfo.F_IsOverdue = 0;
  6980. AssignedInfo.F_IsSure = 0;
  6981. AssignedInfo.F_IsReload = 0;
  6982. AssignedInfo.F_IsNext = 0;
  6983. assignBLL.Add(AssignedInfo);
  6984. #endregion
  6985. #region 保存工单信息
  6986. //modelT_Bus_WorkOrder.F_WorkState = 1;//待交办
  6987. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;//待交办
  6988. modelT_Bus_WorkOrder.F_MainDeptId = null;
  6989. modelT_Bus_WorkOrder.F_OtherDeptIds = "";
  6990. workorderBLL.Update(modelT_Bus_WorkOrder);
  6991. #endregion
  6992. #region 删除交办信息
  6993. modelT_Bus_AssignedInfo.F_IsDelete = 1;//删除
  6994. modelT_Bus_AssignedInfo.F_DeleteUser = userModel.F_UserCode;
  6995. modelT_Bus_AssignedInfo.F_DeleteTime = DateTime.Now;
  6996. assignBLL.Update(modelT_Bus_AssignedInfo);
  6997. #endregion
  6998. #region 删除派单信息
  6999. var pdlist = new BLL.T_Bus_AssignedInfo_Next().GetModelList(" F_IsDelete=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' ");
  7000. foreach (var cg in pdlist)
  7001. {
  7002. cg.F_IsDelete = 1;
  7003. cg.F_DeleteUser = userModel.F_UserCode;
  7004. cg.F_DeleteTime = DateTime.Now;
  7005. new BLL.T_Bus_AssignedInfo_Next().Update(cg);
  7006. }
  7007. #endregion
  7008. #region 删除二级单位处理信息
  7009. var cglist = new BLL.T_Bus_Feedback_Next().GetModelList(" F_IsDelete=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' ");
  7010. foreach (var cg in cglist)
  7011. {
  7012. cg.F_IsDelete = 1;
  7013. cg.F_DeleteUser = userModel.F_UserCode;
  7014. cg.F_DeleteTime = DateTime.Now;
  7015. new BLL.T_Bus_Feedback_Next().Update(cg);
  7016. }
  7017. #endregion
  7018. #region 插入操作记录
  7019. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7020. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7021. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7022. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7023. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7024. oper.F_Message = userinfo + " 收回了工单";
  7025. oper.F_CreateUser = userModel.F_UserCode;
  7026. oper.F_CreateTime = DateTime.Now;
  7027. oper.F_IsDelete = 0;
  7028. operBLL.Add(oper);
  7029. #endregion
  7030. trans.Complete();
  7031. }
  7032. return Success("操作成功");
  7033. }
  7034. else
  7035. {
  7036. return Error("单位已查收,不能收回");
  7037. }
  7038. }
  7039. else
  7040. {
  7041. return Error("操作失败");
  7042. }
  7043. }
  7044. else
  7045. {
  7046. return Error("权限不足");
  7047. }
  7048. }
  7049. /// <summary>
  7050. /// 查收工单
  7051. /// </summary>
  7052. /// <returns></returns>
  7053. [Authority]
  7054. public ActionResult ReceiveWorkOrder()
  7055. {
  7056. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7057. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7058. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7059. {
  7060. string workorderid = RequestString.GetFormString("workorderid");
  7061. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7062. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7063. //操作前新增判断状态
  7064. //if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7065. if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState==(int)EnumWorkState.receive|| modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.reload) && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7066. {
  7067. if (modelT_Bus_AssignedInfo.F_IsSure == 0)
  7068. {
  7069. using (TransactionScope trans = new TransactionScope())
  7070. {
  7071. #region 保存工单信息
  7072. //modelT_Bus_WorkOrder.F_WorkState = 4;//办理中
  7073. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealing;//办理中
  7074. workorderBLL.Update(modelT_Bus_WorkOrder);
  7075. #endregion
  7076. #region 保存查收信息
  7077. modelT_Bus_AssignedInfo.F_IsSure = 1;//查收
  7078. modelT_Bus_AssignedInfo.F_SureUser = userModel.F_UserCode;
  7079. modelT_Bus_AssignedInfo.F_SureTime = DateTime.Now;
  7080. assignBLL.Update(modelT_Bus_AssignedInfo);
  7081. #endregion
  7082. #region 保存明细信息
  7083. if (!string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_OtherDeptIds))
  7084. {
  7085. string[] strids = modelT_Bus_AssignedInfo.F_OtherDeptIds.Split(',');
  7086. foreach (string strid in strids)
  7087. {
  7088. Model.T_Bus_AssignedItemInfo modelT_Bus_AssignedItemInfo = new Model.T_Bus_AssignedItemInfo();
  7089. modelT_Bus_AssignedItemInfo.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7090. modelT_Bus_AssignedItemInfo.F_AssignedOpinion = modelT_Bus_AssignedInfo.F_AssignedOpinion;
  7091. modelT_Bus_AssignedItemInfo.F_DeptId = Int32.Parse(strid);
  7092. modelT_Bus_AssignedItemInfo.F_LimitTime = modelT_Bus_AssignedInfo.F_LimitTime;
  7093. modelT_Bus_AssignedItemInfo.F_Remark = modelT_Bus_AssignedInfo.F_Remark;
  7094. modelT_Bus_AssignedItemInfo.F_State = 1;
  7095. modelT_Bus_AssignedItemInfo.F_Type = 2;
  7096. modelT_Bus_AssignedItemInfo.F_WorkOrderId = modelT_Bus_AssignedInfo.F_WorkOrderId;
  7097. modelT_Bus_AssignedItemInfo.F_IsSure = 0;
  7098. modelT_Bus_AssignedItemInfo.F_CreateTime = DateTime.Now;
  7099. modelT_Bus_AssignedItemInfo.F_CreateUser = userModel.F_UserCode;
  7100. modelT_Bus_AssignedItemInfo.F_IsDelete = 0;
  7101. new BLL.T_Bus_AssignedItemInfo().Add(modelT_Bus_AssignedItemInfo);
  7102. }
  7103. }
  7104. #endregion
  7105. #region 插入操作记录
  7106. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7107. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7108. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7109. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7110. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7111. oper.F_Message = userinfo + " 查收了工单";
  7112. oper.F_CreateUser = userModel.F_UserCode;
  7113. oper.F_CreateTime = DateTime.Now;
  7114. oper.F_IsDelete = 0;
  7115. operBLL.Add(oper);
  7116. #endregion
  7117. trans.Complete();
  7118. }
  7119. return Success("操作成功");
  7120. }
  7121. else
  7122. {
  7123. return Error("单位已查收,不能再次查收");
  7124. }
  7125. }
  7126. else
  7127. {
  7128. return Error("操作失败");
  7129. }
  7130. }
  7131. else
  7132. {
  7133. return Error("权限不足");
  7134. }
  7135. }
  7136. /// <summary>
  7137. /// 退回工单
  7138. /// </summary>
  7139. /// <returns></returns>
  7140. [Authority]
  7141. public ActionResult RebackWorkOrder()
  7142. {
  7143. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7144. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7145. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7146. {
  7147. string workorderid = RequestString.GetFormString("workorderid");
  7148. string backreason = RequestString.GetFormString("backreason");
  7149. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7150. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7151. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7152. {
  7153. if (modelT_Bus_AssignedInfo.F_IsSure == 0)
  7154. {
  7155. using (TransactionScope trans = new TransactionScope())
  7156. {
  7157. #region 保存工单信息
  7158. //modelT_Bus_WorkOrder.F_WorkState = 3;//退回审核中
  7159. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.auditreback;//退回审核中
  7160. workorderBLL.Update(modelT_Bus_WorkOrder);
  7161. #endregion
  7162. #region 插入退回申请信息
  7163. Model.T_Bus_Feedback model_T_Bus_Feedback = new Model.T_Bus_Feedback();
  7164. model_T_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  7165. model_T_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  7166. model_T_Bus_Feedback.F_Result = backreason;//退回原因
  7167. model_T_Bus_Feedback.F_IsAudit = 0;
  7168. model_T_Bus_Feedback.F_IsDelete = 0;
  7169. model_T_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//退回人
  7170. model_T_Bus_Feedback.F_CreateTime = DateTime.Now;//退回时间
  7171. model_T_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//退回部门
  7172. model_T_Bus_Feedback.F_IsFeedEnd = 1;
  7173. model_T_Bus_Feedback.F_State = 1;
  7174. model_T_Bus_Feedback.F_Type = 3;
  7175. new BLL.T_Bus_Feedback().Add(model_T_Bus_Feedback);
  7176. #endregion
  7177. #region 保存交办信息
  7178. //modelT_Bus_AssignedInfo.F_FeedbackTime = DateTime.Now;//办理
  7179. //if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  7180. //{
  7181. // modelT_Bus_AssignedInfo.F_IsOverdue = 1;
  7182. //}
  7183. modelT_Bus_AssignedInfo.F_IsSure = 2;//申请退回
  7184. modelT_Bus_AssignedInfo.F_SureUser = userModel.F_UserCode;
  7185. modelT_Bus_AssignedInfo.F_SureTime = DateTime.Now;
  7186. assignBLL.Update(modelT_Bus_AssignedInfo);
  7187. #endregion
  7188. #region 插入操作记录
  7189. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7190. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7191. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7192. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7193. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7194. oper.F_Message = userinfo + " 申请退回了工单";
  7195. oper.F_CreateUser = userModel.F_UserCode;
  7196. oper.F_CreateTime = DateTime.Now;
  7197. oper.F_IsDelete = 0;
  7198. operBLL.Add(oper);
  7199. //推送消息表
  7200. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_AssignedInfo.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7201. #endregion
  7202. trans.Complete();
  7203. }
  7204. return Success("操作成功");
  7205. }
  7206. else
  7207. {
  7208. return Error("单位已查收,不能退回");
  7209. }
  7210. }
  7211. else
  7212. {
  7213. return Error("操作失败");
  7214. }
  7215. }
  7216. else
  7217. {
  7218. return Error("权限不足");
  7219. }
  7220. }
  7221. /// <summary>
  7222. /// 审核退回工单
  7223. /// </summary>
  7224. /// <returns></returns>
  7225. [Authority]
  7226. public ActionResult AuditRebackWorkOrder()
  7227. {
  7228. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7229. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7230. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7231. {
  7232. string workorderid = RequestString.GetFormString("workorderid");
  7233. int state = RequestString.GetInt("state", 0);
  7234. string reason = RequestString.GetFormString("reason");
  7235. int rebackid = RequestString.GetInt("rebackid", 0);
  7236. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7237. Model.T_Bus_Feedback modelT_Bus_Feedback = new BLL.T_Bus_Feedback().GetModel(rebackid);
  7238. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7239. if (modelT_Bus_WorkOrder != null && modelT_Bus_Feedback != null && modelT_Bus_AssignedInfo != null)
  7240. {
  7241. if (modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  7242. {
  7243. return Error("操作失败");
  7244. }
  7245. if (modelT_Bus_Feedback.F_Type == 3 && modelT_Bus_Feedback.F_IsAudit == 0)
  7246. {
  7247. using (TransactionScope trans = new TransactionScope())
  7248. {
  7249. var rre = "";
  7250. #region 保存查收信息
  7251. modelT_Bus_Feedback.F_IsAudit = state;//审核
  7252. modelT_Bus_Feedback.F_AuditUser = userModel.F_UserCode;
  7253. modelT_Bus_Feedback.F_AuditTime = DateTime.Now;
  7254. modelT_Bus_Feedback.F_AuditReason = reason;
  7255. new BLL.T_Bus_Feedback().Update(modelT_Bus_Feedback);
  7256. #endregion
  7257. string strmsg = "同意";
  7258. if (modelT_Bus_Feedback.F_IsAudit == 1)
  7259. {
  7260. #region 插入交办记录
  7261. Model.T_Bus_AssignedInfo AssignedInfo = new Model.T_Bus_AssignedInfo();
  7262. AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7263. AssignedInfo.F_LimitTime = modelT_Bus_AssignedInfo.F_LimitTime;//办理时限
  7264. AssignedInfo.F_MainDeptId = modelT_Bus_AssignedInfo.F_MainDeptId;//主办单位id
  7265. AssignedInfo.F_OtherDeptIds = modelT_Bus_AssignedInfo.F_OtherDeptIds;//协办单位id
  7266. AssignedInfo.F_AssignedOpinion = modelT_Bus_AssignedInfo.F_AssignedOpinion;//交办意见
  7267. AssignedInfo.F_State = 0;//0草稿 1正式
  7268. AssignedInfo.F_CreateUser = modelT_Bus_AssignedInfo.F_CreateUser;
  7269. AssignedInfo.F_CreateTime = modelT_Bus_AssignedInfo.F_CreateTime;
  7270. AssignedInfo.F_IsDelete = 0;
  7271. AssignedInfo.F_IsOverdue = 0;
  7272. AssignedInfo.F_IsSure = 0;
  7273. AssignedInfo.F_IsNext = 0;
  7274. AssignedInfo.F_IsReload = modelT_Bus_AssignedInfo.F_IsReload;
  7275. assignBLL.Add(AssignedInfo);
  7276. #endregion
  7277. #region 保存交办信息
  7278. modelT_Bus_AssignedInfo.F_IsSure = 3;//退回
  7279. assignBLL.Update(modelT_Bus_AssignedInfo);
  7280. #endregion
  7281. #region 保存工单信息
  7282. //modelT_Bus_WorkOrder.F_WorkState = 1;//待交办
  7283. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.submit;//待交办
  7284. workorderBLL.Update(modelT_Bus_WorkOrder);
  7285. #endregion
  7286. }
  7287. else
  7288. {
  7289. #region 保存工单信息
  7290. //modelT_Bus_WorkOrder.F_WorkState = 2;//待查收
  7291. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.receive;//待查收
  7292. workorderBLL.Update(modelT_Bus_WorkOrder);
  7293. #endregion
  7294. #region 保存交办信息
  7295. //modelT_Bus_AssignedInfo.F_FeedbackTime = null;//反馈时间
  7296. modelT_Bus_AssignedInfo.F_IsSure = 0;
  7297. modelT_Bus_AssignedInfo.F_SureUser = "";
  7298. modelT_Bus_AssignedInfo.F_SureTime = null;
  7299. assignBLL.Update(modelT_Bus_AssignedInfo);
  7300. #endregion
  7301. strmsg = "拒绝";
  7302. }
  7303. #region 插入操作记录
  7304. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7305. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7306. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7307. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7308. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7309. oper.F_Message = userinfo + " " + strmsg + "了工单退回申请";
  7310. oper.F_CreateUser = userModel.F_UserCode;
  7311. oper.F_CreateTime = DateTime.Now;
  7312. oper.F_IsDelete = 0;
  7313. operBLL.Add(oper);
  7314. //推送消息表
  7315. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_Feedback.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7316. #endregion
  7317. if (modelT_Bus_AssignedInfo.F_MainDeptId==304)
  7318. {
  7319. rre = new ShangQiuWorkOrderController().AuditRebackToGrdding(workorderid, state.ToString(),reason,userModel.F_UserCode).ToString();
  7320. }
  7321. trans.Complete();
  7322. }
  7323. return Success("操作成功");
  7324. }
  7325. else
  7326. {
  7327. return Error("此审核已经处理");
  7328. }
  7329. }
  7330. else
  7331. {
  7332. return Error("操作失败");
  7333. }
  7334. }
  7335. else
  7336. {
  7337. return Error("权限不足");
  7338. }
  7339. }
  7340. /// <summary>
  7341. /// 申请延时
  7342. /// </summary>
  7343. /// <returns></returns>
  7344. [Authority]
  7345. public ActionResult DelayWorkOrder()
  7346. {
  7347. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7348. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7349. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7350. {
  7351. string workorderid = RequestString.GetFormString("workorderid");
  7352. //int state = RequestString.GetInt("state", 0);
  7353. DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime") + " 23:59:59");
  7354. string reason = RequestString.GetFormString("reason");
  7355. string files = RequestString.GetFormString("files");
  7356. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7357. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7358. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7359. {
  7360. if (modelT_Bus_AssignedInfo.F_IsSure == 1)
  7361. {
  7362. using (TransactionScope trans = new TransactionScope())
  7363. {
  7364. #region 保存工单信息
  7365. //modelT_Bus_WorkOrder.F_WorkState = 5;//延时审核中
  7366. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.auditdelay;//延时审核中
  7367. workorderBLL.Update(modelT_Bus_WorkOrder);
  7368. #endregion
  7369. #region 插入申请延时信息
  7370. Model.T_Bus_DelayTime delay = new Model.T_Bus_DelayTime();
  7371. delay.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7372. //delay.F_State = state;
  7373. delay.F_OldTime = modelT_Bus_AssignedInfo.F_LimitTime;
  7374. delay.F_NewTime = newlimittime;
  7375. delay.F_Reason = reason;
  7376. delay.F_State = 1;
  7377. delay.F_IsAudit = 0;
  7378. delay.F_IsDelete = 0;
  7379. delay.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7380. delay.F_CreateUser = userModel.F_UserCode;
  7381. delay.F_CreateTime = DateTime.Now;
  7382. delay.F_File = files;
  7383. new BLL.T_Bus_DelayTime().Add(delay);
  7384. #endregion
  7385. #region 插入操作记录
  7386. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7387. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7388. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7389. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7390. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7391. oper.F_Message = userinfo + " 申请了延时处理";
  7392. oper.F_CreateUser = userModel.F_UserCode;
  7393. oper.F_CreateTime = DateTime.Now;
  7394. oper.F_IsDelete = 0;
  7395. operBLL.Add(oper);
  7396. //推送消息表
  7397. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_AssignedInfo.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7398. #endregion
  7399. trans.Complete();
  7400. }
  7401. return Success("操作成功");
  7402. }
  7403. else
  7404. {
  7405. return Error("操作失敗,已查收");
  7406. }
  7407. }
  7408. else
  7409. {
  7410. return Error("操作失败");
  7411. }
  7412. }
  7413. else
  7414. {
  7415. return Error("权限不足");
  7416. }
  7417. }
  7418. /// <summary>
  7419. /// 审核延时工单
  7420. /// </summary>
  7421. /// <returns></returns>
  7422. [Authority]
  7423. public ActionResult AuditDelayWorkOrder()
  7424. {
  7425. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7426. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7427. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7428. {
  7429. string workorderid = RequestString.GetFormString("workorderid");
  7430. int state = RequestString.GetInt("state", 0);
  7431. string reason = RequestString.GetFormString("reason");
  7432. DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime") + " 23:59:59");
  7433. int delayid = RequestString.GetInt("delayid", 0);
  7434. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7435. Model.T_Bus_DelayTime modelT_Bus_DelayTime = new BLL.T_Bus_DelayTime().GetModel(delayid);
  7436. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7437. if (modelT_Bus_WorkOrder != null && modelT_Bus_DelayTime != null && modelT_Bus_AssignedInfo != null)
  7438. {
  7439. if (modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  7440. {
  7441. return Error("操作失败");
  7442. }
  7443. if (modelT_Bus_DelayTime.F_IsAudit == 0)
  7444. {
  7445. using (TransactionScope trans = new TransactionScope())
  7446. {
  7447. #region 保存工单信息
  7448. //modelT_Bus_WorkOrder.F_WorkState = 4;//办理中
  7449. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealing;//办理中
  7450. modelT_Bus_WorkOrder.F_LimitTime = newlimittime;
  7451. workorderBLL.Update(modelT_Bus_WorkOrder);
  7452. #endregion
  7453. #region 保存审核信息
  7454. modelT_Bus_DelayTime.F_IsAudit = state;//审核
  7455. modelT_Bus_DelayTime.F_AuditUser = userModel.F_UserCode;
  7456. modelT_Bus_DelayTime.F_AuditTime = DateTime.Now;
  7457. modelT_Bus_DelayTime.F_RefuseReason = reason;
  7458. modelT_Bus_DelayTime.F_AgreeTime = newlimittime;
  7459. new BLL.T_Bus_DelayTime().Update(modelT_Bus_DelayTime);
  7460. #endregion
  7461. string type = "同意"; string des = "";
  7462. if (modelT_Bus_DelayTime.F_IsAudit == 1)
  7463. {
  7464. #region 修改交办记录
  7465. modelT_Bus_AssignedInfo.F_LimitTime = modelT_Bus_DelayTime.F_AgreeTime;
  7466. assignBLL.Update(modelT_Bus_AssignedInfo);
  7467. #endregion
  7468. #region 处理协办单位
  7469. var xblist = assignItemBLL.GetModelList(" F_IsDelete=0 and F_State=1 and ISNULL(F_FeedbackTime, '')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  7470. foreach (var xb in xblist)
  7471. {
  7472. //xb.F_LimitTime = DateTime.Now;
  7473. xb.F_LimitTime = modelT_Bus_DelayTime.F_AgreeTime;
  7474. assignItemBLL.Update(xb);
  7475. }
  7476. #endregion
  7477. des = ",原定时间" + modelT_Bus_DelayTime.F_OldTime + ",申请延长到" + modelT_Bus_DelayTime.F_AgreeTime;
  7478. }
  7479. else
  7480. {
  7481. type = "拒绝";
  7482. }
  7483. #region 插入操作记录
  7484. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7485. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7486. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7487. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7488. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7489. oper.F_Message = userinfo + " " + type + "了工单延时申请" + des;
  7490. oper.F_CreateUser = userModel.F_UserCode;
  7491. oper.F_CreateTime = DateTime.Now;
  7492. oper.F_IsDelete = 0;
  7493. operBLL.Add(oper);
  7494. //推送消息表
  7495. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_DelayTime.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7496. #endregion
  7497. trans.Complete();
  7498. }
  7499. return Success("操作成功");
  7500. }
  7501. else
  7502. {
  7503. return Error("此审核已经处理");
  7504. }
  7505. }
  7506. else
  7507. {
  7508. return Error("操作失败");
  7509. }
  7510. }
  7511. else
  7512. {
  7513. return Error("权限不足");
  7514. }
  7515. }
  7516. /// <summary>
  7517. /// 批量审核延时
  7518. /// </summary>
  7519. /// <param name="ids"></param>
  7520. /// <returns></returns>
  7521. [Authority]
  7522. public ActionResult AuditDelayWorkOrderBatch(string ids)
  7523. {
  7524. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7525. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7526. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7527. {
  7528. int state = RequestString.GetInt("state", 0);
  7529. string reason = RequestString.GetFormString("reason");
  7530. DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime") + " 23:59:59");
  7531. string errids = "";string errids1 = "";
  7532. if (!string.IsNullOrEmpty(ids))
  7533. {
  7534. string[] strids = ids.Split(',');
  7535. foreach (string str in strids)
  7536. {
  7537. using (TransactionScope trans = new TransactionScope())
  7538. {
  7539. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(str);
  7540. Model.T_Bus_DelayTime modelT_Bus_DelayTime = new BLL.T_Bus_DelayTime().GetModelList(" F_WorkOrderId = '" + str + "' and F_State = 1 and F_IsDelete = 0 and F_IsAudit = 0 order by F_CreateTime desc").FirstOrDefault();
  7541. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(str);
  7542. if (modelT_Bus_WorkOrder != null && modelT_Bus_DelayTime != null && modelT_Bus_AssignedInfo != null)
  7543. {
  7544. if (modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  7545. {
  7546. errids += str + ",";
  7547. continue;
  7548. }
  7549. if (modelT_Bus_DelayTime.F_IsAudit == 0)
  7550. {
  7551. #region 保存工单信息
  7552. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealing;//办理中
  7553. modelT_Bus_WorkOrder.F_LimitTime = newlimittime;
  7554. workorderBLL.Update(modelT_Bus_WorkOrder);
  7555. #endregion
  7556. #region 保存审核信息
  7557. modelT_Bus_DelayTime.F_IsAudit = state;//审核
  7558. modelT_Bus_DelayTime.F_AuditUser = userModel.F_UserCode;
  7559. modelT_Bus_DelayTime.F_AuditTime = DateTime.Now;
  7560. modelT_Bus_DelayTime.F_RefuseReason = reason;
  7561. modelT_Bus_DelayTime.F_AgreeTime = newlimittime;
  7562. new BLL.T_Bus_DelayTime().Update(modelT_Bus_DelayTime);
  7563. #endregion
  7564. string type = "同意"; string des = "";
  7565. if (modelT_Bus_DelayTime.F_IsAudit == 1)
  7566. {
  7567. #region 修改交办记录
  7568. modelT_Bus_AssignedInfo.F_LimitTime = modelT_Bus_DelayTime.F_AgreeTime;
  7569. assignBLL.Update(modelT_Bus_AssignedInfo);
  7570. #endregion
  7571. #region 处理协办单位
  7572. var xblist = assignItemBLL.GetModelList(" F_IsDelete=0 and F_State=1 and ISNULL(F_FeedbackTime, '')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  7573. foreach (var xb in xblist)
  7574. {
  7575. //xb.F_LimitTime = DateTime.Now;
  7576. xb.F_LimitTime = modelT_Bus_DelayTime.F_AgreeTime;
  7577. assignItemBLL.Update(xb);
  7578. }
  7579. #endregion
  7580. des = ",原定时间" + modelT_Bus_DelayTime.F_OldTime + ",申请延长到" + modelT_Bus_DelayTime.F_AgreeTime;
  7581. }
  7582. else
  7583. {
  7584. type = "拒绝";
  7585. }
  7586. #region 插入操作记录
  7587. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7588. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7589. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7590. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7591. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7592. oper.F_Message = userinfo + " " + type + "了工单延时申请" + des;
  7593. oper.F_CreateUser = userModel.F_UserCode;
  7594. oper.F_CreateTime = DateTime.Now;
  7595. oper.F_IsDelete = 0;
  7596. operBLL.Add(oper);
  7597. //推送消息表
  7598. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_DelayTime.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7599. #endregion
  7600. }
  7601. else
  7602. errids1 += str + ",";
  7603. }
  7604. trans.Complete();
  7605. }
  7606. }
  7607. if (errids1 != "" && errids != "")
  7608. return Success("操作成功");
  7609. else
  7610. {
  7611. string msg = "";
  7612. if (errids1 != "")
  7613. msg += ",工单编号为" + errids1.Trim(',') + "的工单已被其他人审核";
  7614. if(errids!="")
  7615. msg += ",工单编号为" + errids1.Trim(',') + "的工单不是交办人本人";
  7616. return Error("部分工单操作失败"+ msg);
  7617. }
  7618. }
  7619. else
  7620. {
  7621. return Error("参数获取失败");
  7622. }
  7623. }
  7624. else
  7625. {
  7626. return Error("权限不足");
  7627. }
  7628. }
  7629. /// <summary>
  7630. /// 办理工单
  7631. /// </summary>
  7632. /// <returns></returns>
  7633. [Authority]
  7634. public ActionResult FeedBackWorkOrder()
  7635. {
  7636. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  7637. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  7638. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  7639. {
  7640. string workorderid = RequestString.GetFormString("workorderid");
  7641. string dealman = RequestString.GetFormString("dealman");
  7642. string result = RequestString.GetFormString("result");
  7643. string files = RequestString.GetFormString("files");
  7644. int state = RequestString.GetInt("state", 0);
  7645. int feedbackid = RequestString.GetInt("feedbackid", 0);
  7646. int isproresult = RequestString.GetInt("isproresult", 0);//是否有处理结果:0默认,1是,2否
  7647. string prosituation = RequestString.GetFormString("prosituation");
  7648. string dealcontact = RequestString.GetFormString("dealcontact");
  7649. string connecttime=RequestString.GetFormString("connecttime");
  7650. string connectmode = RequestString.GetFormString("connectmode");
  7651. string replycontent = RequestString.GetFormString("replycontent");
  7652. int isstaisfied= RequestString.GetInt("isstaisfied", 0);
  7653. string duties= RequestString.GetFormString("duties");
  7654. string situation = RequestString.GetFormString("situation");
  7655. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7656. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7657. Model.T_Bus_Feedback modelT_Bus_Feedback = new Model.T_Bus_Feedback();
  7658. int type = 0;
  7659. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null)
  7660. {
  7661. type = AssignDeptType(modelT_Bus_AssignedInfo, userModel.F_DeptId);
  7662. if (type > 0)
  7663. {
  7664. //if (modelT_Bus_WorkOrder.F_WorkState == 4)
  7665. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing)
  7666. {
  7667. using (TransactionScope trans = new TransactionScope())
  7668. {
  7669. if (feedbackid == 0)
  7670. {
  7671. #region 插入反馈记录
  7672. modelT_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  7673. modelT_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  7674. modelT_Bus_Feedback.F_DealUser = dealman;
  7675. modelT_Bus_Feedback.F_Result = result;//反馈内容
  7676. #region 20200114新增字段 zhengbingbing
  7677. modelT_Bus_Feedback.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  7678. modelT_Bus_Feedback.F_ProSituation = prosituation;//处理情况/方案/进程
  7679. modelT_Bus_Feedback.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  7680. modelT_Bus_Feedback.F_DealUserContact = dealcontact;//承办人联系方式
  7681. DateTime contime = DateTime.Now;
  7682. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  7683. modelT_Bus_Feedback.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  7684. modelT_Bus_Feedback.F_ConnectMode = connectmode;//沟通方式
  7685. modelT_Bus_Feedback.F_ReplyContent = replycontent;//答复内容
  7686. modelT_Bus_Feedback.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  7687. modelT_Bus_Feedback.F_Duties = duties;//职务
  7688. modelT_Bus_Feedback.F_Situation = situation;
  7689. #endregion
  7690. modelT_Bus_Feedback.F_File = files;
  7691. modelT_Bus_Feedback.F_IsAudit = 0;
  7692. modelT_Bus_Feedback.F_IsDelete = 0;
  7693. modelT_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//办理人
  7694. modelT_Bus_Feedback.F_CreateTime = DateTime.Now;//办理时间
  7695. modelT_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//办理部门
  7696. modelT_Bus_Feedback.F_IsFeedEnd = 1;
  7697. modelT_Bus_Feedback.F_State = state;
  7698. modelT_Bus_Feedback.F_Type = type;
  7699. new BLL.T_Bus_Feedback().Add(modelT_Bus_Feedback);
  7700. #endregion
  7701. }
  7702. else
  7703. {
  7704. #region 修改反馈记录
  7705. modelT_Bus_Feedback = new BLL.T_Bus_Feedback().GetModel(feedbackid);
  7706. if (modelT_Bus_Feedback != null)
  7707. {
  7708. modelT_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  7709. modelT_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  7710. modelT_Bus_Feedback.F_DealUser = dealman;
  7711. modelT_Bus_Feedback.F_Result = result;//反馈内容
  7712. modelT_Bus_Feedback.F_File = files;
  7713. #region 20200114新增字段 zhengbingbing
  7714. modelT_Bus_Feedback.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  7715. modelT_Bus_Feedback.F_ProSituation = prosituation;//处理情况/方案/进程
  7716. modelT_Bus_Feedback.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  7717. modelT_Bus_Feedback.F_DealUserContact = dealcontact;//承办人联系方式
  7718. DateTime contime = DateTime.Now;
  7719. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  7720. modelT_Bus_Feedback.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  7721. modelT_Bus_Feedback.F_ConnectMode = connectmode;//沟通方式
  7722. modelT_Bus_Feedback.F_ReplyContent = replycontent;//答复内容
  7723. modelT_Bus_Feedback.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  7724. modelT_Bus_Feedback.F_Duties = duties;//职务
  7725. modelT_Bus_Feedback.F_Situation = situation;
  7726. #endregion
  7727. modelT_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//办理人
  7728. modelT_Bus_Feedback.F_CreateTime = DateTime.Now;//办理时间
  7729. modelT_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//办理部门
  7730. modelT_Bus_Feedback.F_IsFeedEnd = 1;
  7731. modelT_Bus_Feedback.F_State = state;
  7732. if (modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7733. {
  7734. modelT_Bus_Feedback.F_Type = 1;
  7735. }
  7736. else if (!string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_OtherDeptIds) && modelT_Bus_AssignedInfo.F_OtherDeptIds.Split(',').Contains(userModel.F_DeptId.ToString()))
  7737. {
  7738. modelT_Bus_Feedback.F_Type = 2;
  7739. }
  7740. new BLL.T_Bus_Feedback().Update(modelT_Bus_Feedback);
  7741. }
  7742. #endregion
  7743. }
  7744. if (modelT_Bus_Feedback != null && modelT_Bus_Feedback.F_State == 1)
  7745. {
  7746. string typemsg = "办理";
  7747. if (type == 1)
  7748. {
  7749. int iscs = 0;
  7750. if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  7751. {
  7752. iscs = 1;
  7753. }
  7754. #region 保存工单信息
  7755. //modelT_Bus_WorkOrder.F_WorkState = 6;//待回访
  7756. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealed;//待回访
  7757. modelT_Bus_WorkOrder.F_Result = result;
  7758. modelT_Bus_WorkOrder.F_DealDeptId = userModel.F_DeptId;
  7759. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  7760. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  7761. modelT_Bus_WorkOrder.F_IsOverdue = iscs;
  7762. workorderBLL.Update(modelT_Bus_WorkOrder);
  7763. #endregion
  7764. #region 保存交办信息
  7765. modelT_Bus_AssignedInfo.F_FeedbackTime = DateTime.Now;
  7766. if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  7767. {
  7768. modelT_Bus_AssignedInfo.F_IsOverdue = 1;
  7769. }
  7770. assignBLL.Update(modelT_Bus_AssignedInfo);
  7771. #endregion
  7772. #region 删除草稿信息
  7773. var cglist = new BLL.T_Bus_Feedback().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  7774. foreach (var cg in cglist)
  7775. {
  7776. cg.F_IsDelete = 1;
  7777. cg.F_DeleteUser = userModel.F_UserCode;
  7778. cg.F_DeleteTime = DateTime.Now;
  7779. new BLL.T_Bus_Feedback().Update(cg);
  7780. }
  7781. #endregion
  7782. #region 删除二级单位未办理信息
  7783. var ejlist = new BLL.T_Bus_AssignedInfo_Next().GetModelList(" F_IsDelete=0 and isnull(F_FeedbackTime,'')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  7784. foreach (var ej in ejlist)
  7785. {
  7786. ej.F_IsDelete = 1;
  7787. ej.F_DeleteUser = userModel.F_UserCode;
  7788. ej.F_DeleteTime = DateTime.Now;
  7789. new BLL.T_Bus_AssignedInfo_Next().Update(ej);
  7790. }
  7791. #endregion
  7792. #region 处理协办单位
  7793. var xblist = new BLL.T_Bus_AssignedItemInfo().GetModelList(" F_IsDelete=0 and F_State=1 and ISNULL(F_FeedbackTime, '')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  7794. foreach (var xb in xblist)
  7795. {
  7796. xb.F_State = 2;
  7797. xb.F_SureUser = userModel.F_UserCode;
  7798. xb.F_SureTime = DateTime.Now;
  7799. new BLL.T_Bus_AssignedItemInfo().Update(xb);
  7800. }
  7801. #endregion
  7802. typemsg = "主办";
  7803. }
  7804. else if (type == 2)
  7805. {
  7806. #region 保存明细信息
  7807. Model.T_Bus_AssignedItemInfo modelT_Bus_AssignedItemInfo = new BLL.T_Bus_AssignedItemInfo().GetModelList(" F_IsDelete=0 and F_State=1 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_DeptId='" + userModel.F_DeptId + "'").FirstOrDefault();
  7808. modelT_Bus_AssignedItemInfo.F_FeedbackTime = DateTime.Now;
  7809. if (modelT_Bus_AssignedItemInfo.F_LimitTime < DateTime.Now)
  7810. {
  7811. modelT_Bus_AssignedItemInfo.F_IsOverdue = 1;
  7812. }
  7813. new BLL.T_Bus_AssignedItemInfo().Update(modelT_Bus_AssignedItemInfo);
  7814. #endregion
  7815. #region 删除草稿信息
  7816. var cglist = new BLL.T_Bus_Feedback().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  7817. foreach (var cg in cglist)
  7818. {
  7819. cg.F_IsDelete = 1;
  7820. cg.F_DeleteUser = userModel.F_UserCode;
  7821. cg.F_DeleteTime = DateTime.Now;
  7822. new BLL.T_Bus_Feedback().Update(cg);
  7823. }
  7824. #endregion
  7825. typemsg = "协办";
  7826. }
  7827. #region 插入操作记录
  7828. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7829. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  7830. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7831. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  7832. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7833. oper.F_Message = userinfo + " " + typemsg + "了工单";
  7834. oper.F_CreateUser = userModel.F_UserCode;
  7835. oper.F_CreateTime = DateTime.Now;
  7836. oper.F_IsDelete = 0;
  7837. operBLL.Add(oper);
  7838. //推送消息表
  7839. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_WorkOrder.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  7840. #endregion
  7841. }
  7842. trans.Complete();
  7843. }
  7844. return Success("操作成功", modelT_Bus_Feedback.F_Id);
  7845. }
  7846. else
  7847. {
  7848. return Error("已经办理过了");
  7849. }
  7850. }
  7851. else
  7852. {
  7853. return Error("权限不足");
  7854. }
  7855. }
  7856. else
  7857. {
  7858. return Error("操作失败");
  7859. }
  7860. }
  7861. else
  7862. {
  7863. return Error("权限不足");
  7864. }
  7865. }
  7866. #region 网格化对接
  7867. /// <summary>
  7868. /// 对接网格化
  7869. /// 工单查收操作
  7870. /// </summary>
  7871. /// <param name="usercode"></param>
  7872. /// <param name="workorderid"></param>
  7873. /// <returns></returns>
  7874. public string ReceiveWorkOrderByDock(string usercode, string workorderid,string content)
  7875. {
  7876. var returns = "";
  7877. using (TransactionScope trans = new TransactionScope())
  7878. {
  7879. string optmsg = ""; var assid = 0; var msgend = ""; var state = 0; var userinfo = ""; var msgss = ""; var retbool = "false"; var optid = string.Empty;
  7880. Model.T_Sys_UserAccount userModel = userBLL.GetModel(usercode);
  7881. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7882. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7883. msgend = ",工单编号:" + workorderid + ",办理详情:" + content;
  7884. if (userModel != null)
  7885. {
  7886. if (modelT_Bus_WorkOrder == null)
  7887. msgss = "要办理的工单已不存在";
  7888. else if (modelT_Bus_AssignedInfo == null)
  7889. {
  7890. msgss = "工单无法处理或已被处理";
  7891. }
  7892. else
  7893. {
  7894. if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.receive || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.reload) && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7895. {
  7896. if (modelT_Bus_AssignedInfo.F_IsSure == 0)
  7897. {
  7898. #region 保存工单信息
  7899. //modelT_Bus_WorkOrder.F_WorkState = 4;//办理中
  7900. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealing;//办理中
  7901. workorderBLL.Update(modelT_Bus_WorkOrder);
  7902. #endregion
  7903. #region 保存查收信息
  7904. modelT_Bus_AssignedInfo.F_IsSure = 1;//查收
  7905. modelT_Bus_AssignedInfo.F_SureUser = userModel.F_UserCode;
  7906. modelT_Bus_AssignedInfo.F_SureTime = DateTime.Now;
  7907. assignBLL.Update(modelT_Bus_AssignedInfo);
  7908. #endregion
  7909. #region 保存明细信息
  7910. if (!string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_OtherDeptIds))
  7911. {
  7912. string[] strids = modelT_Bus_AssignedInfo.F_OtherDeptIds.Split(',');
  7913. foreach (string strid in strids)
  7914. {
  7915. Model.T_Bus_AssignedItemInfo modelT_Bus_AssignedItemInfo = new Model.T_Bus_AssignedItemInfo();
  7916. modelT_Bus_AssignedItemInfo.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  7917. modelT_Bus_AssignedItemInfo.F_AssignedOpinion = modelT_Bus_AssignedInfo.F_AssignedOpinion;
  7918. modelT_Bus_AssignedItemInfo.F_DeptId = Int32.Parse(strid);
  7919. modelT_Bus_AssignedItemInfo.F_LimitTime = modelT_Bus_AssignedInfo.F_LimitTime;
  7920. modelT_Bus_AssignedItemInfo.F_Remark = modelT_Bus_AssignedInfo.F_Remark;
  7921. modelT_Bus_AssignedItemInfo.F_State = 1;
  7922. modelT_Bus_AssignedItemInfo.F_Type = 2;
  7923. modelT_Bus_AssignedItemInfo.F_WorkOrderId = modelT_Bus_AssignedInfo.F_WorkOrderId;
  7924. modelT_Bus_AssignedItemInfo.F_IsSure = 0;
  7925. modelT_Bus_AssignedItemInfo.F_CreateTime = DateTime.Now;
  7926. modelT_Bus_AssignedItemInfo.F_CreateUser = userModel.F_UserCode;
  7927. modelT_Bus_AssignedItemInfo.F_IsDelete = 0;
  7928. new BLL.T_Bus_AssignedItemInfo().Add(modelT_Bus_AssignedItemInfo);
  7929. }
  7930. }
  7931. #endregion
  7932. retbool = "true";
  7933. optmsg = " 查收了工单";
  7934. msgss = optmsg;
  7935. }
  7936. else
  7937. msgss = "工单已被查收";
  7938. assid = modelT_Bus_AssignedInfo.F_Id;
  7939. state = modelT_Bus_WorkOrder.F_WorkState.Value;
  7940. }
  7941. else
  7942. msgss = "工单已办理或已被重新指派";
  7943. }
  7944. userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7945. }
  7946. else
  7947. {
  7948. userinfo = "无法获取工号信息,工号为" + usercode + msgend;
  7949. msgss = "无法获取工号信息";
  7950. }
  7951. #region 插入操作记录
  7952. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  7953. oper.F_WorkOrderId = workorderid;
  7954. oper.F_AssignedId = assid;
  7955. oper.F_State = state;
  7956. oper.F_Message = userinfo + " " + msgss + msgend;
  7957. oper.F_CreateUser = usercode;
  7958. oper.F_CreateTime = DateTime.Now;
  7959. oper.F_IsDelete = 0;
  7960. oper.F_Type = 1;
  7961. optid = operBLL.Add(oper).ToString();
  7962. #endregion
  7963. trans.Complete();
  7964. returns = retbool + "|" + optid + "|" + msgss;
  7965. }
  7966. return returns;
  7967. }
  7968. /// <summary>
  7969. /// 对接网格化 工单退回操作
  7970. /// </summary>
  7971. /// <returns></returns>
  7972. public string RebackWorkOrderByDock(string usercode,string workorderid,string backreason,string content)
  7973. {
  7974. var returns = "";
  7975. using (TransactionScope trans = new TransactionScope())
  7976. {
  7977. string optmsg = ""; var assid = 0; var msgend = ""; var state = 0;
  7978. var userinfo = ""; var msgss = ""; var optid = string.Empty; var retbool = "false";
  7979. Model.T_Sys_UserAccount userModel = userBLL.GetModel(usercode);
  7980. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  7981. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  7982. msgend = ",工单编号:" + workorderid + ",办理详情:" + content;
  7983. if (userModel != null)
  7984. {
  7985. userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  7986. if (modelT_Bus_WorkOrder == null)
  7987. msgss = "要办理的工单已不存在";
  7988. else if (modelT_Bus_AssignedInfo == null)
  7989. {
  7990. msgss = "工单无法处理或已被处理";
  7991. }
  7992. else
  7993. {
  7994. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  7995. {
  7996. if (modelT_Bus_AssignedInfo.F_IsSure == 0)
  7997. {
  7998. #region 保存工单信息
  7999. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.auditreback;//退回审核中
  8000. workorderBLL.Update(modelT_Bus_WorkOrder);
  8001. #endregion
  8002. #region 插入退回申请信息
  8003. Model.T_Bus_Feedback model_T_Bus_Feedback = new Model.T_Bus_Feedback();
  8004. model_T_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8005. model_T_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  8006. model_T_Bus_Feedback.F_Result = backreason;//退回原因
  8007. model_T_Bus_Feedback.F_IsAudit = 0;
  8008. model_T_Bus_Feedback.F_IsDelete = 0;
  8009. model_T_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//退回人
  8010. model_T_Bus_Feedback.F_CreateTime = DateTime.Now;//退回时间
  8011. model_T_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//退回部门
  8012. model_T_Bus_Feedback.F_IsFeedEnd = 1;
  8013. model_T_Bus_Feedback.F_State = 1;
  8014. model_T_Bus_Feedback.F_Type = 3;
  8015. new BLL.T_Bus_Feedback().Add(model_T_Bus_Feedback);
  8016. #endregion
  8017. #region 保存交办信息
  8018. modelT_Bus_AssignedInfo.F_IsSure = 2;//申请退回
  8019. modelT_Bus_AssignedInfo.F_SureUser = userModel.F_UserCode;
  8020. modelT_Bus_AssignedInfo.F_SureTime = DateTime.Now;
  8021. assignBLL.Update(modelT_Bus_AssignedInfo);
  8022. #endregion
  8023. #region 推送消息
  8024. retbool = "true";
  8025. optmsg = " 申请退回了工单";
  8026. //推送消息表
  8027. msg.AddInternalMessagesInfo("工单消息", userinfo + optmsg + ",工单编号:" + workorderid, modelT_Bus_AssignedInfo.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  8028. #endregion
  8029. msgss = optmsg;
  8030. }
  8031. else
  8032. msgss = "工单已被查收,不能退回";
  8033. assid = modelT_Bus_AssignedInfo.F_Id;
  8034. state = modelT_Bus_WorkOrder.F_WorkState.Value;
  8035. }
  8036. else
  8037. msgss = "工单已办理或已被重新指派";
  8038. }
  8039. }
  8040. else
  8041. {
  8042. userinfo = "无法获取工号信息,工号为" + usercode + msgend;
  8043. msgss = "无法获取工号信息";
  8044. }
  8045. #region 插入操作记录
  8046. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8047. oper.F_WorkOrderId = workorderid;
  8048. oper.F_AssignedId = assid;
  8049. oper.F_State = state;
  8050. oper.F_Message = userinfo+" " + msgss + msgend;
  8051. oper.F_CreateUser = usercode;
  8052. oper.F_CreateTime = DateTime.Now;
  8053. oper.F_IsDelete = 0;
  8054. oper.F_Type = 1;
  8055. optid = operBLL.Add(oper).ToString();
  8056. #endregion
  8057. trans.Complete();
  8058. returns = retbool + "|" + optid + "|" + msgss;
  8059. }
  8060. return returns;
  8061. }
  8062. /// <summary>
  8063. /// 对接网格化办理
  8064. /// </summary>
  8065. /// <param name="usercode">工号</param>
  8066. /// <param name="workorderid">工单编号</param>
  8067. /// <param name="dealman">承办人人</param>
  8068. /// <param name="result">反馈内容</param>
  8069. /// <param name="files">附件</param>
  8070. /// <param name="prosituation">处理情况/方案/进程</param>
  8071. /// <param name="dealcontact">承办人联系方式</param>
  8072. /// <param name="connecttime">沟通时间</param>
  8073. /// <param name="connectmode">沟通方式</param>
  8074. /// <param name="replycontent">答复内容</param>
  8075. /// <param name="duties">职务</param>
  8076. /// <param name="situation">处理情况</param>
  8077. /// <param name="state">0保存,1保存并办理</param>
  8078. /// <param name="feedbackid"></param>
  8079. /// <param name="isproresult">是否有处理结果:0默认,1是,2否</param>
  8080. /// <param name="isstaisfied">是否满意:0未评价,1满意,2基本满意,3不满意</param>
  8081. /// <returns></returns>
  8082. public string FeedBackWorkOrderBYDock(string usercode,string workorderid,string dealman,string result,string files,string prosituation, string dealcontact, string connecttime, string connectmode, string replycontent, string duties, string situation,int state=0, int feedbackid=0, int isproresult=0, int isstaisfied=0)
  8083. {
  8084. var returns = "";
  8085. using (TransactionScope trans = new TransactionScope())
  8086. {
  8087. string optmsg = ""; var assid = 0; var msgend = ""; var wostate = 0; var userinfo = ""; string backid = string.Empty; var msgss = ""; var retbool = "false";
  8088. Model.T_Sys_UserAccount userModel = userBLL.GetModel(usercode);
  8089. if (userModel != null)
  8090. {
  8091. userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8092. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8093. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8094. Model.T_Bus_Feedback modelT_Bus_Feedback = new Model.T_Bus_Feedback();
  8095. msgend = ",工单编号:" + workorderid;
  8096. int type = 0; var resmsg = ""; string typemsg = "办理";
  8097. if (modelT_Bus_WorkOrder == null)
  8098. msgss = "要办理的工单已不存在";
  8099. else if (modelT_Bus_AssignedInfo == null)
  8100. {
  8101. msgss = "工单无法处理";
  8102. }
  8103. else
  8104. {
  8105. type = AssignDeptType(modelT_Bus_AssignedInfo, userModel.F_DeptId);
  8106. if (type > 0)
  8107. {
  8108. #region 办理结果合成
  8109. result = "";
  8110. #region 获取部门
  8111. var deptname = "";
  8112. if (modelT_Bus_WorkOrder.F_MainDeptId != null)
  8113. {
  8114. var deptmodel = new BLL.T_Sys_Department().GetModel(modelT_Bus_WorkOrder.F_MainDeptId.Value);
  8115. if (deptmodel != null)
  8116. deptname = deptmodel.F_DeptName;
  8117. }
  8118. #endregion
  8119. #region 获取来源
  8120. var sourcename = "";
  8121. if (modelT_Bus_WorkOrder.F_InfoSource != null)
  8122. {
  8123. var dicmodel = new BLL.T_Sys_DictionaryValue().GetModel(modelT_Bus_WorkOrder.F_InfoSource.Value);
  8124. if (dicmodel != null)
  8125. sourcename = dicmodel.F_Value;
  8126. }
  8127. #endregion
  8128. var startstr = modelT_Bus_WorkOrder.F_CreateTime + " " + deptname + "部门接到" + sourcename + "来源工单(编号:" + modelT_Bus_WorkOrder.F_WorkOrderId + ")反映" + modelT_Bus_WorkOrder.F_ComTitle + "问题,";
  8129. var bljg = ""; var endstr = "";
  8130. if (isproresult == 1)
  8131. {
  8132. bljg = "已办理";
  8133. if (modelT_Bus_WorkOrder.F_IsProtect == 0)
  8134. {
  8135. var isStaisfiedRadioData = "未评价";
  8136. if (isstaisfied == 1)
  8137. {
  8138. isStaisfiedRadioData = "满意";
  8139. }
  8140. else if (isstaisfied == 2)
  8141. {
  8142. isStaisfiedRadioData = "基本满意";
  8143. }
  8144. else if (isstaisfied == 3)
  8145. {
  8146. isStaisfiedRadioData = "不满意";
  8147. }
  8148. endstr = "; " + dealman + "用" + connectmode + "方式在" + connecttime + "对反映人进行了回复,反映人对结果表示" + isStaisfiedRadioData;
  8149. }
  8150. }
  8151. else if (isproresult == 2)
  8152. {
  8153. bljg = "未办理";
  8154. endstr = "; 处理方案/进程:" + prosituation;
  8155. }
  8156. result = startstr + "经落实,具体情况回复如下:" + situation + " 办理结果:" + bljg + " 承办人:" + dealman + " 职务:" + duties + " 联系电话:" + dealcontact + endstr;
  8157. #endregion
  8158. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing)
  8159. {
  8160. #region 处理办理
  8161. if (feedbackid == 0)
  8162. {
  8163. #region 插入反馈记录
  8164. modelT_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8165. modelT_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  8166. modelT_Bus_Feedback.F_DealUser = dealman;
  8167. modelT_Bus_Feedback.F_Result = result;//反馈内容
  8168. #region 20200114新增字段 zhengbingbing
  8169. modelT_Bus_Feedback.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  8170. modelT_Bus_Feedback.F_ProSituation = prosituation;//处理情况/方案/进程
  8171. modelT_Bus_Feedback.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  8172. modelT_Bus_Feedback.F_DealUserContact = dealcontact;//承办人联系方式
  8173. DateTime contime = DateTime.Now;
  8174. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  8175. modelT_Bus_Feedback.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  8176. modelT_Bus_Feedback.F_ConnectMode = connectmode;//沟通方式
  8177. modelT_Bus_Feedback.F_ReplyContent = replycontent;//答复内容
  8178. modelT_Bus_Feedback.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  8179. modelT_Bus_Feedback.F_Duties = duties;//职务
  8180. modelT_Bus_Feedback.F_Situation = situation;
  8181. #endregion
  8182. modelT_Bus_Feedback.F_File = files;
  8183. modelT_Bus_Feedback.F_IsAudit = 0;
  8184. modelT_Bus_Feedback.F_IsDelete = 0;
  8185. modelT_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//办理人
  8186. modelT_Bus_Feedback.F_CreateTime = DateTime.Now;//办理时间
  8187. modelT_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//办理部门
  8188. modelT_Bus_Feedback.F_IsFeedEnd = 1;
  8189. modelT_Bus_Feedback.F_State = state;
  8190. modelT_Bus_Feedback.F_Type = type;
  8191. modelT_Bus_Feedback.F_Id = new BLL.T_Bus_Feedback().Add(modelT_Bus_Feedback);
  8192. #endregion
  8193. }
  8194. else
  8195. {
  8196. #region 修改反馈记录
  8197. modelT_Bus_Feedback = new BLL.T_Bus_Feedback().GetModel(feedbackid);
  8198. if (modelT_Bus_Feedback != null)
  8199. {
  8200. modelT_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8201. modelT_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  8202. modelT_Bus_Feedback.F_DealUser = dealman;
  8203. modelT_Bus_Feedback.F_Result = result;//反馈内容
  8204. modelT_Bus_Feedback.F_File = files;
  8205. #region 20200114新增字段 zhengbingbing
  8206. modelT_Bus_Feedback.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  8207. modelT_Bus_Feedback.F_ProSituation = prosituation;//处理情况/方案/进程
  8208. modelT_Bus_Feedback.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  8209. modelT_Bus_Feedback.F_DealUserContact = dealcontact;//承办人联系方式
  8210. DateTime contime = DateTime.Now;
  8211. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  8212. modelT_Bus_Feedback.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  8213. modelT_Bus_Feedback.F_ConnectMode = connectmode;//沟通方式
  8214. modelT_Bus_Feedback.F_ReplyContent = replycontent;//答复内容
  8215. modelT_Bus_Feedback.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  8216. modelT_Bus_Feedback.F_Duties = duties;//职务
  8217. modelT_Bus_Feedback.F_Situation = situation;
  8218. #endregion
  8219. modelT_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//办理人
  8220. modelT_Bus_Feedback.F_CreateTime = DateTime.Now;//办理时间
  8221. modelT_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//办理部门
  8222. modelT_Bus_Feedback.F_IsFeedEnd = 1;
  8223. modelT_Bus_Feedback.F_State = state;
  8224. if (modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  8225. {
  8226. modelT_Bus_Feedback.F_Type = 1;
  8227. }
  8228. else if (!string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_OtherDeptIds) && modelT_Bus_AssignedInfo.F_OtherDeptIds.Split(',').Contains(userModel.F_DeptId.ToString()))
  8229. {
  8230. modelT_Bus_Feedback.F_Type = 2;
  8231. }
  8232. new BLL.T_Bus_Feedback().Update(modelT_Bus_Feedback);
  8233. }
  8234. #endregion
  8235. }
  8236. if (modelT_Bus_Feedback != null && modelT_Bus_Feedback.F_State == 1)
  8237. {
  8238. if (type == 1)
  8239. {
  8240. int iscs = 0;
  8241. if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  8242. {
  8243. iscs = 1;
  8244. }
  8245. #region 保存工单信息
  8246. //modelT_Bus_WorkOrder.F_WorkState = 6;//待回访
  8247. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealed;//待回访
  8248. modelT_Bus_WorkOrder.F_Result = result;
  8249. modelT_Bus_WorkOrder.F_DealDeptId = userModel.F_DeptId;
  8250. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  8251. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  8252. modelT_Bus_WorkOrder.F_IsOverdue = iscs;
  8253. workorderBLL.Update(modelT_Bus_WorkOrder);
  8254. #endregion
  8255. #region 保存交办信息
  8256. modelT_Bus_AssignedInfo.F_FeedbackTime = DateTime.Now;
  8257. if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  8258. {
  8259. modelT_Bus_AssignedInfo.F_IsOverdue = 1;
  8260. }
  8261. assignBLL.Update(modelT_Bus_AssignedInfo);
  8262. #endregion
  8263. #region 删除草稿信息
  8264. var cglist = new BLL.T_Bus_Feedback().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  8265. foreach (var cg in cglist)
  8266. {
  8267. cg.F_IsDelete = 1;
  8268. cg.F_DeleteUser = userModel.F_UserCode;
  8269. cg.F_DeleteTime = DateTime.Now;
  8270. new BLL.T_Bus_Feedback().Update(cg);
  8271. }
  8272. #endregion
  8273. #region 删除二级单位未办理信息
  8274. var ejlist = new BLL.T_Bus_AssignedInfo_Next().GetModelList(" F_IsDelete=0 and isnull(F_FeedbackTime,'')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  8275. foreach (var ej in ejlist)
  8276. {
  8277. ej.F_IsDelete = 1;
  8278. ej.F_DeleteUser = userModel.F_UserCode;
  8279. ej.F_DeleteTime = DateTime.Now;
  8280. new BLL.T_Bus_AssignedInfo_Next().Update(ej);
  8281. }
  8282. #endregion
  8283. #region 处理协办单位
  8284. var xblist = new BLL.T_Bus_AssignedItemInfo().GetModelList(" F_IsDelete=0 and F_State=1 and ISNULL(F_FeedbackTime, '')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  8285. foreach (var xb in xblist)
  8286. {
  8287. xb.F_State = 2;
  8288. xb.F_SureUser = userModel.F_UserCode;
  8289. xb.F_SureTime = DateTime.Now;
  8290. new BLL.T_Bus_AssignedItemInfo().Update(xb);
  8291. }
  8292. #endregion
  8293. typemsg = "主办";
  8294. }
  8295. else if (type == 2)
  8296. {
  8297. #region 保存明细信息
  8298. Model.T_Bus_AssignedItemInfo modelT_Bus_AssignedItemInfo = new BLL.T_Bus_AssignedItemInfo().GetModelList(" F_IsDelete=0 and F_State=1 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_DeptId='" + userModel.F_DeptId + "'").FirstOrDefault();
  8299. modelT_Bus_AssignedItemInfo.F_FeedbackTime = DateTime.Now;
  8300. if (modelT_Bus_AssignedItemInfo.F_LimitTime < DateTime.Now)
  8301. {
  8302. modelT_Bus_AssignedItemInfo.F_IsOverdue = 1;
  8303. }
  8304. new BLL.T_Bus_AssignedItemInfo().Update(modelT_Bus_AssignedItemInfo);
  8305. #endregion
  8306. #region 删除草稿信息
  8307. var cglist = new BLL.T_Bus_Feedback().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  8308. foreach (var cg in cglist)
  8309. {
  8310. cg.F_IsDelete = 1;
  8311. cg.F_DeleteUser = userModel.F_UserCode;
  8312. cg.F_DeleteTime = DateTime.Now;
  8313. new BLL.T_Bus_Feedback().Update(cg);
  8314. }
  8315. #endregion
  8316. typemsg = "协办";
  8317. }
  8318. var msgs = userinfo + " " + resmsg + " " + typemsg + "了工单";
  8319. //推送消息表
  8320. msg.AddInternalMessagesInfo("工单消息", msgs + ",工单编号:" + workorderid, modelT_Bus_WorkOrder.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  8321. }
  8322. #endregion
  8323. retbool = "true";
  8324. }
  8325. else
  8326. msgss = "工单已办理";
  8327. backid = modelT_Bus_Feedback.F_Id.ToString();
  8328. }
  8329. else
  8330. msgss = "工单已办理或已被重新指派";
  8331. assid = modelT_Bus_AssignedInfo.F_Id;
  8332. wostate = modelT_Bus_WorkOrder.F_WorkState.Value;
  8333. }
  8334. msgend = resmsg + " " + typemsg + "了工单";
  8335. }
  8336. else
  8337. {
  8338. userinfo = "无法获取工号信息,工号为" + usercode + msgend;
  8339. msgss = "无法获取工号信息";
  8340. }
  8341. #region 插入操作记录
  8342. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8343. oper.F_WorkOrderId = workorderid;
  8344. oper.F_AssignedId = assid;
  8345. oper.F_State = wostate;
  8346. oper.F_Message = userinfo + msgend;
  8347. oper.F_CreateUser = usercode;
  8348. oper.F_CreateTime = DateTime.Now;
  8349. oper.F_IsDelete = 0;
  8350. oper.F_Type = 1;
  8351. oper.F_File = files;
  8352. operBLL.Add(oper);
  8353. #endregion
  8354. trans.Complete();
  8355. returns = retbool + "|" + backid + "|" + msgss;
  8356. }
  8357. return returns;
  8358. }
  8359. /// <summary>
  8360. /// 对接网格化,记录办理过程
  8361. /// </summary>
  8362. /// <param name="usercode"></param>
  8363. /// <param name="workorderid"></param>
  8364. /// <param name="content"></param>
  8365. /// <returns></returns>
  8366. public string DealProcessWorkOrderByDock(string usercode,string workorderid,string content)
  8367. {
  8368. var returns = "";
  8369. using (TransactionScope trans = new TransactionScope())
  8370. {
  8371. var assid = 0; var msgend = ""; var state = 0;var userinfo = "";var msgss = ""; var optid = string.Empty; var retbool = "false";
  8372. Model.T_Sys_UserAccount userModel = userBLL.GetModel(usercode);
  8373. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8374. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8375. msgend = ",工单编号:" + workorderid + ",办理内容为:" + content;
  8376. if (userModel != null)
  8377. {
  8378. if (modelT_Bus_WorkOrder == null)
  8379. msgss = "要办理的工单已不存在";
  8380. else if (modelT_Bus_AssignedInfo == null)
  8381. {
  8382. msgss = "工单无法处理或已被处理";
  8383. }
  8384. else
  8385. {
  8386. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing && modelT_Bus_AssignedInfo.F_IsSure == 1 && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  8387. {
  8388. msgss = "办理工单";
  8389. retbool = "true";
  8390. assid = modelT_Bus_AssignedInfo.F_Id;
  8391. state = modelT_Bus_WorkOrder.F_WorkState.Value;
  8392. }
  8393. else
  8394. {
  8395. msgss = "工单无法处理";
  8396. }
  8397. }
  8398. userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8399. }
  8400. else
  8401. {
  8402. userinfo = "无法获取工号信息,工号为" + usercode + msgend;
  8403. msgss = "无法获取工号信息";
  8404. }
  8405. #region 插入操作记录
  8406. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8407. oper.F_WorkOrderId = workorderid;
  8408. oper.F_AssignedId = assid;
  8409. oper.F_State = state;
  8410. oper.F_Message = userinfo + msgend;
  8411. oper.F_CreateUser = usercode;
  8412. oper.F_CreateTime = DateTime.Now;
  8413. oper.F_IsDelete = 0;
  8414. oper.F_Type = 1;
  8415. optid = operBLL.Add(oper).ToString();
  8416. #endregion
  8417. trans.Complete();
  8418. returns = retbool + "|" + optid + "|" + msgss;
  8419. }
  8420. return returns;
  8421. }
  8422. #endregion
  8423. /// <summary>
  8424. /// 派工单
  8425. /// </summary>
  8426. /// <returns></returns>
  8427. [Authority]
  8428. public ActionResult SplitWorkOrder()
  8429. {
  8430. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8431. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8432. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8433. {
  8434. string workorderid = RequestString.GetFormString("workorderid");
  8435. int maindeptid = RequestString.GetInt("maindeptid", 0);
  8436. string otherdeptids = RequestString.GetFormString("otherdeptids");
  8437. DateTime limittime = DateTime.Parse(RequestString.GetFormString("limittime") + " 23:59:59");
  8438. string assignedopinion = RequestString.GetFormString("assignedopinion");
  8439. string files = RequestString.GetFormString("files");
  8440. int state = RequestString.GetInt("state", 0);
  8441. int nextid = RequestString.GetInt("nextid", 0);
  8442. if (limittime < DateTime.Now)
  8443. {
  8444. return Error("办理时限不能小于当前时间");
  8445. }
  8446. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8447. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8448. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new Model.T_Bus_AssignedInfo_Next();
  8449. var deptinfo = new BLL.T_Sys_Department().GetModel(maindeptid);
  8450. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && deptinfo != null)
  8451. {
  8452. int type = AssignDeptType(modelT_Bus_AssignedInfo, userModel.F_DeptId);
  8453. //if ((type == 1 && modelT_Bus_WorkOrder.F_WorkState == 4) || userModel.F_RoleCode == "GLY")
  8454. if ((type == 1 && modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing) || (userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG"))
  8455. {
  8456. if (modelT_Bus_AssignedInfo.F_IsNext == null || modelT_Bus_AssignedInfo.F_IsNext.Value == 0)
  8457. {
  8458. using (TransactionScope trans = new TransactionScope())
  8459. {
  8460. if (nextid == 0)
  8461. {
  8462. #region 插入派单记录
  8463. modelT_Bus_AssignedInfo_Next.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8464. modelT_Bus_AssignedInfo_Next.F_LimitTime = limittime;//办理时限
  8465. modelT_Bus_AssignedInfo_Next.F_MainDeptId = maindeptid;//主办单位id
  8466. modelT_Bus_AssignedInfo_Next.F_OtherDeptIds = otherdeptids;//协办单位id
  8467. modelT_Bus_AssignedInfo_Next.F_AssignedOpinion = assignedopinion;//交办意见
  8468. modelT_Bus_AssignedInfo_Next.F_State = state;//0草稿 1正式
  8469. modelT_Bus_AssignedInfo_Next.F_CreateUser = userModel.F_UserCode;
  8470. modelT_Bus_AssignedInfo_Next.F_CreateTime = DateTime.Now;
  8471. modelT_Bus_AssignedInfo_Next.F_IsDelete = 0;
  8472. modelT_Bus_AssignedInfo_Next.F_IsOverdue = 0;
  8473. modelT_Bus_AssignedInfo_Next.F_IsSure = 0;
  8474. modelT_Bus_AssignedInfo_Next.F_IsReload = 0;
  8475. modelT_Bus_AssignedInfo_Next.F_Id = new BLL.T_Bus_AssignedInfo_Next().Add(modelT_Bus_AssignedInfo_Next);
  8476. #endregion
  8477. }
  8478. else
  8479. {
  8480. #region 修改派单记录
  8481. modelT_Bus_AssignedInfo_Next = new BLL.T_Bus_AssignedInfo_Next().GetModel(nextid);
  8482. if (modelT_Bus_AssignedInfo_Next != null)
  8483. {
  8484. modelT_Bus_AssignedInfo_Next.F_LimitTime = limittime;//办理时限
  8485. modelT_Bus_AssignedInfo_Next.F_MainDeptId = maindeptid;//主办单位id
  8486. modelT_Bus_AssignedInfo_Next.F_OtherDeptIds = otherdeptids;//协办单位id
  8487. modelT_Bus_AssignedInfo_Next.F_AssignedOpinion = assignedopinion;//交办意见
  8488. modelT_Bus_AssignedInfo_Next.F_State = state;//0草稿 1正式
  8489. modelT_Bus_AssignedInfo_Next.F_CreateUser = userModel.F_UserCode;
  8490. modelT_Bus_AssignedInfo_Next.F_CreateTime = DateTime.Now;
  8491. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next);
  8492. }
  8493. #endregion
  8494. }
  8495. if (modelT_Bus_AssignedInfo_Next != null && modelT_Bus_AssignedInfo_Next.F_State == 1)
  8496. {
  8497. #region 保存交办信息
  8498. modelT_Bus_AssignedInfo.F_IsNext = 1;
  8499. modelT_Bus_AssignedInfo.F_NextUser = userModel.F_UserCode;
  8500. modelT_Bus_AssignedInfo.F_NextTime = DateTime.Now;
  8501. new BLL.T_Bus_AssignedInfo().Update(modelT_Bus_AssignedInfo);
  8502. #endregion
  8503. #region 保存工单信息
  8504. modelT_Bus_WorkOrder.F_MainDeptID3 = maindeptid.ToString();
  8505. workorderBLL.Update(modelT_Bus_WorkOrder);
  8506. #endregion
  8507. #region 插入操作记录
  8508. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8509. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8510. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  8511. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  8512. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8513. oper.F_Message = userinfo + " 派单给单位:" + deptinfo.F_DeptName;
  8514. oper.F_CreateUser = userModel.F_UserCode;
  8515. oper.F_CreateTime = DateTime.Now;
  8516. oper.F_IsDelete = 0;
  8517. operBLL.Add(oper);
  8518. //推送消息表
  8519. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_WorkOrder.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  8520. #endregion
  8521. }
  8522. trans.Complete();
  8523. }
  8524. return Success("操作成功", modelT_Bus_AssignedInfo_Next.F_Id);
  8525. }
  8526. else
  8527. {
  8528. return Error("已经派过单了");
  8529. }
  8530. }
  8531. else
  8532. {
  8533. return Error("操作失败");
  8534. }
  8535. }
  8536. else
  8537. {
  8538. return Error("操作失败");
  8539. }
  8540. }
  8541. else
  8542. {
  8543. return Error("权限不足");
  8544. }
  8545. }
  8546. /// <summary>
  8547. /// 撤回工单
  8548. /// </summary>
  8549. /// <returns></returns>
  8550. [Authority]
  8551. public ActionResult WithdrawWorkOrder()
  8552. {
  8553. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8554. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8555. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8556. {
  8557. string workorderid = RequestString.GetFormString("workorderid");
  8558. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8559. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8560. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new BLL.T_Bus_AssignedInfo_Next().GetNewModelByWorkOrderID(workorderid);
  8561. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo_Next != null && modelT_Bus_AssignedInfo.F_MainDeptId == userModel.F_DeptId)
  8562. {
  8563. using (TransactionScope trans = new TransactionScope())
  8564. {
  8565. #region 保存撤单信息
  8566. modelT_Bus_AssignedInfo_Next.F_IsDelete = 1;
  8567. modelT_Bus_AssignedInfo_Next.F_DeleteUser = userModel.F_UserCode;
  8568. modelT_Bus_AssignedInfo_Next.F_DeleteTime = DateTime.Now;
  8569. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next);
  8570. #endregion
  8571. #region 删除处理信息
  8572. var cglist = new BLL.T_Bus_Feedback_Next().GetModelList(" F_IsDelete=0 and F_AssignedId='" + modelT_Bus_AssignedInfo_Next.F_Id + "'");
  8573. foreach (var cg in cglist)
  8574. {
  8575. cg.F_IsDelete = 1;
  8576. cg.F_DeleteUser = userModel.F_UserCode;
  8577. cg.F_DeleteTime = DateTime.Now;
  8578. new BLL.T_Bus_Feedback_Next().Update(cg);
  8579. }
  8580. #endregion
  8581. #region 保存交办信息
  8582. modelT_Bus_AssignedInfo.F_IsNext = 0;
  8583. new BLL.T_Bus_AssignedInfo().Update(modelT_Bus_AssignedInfo);
  8584. #endregion
  8585. #region 保存工单信息
  8586. modelT_Bus_WorkOrder.F_MainDeptID3 = null;
  8587. workorderBLL.Update(modelT_Bus_WorkOrder);
  8588. #endregion
  8589. #region 插入操作记录
  8590. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8591. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8592. oper.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;
  8593. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  8594. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8595. oper.F_Message = userinfo + " 撤回了工单";
  8596. oper.F_CreateUser = userModel.F_UserCode;
  8597. oper.F_CreateTime = DateTime.Now;
  8598. oper.F_IsDelete = 0;
  8599. operBLL.Add(oper);
  8600. #endregion
  8601. trans.Complete();
  8602. }
  8603. return Success("操作成功");
  8604. }
  8605. else
  8606. {
  8607. return Error("操作失败");
  8608. }
  8609. }
  8610. else
  8611. {
  8612. return Error("权限不足");
  8613. }
  8614. }
  8615. /// <summary>
  8616. /// 签收工单
  8617. /// </summary>
  8618. /// <returns></returns>
  8619. [Authority]
  8620. public ActionResult SignWorkOrder()
  8621. {
  8622. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8623. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8624. if (userModel.F_RoleCode == "EJWLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8625. {
  8626. string workorderid = RequestString.GetFormString("workorderid");
  8627. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8628. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8629. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new BLL.T_Bus_AssignedInfo_Next().GetNewModelByWorkOrderID(workorderid);
  8630. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo_Next != null && modelT_Bus_AssignedInfo_Next.F_MainDeptId == userModel.F_DeptId)
  8631. {
  8632. if (modelT_Bus_AssignedInfo_Next.F_IsSure == 0)
  8633. {
  8634. using (TransactionScope trans = new TransactionScope())
  8635. {
  8636. #region 保存签收信息
  8637. modelT_Bus_AssignedInfo_Next.F_IsSure = 1;//签收
  8638. modelT_Bus_AssignedInfo_Next.F_SureUser = userModel.F_UserCode;
  8639. modelT_Bus_AssignedInfo_Next.F_SureTime = DateTime.Now;
  8640. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next);
  8641. #endregion
  8642. #region 保存交办信息
  8643. modelT_Bus_AssignedInfo.F_IsNext = 2;
  8644. new BLL.T_Bus_AssignedInfo().Update(modelT_Bus_AssignedInfo);
  8645. #endregion
  8646. #region 插入操作记录
  8647. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8648. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8649. oper.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;
  8650. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  8651. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8652. oper.F_Message = userinfo + " 签收了工单";
  8653. oper.F_CreateUser = userModel.F_UserCode;
  8654. oper.F_CreateTime = DateTime.Now;
  8655. oper.F_IsDelete = 0;
  8656. operBLL.Add(oper);
  8657. #endregion
  8658. trans.Complete();
  8659. }
  8660. return Success("操作成功");
  8661. }
  8662. else
  8663. {
  8664. return Error("单位已签收,不能再次签收");
  8665. }
  8666. }
  8667. else
  8668. {
  8669. return Error("操作失败");
  8670. }
  8671. }
  8672. else
  8673. {
  8674. return Error("权限不足");
  8675. }
  8676. }
  8677. /// <summary>
  8678. /// 拒收工单
  8679. /// </summary>
  8680. /// <returns></returns>
  8681. [Authority]
  8682. public ActionResult RefuseWorkOrder()
  8683. {
  8684. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8685. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8686. if (userModel.F_RoleCode == "EJWLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8687. {
  8688. string workorderid = RequestString.GetFormString("workorderid");
  8689. string reason = RequestString.GetFormString("reason");
  8690. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8691. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8692. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new BLL.T_Bus_AssignedInfo_Next().GetNewModelByWorkOrderID(workorderid);
  8693. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo_Next != null && modelT_Bus_AssignedInfo_Next.F_MainDeptId == userModel.F_DeptId)
  8694. {
  8695. if (modelT_Bus_AssignedInfo_Next.F_IsSure == 0)
  8696. {
  8697. using (TransactionScope trans = new TransactionScope())
  8698. {
  8699. #region 保存签收信息
  8700. modelT_Bus_AssignedInfo_Next.F_IsSure = 3;//签收
  8701. modelT_Bus_AssignedInfo_Next.F_SureUser = userModel.F_UserCode;
  8702. modelT_Bus_AssignedInfo_Next.F_SureTime = DateTime.Now;
  8703. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next);
  8704. #endregion
  8705. #region 保存交办信息
  8706. modelT_Bus_AssignedInfo.F_IsNext = 0;
  8707. new BLL.T_Bus_AssignedInfo().Update(modelT_Bus_AssignedInfo);
  8708. #endregion
  8709. #region 保存工单信息
  8710. modelT_Bus_WorkOrder.F_MainDeptID3 = null;
  8711. workorderBLL.Update(modelT_Bus_WorkOrder);
  8712. #endregion
  8713. #region 插入操作记录
  8714. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8715. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8716. oper.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;
  8717. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  8718. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8719. oper.F_Message = userinfo + " 拒收了工单,原因:" + reason;
  8720. oper.F_CreateUser = userModel.F_UserCode;
  8721. oper.F_CreateTime = DateTime.Now;
  8722. oper.F_IsDelete = 0;
  8723. operBLL.Add(oper);
  8724. #endregion
  8725. trans.Complete();
  8726. }
  8727. return Success("操作成功");
  8728. }
  8729. else
  8730. {
  8731. return Error("单位已签收,不能再次签收");
  8732. }
  8733. }
  8734. else
  8735. {
  8736. return Error("操作失败");
  8737. }
  8738. }
  8739. else
  8740. {
  8741. return Error("权限不足");
  8742. }
  8743. }
  8744. /// <summary>
  8745. /// 处理工单
  8746. /// </summary>
  8747. /// <returns></returns>
  8748. [Authority]
  8749. public ActionResult DealWorkOrder()
  8750. {
  8751. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8752. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8753. if (userModel.F_RoleCode == "EJWLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8754. {
  8755. string workorderid = RequestString.GetFormString("workorderid");
  8756. string dealman = RequestString.GetFormString("dealman");
  8757. string result = RequestString.GetFormString("result");
  8758. string files = RequestString.GetFormString("files");
  8759. int state = RequestString.GetInt("state", 0);
  8760. int dealid = RequestString.GetInt("dealid", 0);
  8761. int isproresult = RequestString.GetInt("isproresult", 0);//是否有处理结果:0默认,1是,2否
  8762. string prosituation = RequestString.GetFormString("prosituation");
  8763. string dealcontact = RequestString.GetFormString("dealcontact");
  8764. string connecttime = RequestString.GetFormString("connecttime");
  8765. string connectmode = RequestString.GetFormString("connectmode");
  8766. string replycontent = RequestString.GetFormString("replycontent");
  8767. int isstaisfied = RequestString.GetInt("isstaisfied", 0);
  8768. string duties = RequestString.GetFormString("duties");//职务
  8769. string situation = RequestString.GetFormString("situation");
  8770. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8771. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8772. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new BLL.T_Bus_AssignedInfo_Next().GetNewModelByWorkOrderID(workorderid);
  8773. Model.T_Bus_Feedback_Next modelT_Bus_Feedback_Next = new Model.T_Bus_Feedback_Next();
  8774. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo_Next != null && modelT_Bus_AssignedInfo_Next.F_MainDeptId == userModel.F_DeptId
  8775. && modelT_Bus_AssignedInfo_Next.F_IsSure == 1)
  8776. {
  8777. //if (modelT_Bus_WorkOrder.F_WorkState == 4 || modelT_Bus_WorkOrder.F_WorkState == 5)
  8778. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.auditdelay)
  8779. {
  8780. if (modelT_Bus_AssignedInfo.F_IsNext == 2)
  8781. {
  8782. using (TransactionScope trans = new TransactionScope())
  8783. {
  8784. if (dealid == 0)
  8785. {
  8786. #region 插入反馈记录
  8787. modelT_Bus_Feedback_Next.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8788. modelT_Bus_Feedback_Next.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;//交办id
  8789. modelT_Bus_Feedback_Next.F_DealUser = dealman;
  8790. modelT_Bus_Feedback_Next.F_Result = result;//反馈内容
  8791. #region 20200114新增字段 zhengbingbing
  8792. modelT_Bus_Feedback_Next.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  8793. modelT_Bus_Feedback_Next.F_ProSituation = prosituation;//处理情况/方案/进程
  8794. modelT_Bus_Feedback_Next.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  8795. modelT_Bus_Feedback_Next.F_DealUserContact = dealcontact;//承办人联系方式
  8796. DateTime contime = DateTime.Now;
  8797. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  8798. modelT_Bus_Feedback_Next.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  8799. modelT_Bus_Feedback_Next.F_ConnectMode = connectmode;//沟通方式
  8800. modelT_Bus_Feedback_Next.F_ReplyContent = replycontent;//答复内容
  8801. modelT_Bus_Feedback_Next.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  8802. modelT_Bus_Feedback_Next.F_Duties = duties;//职务
  8803. modelT_Bus_Feedback_Next.F_Situation = situation;
  8804. #endregion
  8805. modelT_Bus_Feedback_Next.F_File = files;
  8806. modelT_Bus_Feedback_Next.F_IsAudit = 0;
  8807. modelT_Bus_Feedback_Next.F_IsDelete = 0;
  8808. modelT_Bus_Feedback_Next.F_CreateUser = userModel.F_UserCode;//办理人
  8809. modelT_Bus_Feedback_Next.F_CreateTime = DateTime.Now;//办理时间
  8810. modelT_Bus_Feedback_Next.F_CreateDeptId = userModel.F_DeptId;//办理部门
  8811. modelT_Bus_Feedback_Next.F_IsFeedEnd = 1;
  8812. modelT_Bus_Feedback_Next.F_State = state;
  8813. modelT_Bus_Feedback_Next.F_Type = 1;
  8814. new BLL.T_Bus_Feedback_Next().Add(modelT_Bus_Feedback_Next);
  8815. #endregion
  8816. }
  8817. else
  8818. {
  8819. #region 修改反馈记录
  8820. modelT_Bus_Feedback_Next = new BLL.T_Bus_Feedback_Next().GetModel(dealid);
  8821. if (modelT_Bus_Feedback_Next != null)
  8822. {
  8823. modelT_Bus_Feedback_Next.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8824. modelT_Bus_Feedback_Next.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;//交办id
  8825. modelT_Bus_Feedback_Next.F_DealUser = dealman;
  8826. modelT_Bus_Feedback_Next.F_Result = result;//反馈内容
  8827. modelT_Bus_Feedback_Next.F_File = files;
  8828. #region 20200114新增字段 zhengbingbing
  8829. modelT_Bus_Feedback_Next.F_IsProResult = isproresult;//是否有处理结果:0默认,1是,2否
  8830. modelT_Bus_Feedback_Next.F_ProSituation = prosituation;//处理情况/方案/进程
  8831. modelT_Bus_Feedback_Next.F_IsProtect = modelT_Bus_WorkOrder.F_IsProtect;//是否保密(0:否1:是)
  8832. modelT_Bus_Feedback_Next.F_DealUserContact = dealcontact;//承办人联系方式
  8833. DateTime contime = DateTime.Now;
  8834. if (connecttime != "" && DateTime.TryParse(connecttime, out contime))
  8835. modelT_Bus_Feedback_Next.F_ConnectTime = DateTime.Parse(connecttime);//沟通时间
  8836. modelT_Bus_Feedback_Next.F_ConnectMode = connectmode;//沟通方式
  8837. modelT_Bus_Feedback_Next.F_ReplyContent = replycontent;//答复内容
  8838. modelT_Bus_Feedback_Next.F_IsSatisfied = isstaisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  8839. modelT_Bus_Feedback_Next.F_Duties = duties;//职务
  8840. modelT_Bus_Feedback_Next.F_Situation = situation;
  8841. #endregion
  8842. modelT_Bus_Feedback_Next.F_CreateUser = userModel.F_UserCode;//办理人
  8843. modelT_Bus_Feedback_Next.F_CreateTime = DateTime.Now;//办理时间
  8844. modelT_Bus_Feedback_Next.F_CreateDeptId = userModel.F_DeptId;//办理部门
  8845. modelT_Bus_Feedback_Next.F_IsFeedEnd = 1;
  8846. modelT_Bus_Feedback_Next.F_State = state;
  8847. new BLL.T_Bus_Feedback_Next().Update(modelT_Bus_Feedback_Next);
  8848. }
  8849. #endregion
  8850. }
  8851. if (modelT_Bus_Feedback_Next != null && modelT_Bus_Feedback_Next.F_State == 1)
  8852. {
  8853. #region 保存交办信息
  8854. modelT_Bus_AssignedInfo.F_IsNext = 3;
  8855. new BLL.T_Bus_AssignedInfo().Update(modelT_Bus_AssignedInfo);
  8856. #endregion
  8857. #region 保存派单信息
  8858. modelT_Bus_AssignedInfo_Next.F_FeedbackTime = DateTime.Now;
  8859. if (modelT_Bus_AssignedInfo_Next.F_LimitTime < DateTime.Now)
  8860. {
  8861. modelT_Bus_AssignedInfo_Next.F_IsOverdue = 1;
  8862. }
  8863. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next);
  8864. #endregion
  8865. #region 删除草稿信息
  8866. var cglist = new BLL.T_Bus_Feedback_Next().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  8867. foreach (var cg in cglist)
  8868. {
  8869. cg.F_IsDelete = 1;
  8870. cg.F_DeleteUser = userModel.F_UserCode;
  8871. cg.F_DeleteTime = DateTime.Now;
  8872. new BLL.T_Bus_Feedback_Next().Update(cg);
  8873. }
  8874. #endregion
  8875. #region 插入操作记录
  8876. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  8877. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  8878. oper.F_AssignedId = modelT_Bus_AssignedInfo_Next.F_Id;
  8879. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  8880. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  8881. oper.F_Message = userinfo + " 办理了工单";
  8882. oper.F_CreateUser = userModel.F_UserCode;
  8883. oper.F_CreateTime = DateTime.Now;
  8884. oper.F_IsDelete = 0;
  8885. operBLL.Add(oper);
  8886. //推送消息表
  8887. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_WorkOrder.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  8888. #endregion
  8889. }
  8890. trans.Complete();
  8891. }
  8892. return Success("操作成功", modelT_Bus_AssignedInfo_Next.F_Id);
  8893. }
  8894. else
  8895. {
  8896. return Error("已经办理过了");
  8897. }
  8898. }
  8899. else
  8900. {
  8901. return Error("已经办理过了");
  8902. }
  8903. }
  8904. else
  8905. {
  8906. return Error("操作失败");
  8907. }
  8908. }
  8909. else
  8910. {
  8911. return Error("权限不足");
  8912. }
  8913. }
  8914. /// <summary>
  8915. /// 审核派单
  8916. /// </summary>
  8917. /// <returns></returns>
  8918. [Authority]
  8919. public ActionResult AuditSplitWorkOrder()
  8920. {
  8921. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  8922. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  8923. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  8924. {
  8925. string workorderid = RequestString.GetFormString("workorderid");
  8926. int state = RequestString.GetInt("state", 0);
  8927. string reason = RequestString.GetFormString("reason");
  8928. int backid = RequestString.GetInt("backid", 0);
  8929. string files = RequestString.GetFormString("files");
  8930. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  8931. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  8932. Model.T_Bus_Feedback_Next modelT_Bus_Feedback_Next = new BLL.T_Bus_Feedback_Next().GetModel(backid);
  8933. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null && modelT_Bus_Feedback_Next != null)
  8934. {
  8935. if (modelT_Bus_Feedback_Next.F_IsAudit.Value == 0)
  8936. {
  8937. using (TransactionScope trans = new TransactionScope())
  8938. {
  8939. modelT_Bus_Feedback_Next.F_IsAudit = state;
  8940. modelT_Bus_Feedback_Next.F_AuditUser = userModel.F_UserCode;
  8941. modelT_Bus_Feedback_Next.F_AuditTime = DateTime.Now;
  8942. modelT_Bus_Feedback_Next.F_AuditReason = reason;
  8943. new BLL.T_Bus_Feedback_Next().Update(modelT_Bus_Feedback_Next);
  8944. string strmsg = "";
  8945. if (state == 1)
  8946. {
  8947. strmsg = "同意";
  8948. #region 插入反馈记录
  8949. Model.T_Bus_Feedback modelT_Bus_Feedback = new Model.T_Bus_Feedback();
  8950. modelT_Bus_Feedback.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单编号
  8951. modelT_Bus_Feedback.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;//交办id
  8952. modelT_Bus_Feedback.F_DealUser = modelT_Bus_Feedback_Next.F_DealUser;
  8953. modelT_Bus_Feedback.F_Result = modelT_Bus_Feedback_Next.F_Result;//反馈内容
  8954. #region 20200114新增字段 zhengbingbing
  8955. modelT_Bus_Feedback.F_IsProResult = modelT_Bus_Feedback_Next.F_IsProResult;//是否有处理结果:0默认,1是,2否
  8956. modelT_Bus_Feedback.F_ProSituation = modelT_Bus_Feedback_Next.F_ProSituation;//处理情况/方案/进程
  8957. modelT_Bus_Feedback.F_IsProtect = modelT_Bus_Feedback_Next.F_IsProtect;//是否保密(0:否1:是)
  8958. modelT_Bus_Feedback.F_DealUserContact = modelT_Bus_Feedback_Next.F_DealUserContact;//承办人联系方式
  8959. modelT_Bus_Feedback.F_ConnectTime = modelT_Bus_Feedback_Next.F_ConnectTime;//沟通时间
  8960. modelT_Bus_Feedback.F_ConnectMode = modelT_Bus_Feedback_Next.F_ConnectMode;//沟通方式
  8961. modelT_Bus_Feedback.F_ReplyContent = modelT_Bus_Feedback_Next.F_ReplyContent;//答复内容
  8962. modelT_Bus_Feedback.F_IsSatisfied = modelT_Bus_Feedback_Next.F_IsSatisfied;//是否满意:0未评价,1满意,2基本满意,3不满意
  8963. #endregion
  8964. modelT_Bus_Feedback.F_File = modelT_Bus_Feedback_Next.F_File;
  8965. modelT_Bus_Feedback.F_IsAudit = 0;
  8966. modelT_Bus_Feedback.F_IsDelete = 0;
  8967. modelT_Bus_Feedback.F_CreateUser = userModel.F_UserCode;//办理人
  8968. modelT_Bus_Feedback.F_CreateTime = DateTime.Now;//办理时间
  8969. modelT_Bus_Feedback.F_CreateDeptId = userModel.F_DeptId;//办理部门
  8970. modelT_Bus_Feedback.F_IsFeedEnd = 1;
  8971. modelT_Bus_Feedback.F_State = state;
  8972. modelT_Bus_Feedback.F_Type = 1;
  8973. new BLL.T_Bus_Feedback().Add(modelT_Bus_Feedback);
  8974. #endregion
  8975. if (modelT_Bus_AssignedInfo.F_LimitTime < DateTime.Now)
  8976. {
  8977. modelT_Bus_AssignedInfo.F_IsOverdue = 1;
  8978. modelT_Bus_WorkOrder.F_IsOverdue = 1;
  8979. }
  8980. #region 保存工单信息
  8981. //modelT_Bus_WorkOrder.F_WorkState = 6;//待回访
  8982. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.dealed;//待回访
  8983. modelT_Bus_WorkOrder.F_Result = modelT_Bus_Feedback_Next.F_Result;
  8984. modelT_Bus_WorkOrder.F_DealDeptId = modelT_Bus_Feedback_Next.F_CreateDeptId;
  8985. modelT_Bus_WorkOrder.F_DealUser = modelT_Bus_Feedback_Next.F_CreateUser;
  8986. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  8987. workorderBLL.Update(modelT_Bus_WorkOrder);
  8988. #endregion
  8989. #region 保存交办信息
  8990. modelT_Bus_AssignedInfo.F_FeedbackTime = DateTime.Now;
  8991. assignBLL.Update(modelT_Bus_AssignedInfo);
  8992. #endregion
  8993. #region 删除草稿信息
  8994. var cglist = new BLL.T_Bus_Feedback().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateDeptId='" + userModel.F_DeptId + "'");
  8995. foreach (var cg in cglist)
  8996. {
  8997. cg.F_IsDelete = 1;
  8998. cg.F_DeleteUser = userModel.F_UserCode;
  8999. cg.F_DeleteTime = DateTime.Now;
  9000. new BLL.T_Bus_Feedback().Update(cg);
  9001. }
  9002. #endregion
  9003. #region 处理协办单位
  9004. var xblist = new BLL.T_Bus_AssignedItemInfo().GetModelList(" F_IsDelete=0 and F_State=1 and ISNULL(F_FeedbackTime, '')='' and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  9005. foreach (var xb in xblist)
  9006. {
  9007. xb.F_State = 2;
  9008. xb.F_SureUser = userModel.F_UserCode;
  9009. xb.F_SureTime = DateTime.Now;
  9010. new BLL.T_Bus_AssignedItemInfo().Update(xb);
  9011. }
  9012. #endregion
  9013. }
  9014. else if (state == 2)
  9015. {
  9016. strmsg = "拒绝";
  9017. Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next1 = new BLL.T_Bus_AssignedInfo_Next().GetModel(modelT_Bus_Feedback_Next.F_AssignedId.Value);
  9018. modelT_Bus_AssignedInfo_Next1.F_FeedbackTime = null;
  9019. new BLL.T_Bus_AssignedInfo_Next().Update(modelT_Bus_AssignedInfo_Next1);
  9020. modelT_Bus_AssignedInfo.F_IsNext = 2;
  9021. assignBLL.Update(modelT_Bus_AssignedInfo);
  9022. //#region 插入派单记录
  9023. //Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next1 = new BLL.T_Bus_AssignedInfo_Next().GetModel(modelT_Bus_Feedback_Next.F_AssignedId.Value);
  9024. //Model.T_Bus_AssignedInfo_Next modelT_Bus_AssignedInfo_Next = new Model.T_Bus_AssignedInfo_Next();
  9025. //modelT_Bus_AssignedInfo_Next.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9026. //modelT_Bus_AssignedInfo_Next.F_LimitTime = modelT_Bus_AssignedInfo_Next1.F_LimitTime;//办理时限
  9027. //modelT_Bus_AssignedInfo_Next.F_MainDeptId = modelT_Bus_AssignedInfo_Next1.F_MainDeptId;//主办单位id
  9028. //modelT_Bus_AssignedInfo_Next.F_OtherDeptIds = modelT_Bus_AssignedInfo_Next1.F_OtherDeptIds;//协办单位id
  9029. //modelT_Bus_AssignedInfo_Next.F_AssignedOpinion = reason;//交办意见
  9030. //modelT_Bus_AssignedInfo_Next.F_State = state;//0草稿 1正式
  9031. //modelT_Bus_AssignedInfo_Next.F_CreateUser = userModel.F_UserCode;
  9032. //modelT_Bus_AssignedInfo_Next.F_CreateTime = DateTime.Now;
  9033. //modelT_Bus_AssignedInfo_Next.F_IsDelete = 0;
  9034. //modelT_Bus_AssignedInfo_Next.F_IsOverdue = 0;
  9035. //modelT_Bus_AssignedInfo_Next.F_IsSure = 0;
  9036. //modelT_Bus_AssignedInfo_Next.F_IsReload = 0;
  9037. //modelT_Bus_AssignedInfo_Next.F_Id = new BLL.T_Bus_AssignedInfo_Next().Add(modelT_Bus_AssignedInfo_Next);
  9038. //#endregion
  9039. }
  9040. #region 插入操作记录
  9041. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9042. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9043. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9044. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9045. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9046. oper.F_Message = userinfo + " " + strmsg + "了此处理";
  9047. oper.F_CreateUser = userModel.F_UserCode;
  9048. oper.F_CreateTime = DateTime.Now;
  9049. oper.F_IsDelete = 0;
  9050. operBLL.Add(oper);
  9051. //推送消息表
  9052. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_WorkOrder.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  9053. #endregion
  9054. trans.Complete();
  9055. }
  9056. return Success("操作成功");
  9057. }
  9058. else
  9059. {
  9060. return Error("已经审核过了");
  9061. }
  9062. }
  9063. else
  9064. {
  9065. return Error("操作失败");
  9066. }
  9067. }
  9068. else
  9069. {
  9070. return Error("权限不足");
  9071. }
  9072. }
  9073. /// <summary>
  9074. /// 回访工单
  9075. /// </summary>
  9076. /// <returns></returns>
  9077. [Authority]
  9078. public ActionResult VisitWorkOrder()
  9079. {
  9080. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9081. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9082. //if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY")
  9083. if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9084. {
  9085. string workorderid = RequestString.GetFormString("workorderid");
  9086. string visituser = RequestString.GetFormString("visituser");//回访人
  9087. int type = RequestString.GetInt("type", 0);//回访方式
  9088. int issatisfie = RequestString.GetInt("issatisfie", 0);//0不满意 1满意
  9089. //DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime"));//不满意,重办的办理时限
  9090. int state = RequestString.GetInt("state", 0);//0保存 1保存并下一步
  9091. int visitid = RequestString.GetInt("visitid", 0);
  9092. string result = RequestString.GetFormString("result");//回访情况
  9093. int nexttype = RequestString.GetInt("nexttype", 0);//1重办 2结案
  9094. //string overseeopinion = RequestString.GetFormString("overseeopinion");//督办意见
  9095. //string finalopinion = RequestString.GetFormString("finalopinion");//结案意见
  9096. string cbreason = RequestString.GetFormString("cbreason");//重办原因
  9097. string callid = RequestString.GetFormString("callid");
  9098. string guid = RequestString.GetFormString("guid");
  9099. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9100. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  9101. Model.T_Bus_VisitResult modelT_Bus_VisitResult = new Model.T_Bus_VisitResult();
  9102. if (modelT_Bus_WorkOrder != null)
  9103. {
  9104. //if (modelT_Bus_WorkOrder.F_WorkState == 6)
  9105. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealed)
  9106. {
  9107. using (TransactionScope trans = new TransactionScope())
  9108. {
  9109. #region 回访
  9110. if (visitid == 0)
  9111. {
  9112. #region 新增回访结果记录
  9113. modelT_Bus_VisitResult.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9114. modelT_Bus_VisitResult.F_AssignedId = 0;
  9115. modelT_Bus_VisitResult.F_VisitUser = visituser;
  9116. modelT_Bus_VisitResult.F_Type = type;
  9117. modelT_Bus_VisitResult.F_IsSatisfie = issatisfie;
  9118. modelT_Bus_VisitResult.F_Result = result;
  9119. modelT_Bus_VisitResult.F_State = state;
  9120. if (!string.IsNullOrEmpty(callid))
  9121. {
  9122. var rd = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  9123. if (rd != null)
  9124. {
  9125. modelT_Bus_VisitResult.F_CallRecordId = rd.CallRecordsId;
  9126. }
  9127. }
  9128. //modelT_Bus_VisitResult.F_LimitTime = newlimittime;
  9129. modelT_Bus_VisitResult.F_IsDelete = 0;
  9130. modelT_Bus_VisitResult.F_CreateUser = userModel.F_UserCode;
  9131. modelT_Bus_VisitResult.F_CreateTime = DateTime.Now;
  9132. if (modelT_Bus_AssignedInfo != null)
  9133. {
  9134. modelT_Bus_VisitResult.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9135. }
  9136. int id = new BLL.T_Bus_VisitResult().Add(modelT_Bus_VisitResult);
  9137. modelT_Bus_VisitResult.F_Id = id;
  9138. //保存回访记录
  9139. new BLL.T_Bus_VisitResultRecords().AddInfo(modelT_Bus_VisitResult, userModel.F_UserCode, guid);
  9140. #endregion
  9141. }
  9142. else
  9143. {
  9144. #region 修改回访结果记录
  9145. modelT_Bus_VisitResult = new BLL.T_Bus_VisitResult().GetModel(visitid);
  9146. if (modelT_Bus_VisitResult != null)
  9147. {
  9148. modelT_Bus_VisitResult.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9149. modelT_Bus_VisitResult.F_AssignedId = 0;
  9150. modelT_Bus_VisitResult.F_VisitUser = visituser;
  9151. modelT_Bus_VisitResult.F_Type = type;
  9152. modelT_Bus_VisitResult.F_IsSatisfie = issatisfie;
  9153. modelT_Bus_VisitResult.F_Result = result;
  9154. modelT_Bus_VisitResult.F_State = state;
  9155. if (!string.IsNullOrEmpty(callid))
  9156. {
  9157. var rd = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  9158. if (rd != null)
  9159. {
  9160. modelT_Bus_VisitResult.F_CallRecordId = rd.CallRecordsId;
  9161. }
  9162. }
  9163. //modelT_Bus_VisitResult.F_LimitTime = newlimittime;
  9164. modelT_Bus_VisitResult.F_IsDelete = 0;
  9165. modelT_Bus_VisitResult.F_CreateUser = userModel.F_UserCode;
  9166. modelT_Bus_VisitResult.F_CreateTime = DateTime.Now;
  9167. if (modelT_Bus_AssignedInfo != null)
  9168. {
  9169. modelT_Bus_VisitResult.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9170. }
  9171. int id = new BLL.T_Bus_VisitResult().Add(modelT_Bus_VisitResult);
  9172. modelT_Bus_VisitResult.F_Id = id;
  9173. //保存回访记录
  9174. new BLL.T_Bus_VisitResultRecords().AddInfo(modelT_Bus_VisitResult, userModel.F_UserCode, guid);
  9175. }
  9176. #endregion
  9177. }
  9178. if (modelT_Bus_VisitResult != null && modelT_Bus_VisitResult.F_State == 1)
  9179. {
  9180. #region 保存交办信息
  9181. modelT_Bus_AssignedInfo.F_IsSatisfie = issatisfie;
  9182. assignBLL.Update(modelT_Bus_AssignedInfo);
  9183. #endregion
  9184. #region 保存工单信息
  9185. //modelT_Bus_WorkOrder.F_WorkState = 7;//已回访
  9186. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.visit;//已回访
  9187. workorderBLL.Update(modelT_Bus_WorkOrder);
  9188. #endregion
  9189. #region 删除草稿信息
  9190. var cglist = new BLL.T_Bus_VisitResult().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  9191. foreach (var cg in cglist)
  9192. {
  9193. cg.F_IsDelete = 1;
  9194. cg.F_DeleteUser = userModel.F_UserCode;
  9195. cg.F_DeleteTime = DateTime.Now;
  9196. new BLL.T_Bus_VisitResult().Update(cg);
  9197. //保存回访记录
  9198. new BLL.T_Bus_VisitResultRecords().AddInfo(modelT_Bus_VisitResult, userModel.F_UserCode, guid);
  9199. }
  9200. #endregion
  9201. var opt = "回访"; var cbreasons = "";
  9202. #region 重办
  9203. if (nexttype == 1)
  9204. {
  9205. #region 保存工单信息
  9206. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.resubmit;//重办待交办
  9207. workorderBLL.Update(modelT_Bus_WorkOrder);
  9208. #endregion
  9209. opt = "回访并提交重办";
  9210. cbreasons = ",重办原因:"+ cbreason;
  9211. }
  9212. #endregion
  9213. #region 插入操作记录
  9214. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9215. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9216. oper.F_AssignedId = modelT_Bus_VisitResult.F_AssignedId;
  9217. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9218. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9219. oper.F_Message = userinfo+" " + opt + "了工单,结果:" + (issatisfie == 1 ? "满意" : "不满意")+ cbreasons;
  9220. oper.F_CreateUser = userModel.F_UserCode;
  9221. oper.F_CreateTime = DateTime.Now;
  9222. oper.F_IsDelete = 0;
  9223. operBLL.Add(oper);
  9224. //推送消息表
  9225. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_AssignedInfo.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  9226. #endregion
  9227. #region 自动语音回访
  9228. if (issatisfie == 1)//如果满意就进行自动语音回访
  9229. {
  9230. var configacb = configBll.GetModelList(" F_ParamCode='AutoCallBack' ").FirstOrDefault();
  9231. if (configacb != null && configacb.F_ParamValue == "1")//如果为1就是开启了自动语音回访,其他都是关闭
  9232. {
  9233. string AutoCallMsg = string.Empty;
  9234. new BLL.T_CTI_Task().AddToAutoVoiceNotice(modelT_Bus_WorkOrder.F_CusPhone, modelT_Bus_WorkOrder.F_WorkOrderId, modelT_Bus_AssignedInfo.F_Id, out AutoCallMsg);
  9235. }
  9236. }
  9237. #endregion
  9238. }
  9239. #endregion
  9240. trans.Complete();
  9241. }
  9242. return Success("操作成功", modelT_Bus_VisitResult.F_Id);
  9243. }
  9244. else
  9245. {
  9246. return Error("已经回访过了");
  9247. }
  9248. }
  9249. else
  9250. {
  9251. return Error("操作失败");
  9252. }
  9253. }
  9254. else
  9255. {
  9256. return Error("权限不足");
  9257. }
  9258. }
  9259. #region 20200311 zhengbingbing 增加履职界定操作
  9260. /// <summary>
  9261. /// 履职
  9262. /// </summary>
  9263. /// <returns></returns>
  9264. [Authority]
  9265. public ActionResult PerformWorkOrder()
  9266. {
  9267. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9268. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9269. if (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9270. {//承办单位和管理员
  9271. string workorderid = RequestString.GetFormString("workorderid");
  9272. int state = RequestString.GetInt("state", 0);//0保存 1保存并下一步
  9273. int perid = RequestString.GetInt("perid", 0);
  9274. string file = RequestString.GetFormString("file");
  9275. string result = RequestString.GetFormString("result");
  9276. string guid = RequestString.GetFormString("guid");
  9277. string visitids = RequestString.GetFormString("visitids");
  9278. if (string.IsNullOrWhiteSpace(visitids))
  9279. return Error("请选择你要履职的回访记录");
  9280. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9281. List<Model.T_Bus_VisitResult> listT_Bus_VisitResult = new BLL.T_Bus_VisitResult().GetModelList("F_Id in ("+ visitids + ")");
  9282. Model.T_Bus_PerformDuties modelT_Bus_PerformDuties = new Model.T_Bus_PerformDuties();
  9283. if (modelT_Bus_WorkOrder != null)
  9284. {
  9285. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit|| modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.reload || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.rejload || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)
  9286. {//已回访,重办待交办,重办中,重办驳回,已结案
  9287. using (TransactionScope trans = new TransactionScope())
  9288. {
  9289. var assids = ""; //读取对应的交办记录
  9290. #region 读取对应的交办id
  9291. foreach (var item in listT_Bus_VisitResult)
  9292. {
  9293. if (item.F_AssignedId != null && item.F_AssignedId != 0)
  9294. assids = item.F_AssignedId + ",";
  9295. }
  9296. assids = assids.Trim(',');
  9297. #endregion
  9298. #region 履职
  9299. if (perid == 0)
  9300. {
  9301. #region 新增履职记录
  9302. modelT_Bus_PerformDuties.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9303. modelT_Bus_PerformDuties.F_AssignedId = assids;
  9304. modelT_Bus_PerformDuties.F_VisitId = visitids;
  9305. modelT_Bus_PerformDuties.F_File = file;
  9306. modelT_Bus_PerformDuties.F_State = state;
  9307. modelT_Bus_PerformDuties.F_Result = result;
  9308. modelT_Bus_PerformDuties.F_IsAudit = 0;
  9309. modelT_Bus_PerformDuties.F_IsDelete = 0;
  9310. modelT_Bus_PerformDuties.F_CreateDeptId = userModel.F_DeptId;
  9311. modelT_Bus_PerformDuties.F_CreateTime = DateTime.Now;
  9312. modelT_Bus_PerformDuties.F_CreateUser = userModel.F_UserCode;
  9313. int id=new BLL.T_Bus_PerformDuties().Add(modelT_Bus_PerformDuties);
  9314. modelT_Bus_PerformDuties.F_Id = id;
  9315. //保存回访记录
  9316. new BLL.T_Bus_PerformDutiesRecords().AddInfo(modelT_Bus_PerformDuties, userModel.F_UserCode, guid);
  9317. #endregion
  9318. }
  9319. else
  9320. {
  9321. #region 修改履职记录
  9322. modelT_Bus_PerformDuties = new BLL.T_Bus_PerformDuties().GetModel(perid);
  9323. if (modelT_Bus_PerformDuties != null)
  9324. {
  9325. modelT_Bus_PerformDuties.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9326. modelT_Bus_PerformDuties.F_AssignedId = assids;
  9327. modelT_Bus_PerformDuties.F_VisitId = visitids;
  9328. modelT_Bus_PerformDuties.F_File = file;
  9329. modelT_Bus_PerformDuties.F_State = state;
  9330. modelT_Bus_PerformDuties.F_Result = result;
  9331. modelT_Bus_PerformDuties.F_IsAudit = 0;
  9332. modelT_Bus_PerformDuties.F_IsDelete = 0;
  9333. modelT_Bus_PerformDuties.F_CreateDeptId = userModel.F_DeptId;
  9334. modelT_Bus_PerformDuties.F_CreateTime = DateTime.Now;
  9335. modelT_Bus_PerformDuties.F_CreateUser = userModel.F_UserCode;
  9336. int id = new BLL.T_Bus_PerformDuties().Add(modelT_Bus_PerformDuties);
  9337. modelT_Bus_PerformDuties.F_Id = id;
  9338. //保存回访记录
  9339. new BLL.T_Bus_PerformDutiesRecords().AddInfo(modelT_Bus_PerformDuties, userModel.F_UserCode, guid);
  9340. }
  9341. #endregion
  9342. }
  9343. if (modelT_Bus_PerformDuties != null && modelT_Bus_PerformDuties.F_State == 1)
  9344. {
  9345. #region 保存交办信息
  9346. foreach (var item in assids.Split(','))
  9347. {
  9348. var model = assignBLL.GetModel(int.Parse(item));
  9349. if (model != null)
  9350. {
  9351. model.F_IsPerform = 1;
  9352. assignBLL.Update(model);
  9353. }
  9354. }
  9355. #endregion
  9356. #region
  9357. foreach (var item in listT_Bus_VisitResult)
  9358. {
  9359. item.F_IsPerform = 1;
  9360. new BLL.T_Bus_VisitResult().Update(item);
  9361. }
  9362. #endregion
  9363. #region 删除草稿信息
  9364. var cglist = new BLL.T_Bus_PerformDuties().GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_CreateUser='" + userModel.F_UserCode + "' ");
  9365. foreach (var cg in cglist)
  9366. {
  9367. cg.F_IsDelete = 1;
  9368. cg.F_DeleteUser = userModel.F_UserCode;
  9369. cg.F_DeleteTime = DateTime.Now;
  9370. new BLL.T_Bus_PerformDuties().Update(cg);
  9371. new BLL.T_Bus_PerformDutiesRecords().AddInfo(cg, userModel.F_UserCode, guid);
  9372. }
  9373. #endregion
  9374. var opt = "履职界定";
  9375. #region 插入操作记录
  9376. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9377. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9378. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9379. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9380. oper.F_Message = userinfo + " 对工单提交 " + opt + " 操作";
  9381. oper.F_File = modelT_Bus_PerformDuties.F_File;
  9382. oper.F_CreateUser = userModel.F_UserCode;
  9383. oper.F_CreateTime = DateTime.Now;
  9384. oper.F_IsDelete = 0;
  9385. foreach (var item in assids.Split(','))
  9386. {
  9387. oper.F_AssignedId = int.Parse(item);
  9388. operBLL.Add(oper);
  9389. //推送消息表 履职界定消息目前推送给工号8666
  9390. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, "8666", userModel.F_UserCode, (int)EnumSmsType.workorder);
  9391. }
  9392. #endregion
  9393. }
  9394. #endregion
  9395. trans.Complete();
  9396. }
  9397. return Success("操作成功", modelT_Bus_PerformDuties.F_Id);
  9398. }
  9399. else
  9400. {
  9401. return Error("此状态下不能进行履职操作");
  9402. }
  9403. }
  9404. else
  9405. {
  9406. return Error("操作失败");
  9407. }
  9408. }
  9409. else
  9410. {
  9411. return Error("权限不足");
  9412. }
  9413. }
  9414. /// <summary>
  9415. /// 履职界定审核
  9416. /// </summary>
  9417. /// <returns></returns>
  9418. [Authority]
  9419. public ActionResult DefinitionWorkOrder() {
  9420. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9421. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9422. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9423. {
  9424. string workorderid = RequestString.GetFormString("workorderid");
  9425. int state = RequestString.GetInt("state", 0);
  9426. string reason = RequestString.GetFormString("reason");
  9427. int perid = RequestString.GetInt("perid", 0);
  9428. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9429. Model.T_Bus_PerformDuties modelT_Bus_PerformDuties = new BLL.T_Bus_PerformDuties().GetModel(perid);
  9430. if (modelT_Bus_WorkOrder != null && modelT_Bus_PerformDuties != null)
  9431. {
  9432. if (modelT_Bus_PerformDuties.F_IsAudit.Value == 0)
  9433. {
  9434. using (TransactionScope trans = new TransactionScope())
  9435. {
  9436. #region 保存履职界定信息
  9437. modelT_Bus_PerformDuties.F_IsAudit = state;
  9438. modelT_Bus_PerformDuties.F_AuditUser = userModel.F_UserCode;
  9439. modelT_Bus_PerformDuties.F_AuditTime = DateTime.Now;
  9440. modelT_Bus_PerformDuties.F_AuditReason = reason;
  9441. new BLL.T_Bus_PerformDuties().Update(modelT_Bus_PerformDuties);
  9442. #endregion
  9443. string strmsg = ""; var isperform = 1; int IsSatisfie = 0;
  9444. #region
  9445. if (state == 1)
  9446. {
  9447. strmsg = "同意";
  9448. isperform = 2;
  9449. IsSatisfie = 1;
  9450. }
  9451. else if (state == 2)
  9452. {
  9453. strmsg = "拒绝";
  9454. isperform = 3;
  9455. }
  9456. #endregion
  9457. #region 交办记录处理
  9458. foreach (var item in modelT_Bus_PerformDuties.F_AssignedId.Split(','))
  9459. {
  9460. var model = assignBLL.GetModel(int.Parse(item));
  9461. if (model != null)
  9462. {
  9463. model.F_IsPerform = isperform;
  9464. if (state == 1)//同意此履职界定则修改回访结果为满意
  9465. model.F_IsSatisfie = IsSatisfie;
  9466. assignBLL.Update(model);
  9467. }
  9468. }
  9469. #endregion
  9470. #region 回访记录处理
  9471. foreach (var item in modelT_Bus_PerformDuties.F_VisitId.Split(','))
  9472. {
  9473. var model = new BLL.T_Bus_VisitResult().GetModel(int.Parse(item));
  9474. if (model != null)
  9475. {
  9476. model.F_IsPerform = isperform;
  9477. if (state == 1)//同意此履职界定则修改回访结果为满意
  9478. model.F_IsSatisfie = IsSatisfie;
  9479. new BLL.T_Bus_VisitResult().Update(model);
  9480. }
  9481. }
  9482. #endregion
  9483. #region 插入操作记录
  9484. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9485. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9486. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9487. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9488. oper.F_Message = userinfo + " " + strmsg + "了此处理";
  9489. if (!string.IsNullOrWhiteSpace(reason))
  9490. oper.F_Message = oper.F_Message + ",理由为:"+ reason;
  9491. oper.F_CreateUser = userModel.F_UserCode;
  9492. oper.F_CreateTime = DateTime.Now;
  9493. oper.F_IsDelete = 0;
  9494. foreach (var item in modelT_Bus_PerformDuties.F_AssignedId.Split(','))
  9495. {
  9496. oper.F_AssignedId = int.Parse(item);
  9497. operBLL.Add(oper);
  9498. //推送消息表
  9499. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, modelT_Bus_PerformDuties.F_CreateUser, userModel.F_UserCode, (int)EnumSmsType.workorder);
  9500. }
  9501. #endregion
  9502. trans.Complete();
  9503. }
  9504. return Success("操作成功");
  9505. }
  9506. else
  9507. return Error("已经审核过了");
  9508. }
  9509. else
  9510. return Error("操作失败");
  9511. }
  9512. else
  9513. return Error("权限不足");
  9514. }
  9515. #endregion
  9516. /// <summary>
  9517. /// 督办或监察工单
  9518. /// </summary>
  9519. /// <returns></returns>
  9520. [Authority]
  9521. public ActionResult RemindWorkOrder()
  9522. {
  9523. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9524. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9525. string workorderid = RequestString.GetFormString("workorderid");
  9526. int type = RequestString.GetInt("type", 0);//1督办 2监察
  9527. int state = RequestString.GetInt("state", 0);//0待办 1已办 2退回
  9528. string overseeopinion = RequestString.GetFormString("overseeopinion");//督办意见
  9529. string files = RequestString.GetFormString("files");
  9530. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9531. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  9532. if (modelT_Bus_WorkOrder != null && modelT_Bus_AssignedInfo != null)
  9533. {
  9534. using (TransactionScope trans = new TransactionScope())
  9535. {
  9536. #region 插入督办记录
  9537. Model.T_Bus_RemindRecord modelT_Bus_RemindRecord = new Model.T_Bus_RemindRecord();
  9538. if (type == 1 && state > 0)
  9539. {
  9540. modelT_Bus_RemindRecord = new BLL.T_Bus_RemindRecord().GetModelList(" F_State=0 and F_IsDelete=0 and F_Type =1 order by F_CreateTime desc").FirstOrDefault();
  9541. if(modelT_Bus_RemindRecord!=null)
  9542. {
  9543. modelT_Bus_RemindRecord.F_Content = overseeopinion;
  9544. modelT_Bus_RemindRecord.F_State = state;
  9545. new BLL.T_Bus_RemindRecord().Update(modelT_Bus_RemindRecord);
  9546. }
  9547. }
  9548. else
  9549. {
  9550. modelT_Bus_RemindRecord.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9551. modelT_Bus_RemindRecord.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9552. modelT_Bus_RemindRecord.F_Type = type;
  9553. modelT_Bus_RemindRecord.F_DeptId = modelT_Bus_AssignedInfo.F_MainDeptId;
  9554. modelT_Bus_RemindRecord.F_Content = overseeopinion;
  9555. modelT_Bus_RemindRecord.F_File = files;
  9556. modelT_Bus_RemindRecord.F_State = state;//0待办 1已办 2退回
  9557. modelT_Bus_RemindRecord.F_IsDelete = 0;
  9558. modelT_Bus_RemindRecord.F_CreateUser = userModel.F_UserCode;
  9559. modelT_Bus_RemindRecord.F_CreateTime = DateTime.Now;
  9560. new BLL.T_Bus_RemindRecord().Add(modelT_Bus_RemindRecord);
  9561. }
  9562. #endregion
  9563. #region 插入操作记录
  9564. string typename = "督办";
  9565. if (type == 2) { typename = "监察"; }
  9566. if (type == 1 && state==0) { typename = "提交督办"; }
  9567. if (type == 1 && state == 1) { typename = "督办"; }
  9568. if (type == 1 && state == 2) { typename = "退回督办"; }
  9569. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9570. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9571. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9572. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9573. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9574. oper.F_Message = userinfo + " " + typename + "了工单";
  9575. oper.F_CreateUser = userModel.F_UserCode;
  9576. oper.F_CreateTime = DateTime.Now;
  9577. oper.F_IsDelete = 0;
  9578. operBLL.Add(oper);
  9579. #endregion
  9580. trans.Complete();
  9581. }
  9582. return Success("操作成功");
  9583. }
  9584. else
  9585. {
  9586. return Error("操作失败");
  9587. }
  9588. }
  9589. /// <summary>
  9590. /// 重办工单
  9591. /// </summary>
  9592. /// <returns></returns>
  9593. [Authority]
  9594. public ActionResult ReloadWorkOrder()
  9595. {
  9596. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9597. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9598. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9599. //if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY")
  9600. {
  9601. string workorderid = RequestString.GetFormString("workorderid");
  9602. string overseeopinion = RequestString.GetFormString("overseeopinion");//督办意见
  9603. DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime") + " 23:59:59");//不满意,重办的办理时限
  9604. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9605. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  9606. if (modelT_Bus_WorkOrder != null)
  9607. {
  9608. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  9609. {
  9610. return Error("操作失败");
  9611. }
  9612. //if (modelT_Bus_WorkOrder.F_WorkState == 7)
  9613. //if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit)
  9614. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit)
  9615. {
  9616. using (TransactionScope trans = new TransactionScope())
  9617. {
  9618. #region 插入督办记录
  9619. Model.T_Bus_RemindRecord modelT_Bus_RemindRecord = new Model.T_Bus_RemindRecord();
  9620. modelT_Bus_RemindRecord.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9621. modelT_Bus_RemindRecord.F_AssignedId = 0;
  9622. modelT_Bus_RemindRecord.F_Type = 1;
  9623. if (modelT_Bus_AssignedInfo != null)//转办后重办
  9624. {
  9625. #region 插入交办记录
  9626. int n = Int32.Parse(DbHelperSQL.GetSingle("select count(1) from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_State=1 and F_IsSure=1 and F_IsDelete=0 and isnull(F_IsReload,0)>0").ToString());
  9627. modelT_Bus_WorkOrder.F_IsReload = n + 1;
  9628. modelT_Bus_WorkOrder.F_LimitTime = newlimittime;
  9629. modelT_Bus_WorkOrder.F_IsOverdue = 0;
  9630. Model.T_Bus_AssignedInfo AssignedInfo = new Model.T_Bus_AssignedInfo();
  9631. AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9632. AssignedInfo.F_LimitTime = newlimittime;//办理时限
  9633. AssignedInfo.F_MainDeptId = modelT_Bus_AssignedInfo.F_MainDeptId;//主办单位id
  9634. AssignedInfo.F_OtherDeptIds = modelT_Bus_AssignedInfo.F_OtherDeptIds;//协办单位id
  9635. AssignedInfo.F_AssignedOpinion = modelT_Bus_AssignedInfo.F_AssignedOpinion;//交办意见
  9636. AssignedInfo.F_State = 1;//0草稿 1正式
  9637. AssignedInfo.F_CreateUser = modelT_Bus_AssignedInfo.F_CreateUser;
  9638. AssignedInfo.F_CreateTime = modelT_Bus_AssignedInfo.F_CreateTime;
  9639. AssignedInfo.F_IsDelete = 0;
  9640. AssignedInfo.F_IsOverdue = 0;
  9641. AssignedInfo.F_IsSure = 0;
  9642. AssignedInfo.F_IsReload = n + 1;
  9643. AssignedInfo.F_ReloadUser = userModel.F_UserCode;
  9644. AssignedInfo.F_ReloadTime = DateTime.Now;
  9645. assignBLL.Add(AssignedInfo);
  9646. #endregion
  9647. modelT_Bus_RemindRecord.F_AssignedId = AssignedInfo.F_Id;
  9648. modelT_Bus_RemindRecord.F_DeptId = AssignedInfo.F_MainDeptId;
  9649. }
  9650. else if (modelT_Bus_WorkOrder.F_IsResult == 1)//直办后重办
  9651. {
  9652. var cruser = userBLL.GetModel(modelT_Bus_WorkOrder.F_CreateUser);
  9653. if (cruser != null)
  9654. {
  9655. modelT_Bus_RemindRecord.F_DeptId = cruser.F_DeptId;
  9656. }
  9657. }
  9658. modelT_Bus_RemindRecord.F_Content = overseeopinion;
  9659. modelT_Bus_RemindRecord.F_State = 1;
  9660. modelT_Bus_RemindRecord.F_IsDelete = 0;
  9661. modelT_Bus_RemindRecord.F_CreateUser = userModel.F_UserCode;
  9662. modelT_Bus_RemindRecord.F_CreateTime = DateTime.Now;
  9663. new BLL.T_Bus_RemindRecord().Add(modelT_Bus_RemindRecord);
  9664. #endregion
  9665. #region 保存工单信息
  9666. //modelT_Bus_WorkOrder.F_WorkState = 8;//重办中
  9667. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.reload;//重办中
  9668. modelT_Bus_WorkOrder.F_Result = "";
  9669. modelT_Bus_WorkOrder.F_DealDeptId = null;
  9670. modelT_Bus_WorkOrder.F_DealUser = "";
  9671. modelT_Bus_WorkOrder.F_DealTime = null;
  9672. workorderBLL.Update(modelT_Bus_WorkOrder);
  9673. #endregion
  9674. #region 插入操作记录
  9675. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9676. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9677. if (modelT_Bus_AssignedInfo != null)
  9678. {
  9679. oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  9680. }
  9681. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9682. string deptname = "";
  9683. #region 20191021调整为多个主办单位时调整
  9684. var deptinfo = new BLL.T_Sys_Department().GetModel(modelT_Bus_AssignedInfo.F_MainDeptId.Value);
  9685. if (deptinfo != null) { deptname = deptinfo.F_DeptName; }
  9686. #endregion
  9687. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9688. oper.F_Message = userinfo + " 重办并督办了工单,交办单位:" + deptname;
  9689. oper.F_CreateUser = userModel.F_UserCode;
  9690. oper.F_CreateTime = DateTime.Now;
  9691. oper.F_IsDelete = 0;
  9692. operBLL.Add(oper);
  9693. //推送消息表
  9694. var users = userBLL.GetModelList(" F_DeptId='" + modelT_Bus_AssignedInfo.F_MainDeptId + "' ");
  9695. foreach (var u in users)
  9696. {
  9697. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  9698. }
  9699. #endregion
  9700. trans.Complete();
  9701. }
  9702. return Success("操作成功");
  9703. }
  9704. else
  9705. {
  9706. return Error("已经处理过了");
  9707. }
  9708. }
  9709. else
  9710. {
  9711. return Error("操作失败");
  9712. }
  9713. }
  9714. else
  9715. {
  9716. return Error("权限不足");
  9717. }
  9718. }
  9719. /// <summary>
  9720. /// 重办提交工单 提交后为重办待交办
  9721. /// </summary>
  9722. /// <returns></returns>
  9723. [Authority]
  9724. public ActionResult SubReloadWorkOrder(string[] ids, string reason)
  9725. {
  9726. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9727. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9728. if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9729. {
  9730. if (ids != null && ids.Length > 0)
  9731. {
  9732. foreach (string str in ids)
  9733. {
  9734. using (TransactionScope trans = new TransactionScope())
  9735. {
  9736. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(str);
  9737. if (modelT_Bus_WorkOrder != null)
  9738. {
  9739. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.rejload)
  9740. {
  9741. #region 保存工单信息
  9742. modelT_Bus_WorkOrder.F_SubmitTime = DateTime.Now;
  9743. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.resubmit;//待交办
  9744. #region 重办待交办时-主办单位清空 zhengbingbing 20191016
  9745. modelT_Bus_WorkOrder.F_MainDeptId = null;
  9746. modelT_Bus_WorkOrder.F_OtherDeptIds = "";
  9747. modelT_Bus_WorkOrder.F_DealDeptId = null;
  9748. #endregion
  9749. workorderBLL.Update(modelT_Bus_WorkOrder);
  9750. #endregion
  9751. #region 插入操作记录
  9752. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9753. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9754. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9755. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9756. oper.F_Message = userinfo + " 提交重办了工单,重办原因:" + reason;
  9757. oper.F_CreateUser = userModel.F_UserCode;
  9758. oper.F_CreateTime = DateTime.Now;
  9759. oper.F_IsDelete = 0;
  9760. operBLL.Add(oper);
  9761. #endregion
  9762. }
  9763. }
  9764. trans.Complete();
  9765. }
  9766. }
  9767. return Success("操作成功");
  9768. }
  9769. else
  9770. {
  9771. return Error("操作失败");
  9772. }
  9773. }
  9774. else
  9775. {
  9776. return Error("权限不足");
  9777. }
  9778. }
  9779. /// <summary>
  9780. /// 驳回重办,驳回后状态为重办驳回状态
  9781. /// 调度员可驳回
  9782. /// </summary>
  9783. /// <param name="ids"></param>
  9784. /// <returns></returns>
  9785. [Authority]
  9786. public ActionResult RejReloadWorkOrder(string id,string reason)
  9787. {
  9788. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9789. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9790. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9791. {
  9792. if (!string.IsNullOrEmpty(id))
  9793. {
  9794. using (TransactionScope trans = new TransactionScope())
  9795. {
  9796. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(id.Trim());
  9797. if (modelT_Bus_WorkOrder != null)
  9798. {
  9799. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetModelList(" F_WorkOrderId='"+modelT_Bus_WorkOrder.F_WorkOrderId+ "' order by F_CreateTime desc ").FirstOrDefault();
  9800. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit)
  9801. {
  9802. #region 保存工单信息
  9803. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.rejload;//重办驳回
  9804. if (modelT_Bus_AssignedInfo != null)
  9805. {
  9806. Model.T_Bus_Feedback modelT_Bus_Feedback = feedbackBLL.GetModelList(" F_AssignedId=" + modelT_Bus_AssignedInfo.F_Id + " and F_IsFeedEnd=1 and F_State=1 order by F_CreateTime desc").FirstOrDefault();
  9807. #region 重办驳回时-恢复主办单位 zhengbingbing 20191017
  9808. modelT_Bus_WorkOrder.F_MainDeptId = modelT_Bus_AssignedInfo.F_MainDeptId;
  9809. modelT_Bus_WorkOrder.F_OtherDeptIds = modelT_Bus_AssignedInfo.F_OtherDeptIds;
  9810. modelT_Bus_WorkOrder.F_DealDeptId = modelT_Bus_Feedback.F_CreateDeptId;
  9811. modelT_Bus_WorkOrder.F_DealUser = modelT_Bus_Feedback.F_CreateUser;
  9812. modelT_Bus_WorkOrder.F_DealTime = modelT_Bus_Feedback.F_CreateTime;
  9813. #endregion
  9814. }
  9815. workorderBLL.Update(modelT_Bus_WorkOrder);
  9816. #endregion
  9817. #region 插入操作记录
  9818. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9819. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9820. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9821. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9822. oper.F_Message = userinfo + " 驳回重办工单,驳回原因:" + reason;
  9823. oper.F_CreateUser = userModel.F_UserCode;
  9824. oper.F_CreateTime = DateTime.Now;
  9825. oper.F_IsDelete = 0;
  9826. operBLL.Add(oper);
  9827. #endregion
  9828. }
  9829. }
  9830. trans.Complete();
  9831. }
  9832. return Success("操作成功");
  9833. }
  9834. else
  9835. {
  9836. return Error("参数异常");
  9837. }
  9838. }
  9839. else
  9840. {
  9841. return Error("权限不足");
  9842. }
  9843. }
  9844. /// <summary>
  9845. /// 重办工单
  9846. /// </summary>
  9847. /// <returns></returns>
  9848. [Authority]
  9849. public ActionResult NewReloadWorkOrder()
  9850. {
  9851. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9852. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9853. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9854. //if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY")
  9855. {
  9856. string workorderid = RequestString.GetFormString("workorderid");
  9857. int maindeptid = RequestString.GetInt("maindeptid", 0);
  9858. string otherdeptids = RequestString.GetFormString("otherdeptids");
  9859. DateTime limittime = DateTime.Parse(RequestString.GetFormString("limittime") + " 23:59:59");
  9860. string assignedopinion = RequestString.GetFormString("assignedopinion");
  9861. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9862. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  9863. if (modelT_Bus_WorkOrder != null)
  9864. {
  9865. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  9866. {
  9867. return Error("操作失败");
  9868. }
  9869. if (!string.IsNullOrEmpty(otherdeptids))
  9870. {
  9871. if (otherdeptids.Split(',').Contains(maindeptid.ToString()))
  9872. {
  9873. return Error("主办单位不能出现在协办单位");
  9874. }
  9875. }
  9876. if (limittime < DateTime.Now)
  9877. {
  9878. return Error("办理时限不能小于当前时间");
  9879. }
  9880. //if (modelT_Bus_WorkOrder.F_WorkState == 7)
  9881. //if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit)
  9882. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit)
  9883. {
  9884. using (TransactionScope trans = new TransactionScope())
  9885. {
  9886. Model.T_Bus_AssignedInfo newmodelT_Bus_AssignedInfo = new Model.T_Bus_AssignedInfo();
  9887. newmodelT_Bus_AssignedInfo.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9888. newmodelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  9889. newmodelT_Bus_AssignedInfo.F_MainDeptId = maindeptid;//主办单位id
  9890. newmodelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  9891. newmodelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  9892. newmodelT_Bus_AssignedInfo.F_State = 1;
  9893. newmodelT_Bus_AssignedInfo.F_CreateUser = userModel.F_UserCode;
  9894. newmodelT_Bus_AssignedInfo.F_CreateTime = DateTime.Now;
  9895. newmodelT_Bus_AssignedInfo.F_IsDelete = 0;
  9896. newmodelT_Bus_AssignedInfo.F_IsOverdue = 0;
  9897. newmodelT_Bus_AssignedInfo.F_IsSure = 0;
  9898. newmodelT_Bus_AssignedInfo.F_IsReload = 0;
  9899. newmodelT_Bus_AssignedInfo.F_IsNext = 0;
  9900. newmodelT_Bus_AssignedInfo.F_Id = assignBLL.Add(newmodelT_Bus_AssignedInfo);
  9901. #region 保存工单信息
  9902. modelT_Bus_WorkOrder.F_MainDeptId = maindeptid;
  9903. modelT_Bus_WorkOrder.F_OtherDeptIds = otherdeptids;
  9904. modelT_Bus_WorkOrder.F_AssignUser = userModel.F_UserCode;
  9905. modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
  9906. int n = Int32.Parse(DbHelperSQL.GetSingle("select count(1) from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "' and F_State=1 and F_IsSure=1 and F_IsDelete=0 and isnull(F_IsReload,0)>0").ToString());
  9907. modelT_Bus_WorkOrder.F_IsReload = n + 1;
  9908. modelT_Bus_WorkOrder.F_LimitTime = limittime;
  9909. modelT_Bus_WorkOrder.F_IsOverdue = 0;
  9910. //modelT_Bus_WorkOrder.F_WorkState = 8;//重办中
  9911. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.reload;//重办中
  9912. modelT_Bus_WorkOrder.F_Result = "";
  9913. modelT_Bus_WorkOrder.F_DealDeptId = null;
  9914. modelT_Bus_WorkOrder.F_DealUser = "";
  9915. modelT_Bus_WorkOrder.F_DealTime = null;
  9916. workorderBLL.Update(modelT_Bus_WorkOrder);
  9917. #endregion
  9918. #region 插入操作记录
  9919. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  9920. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  9921. oper.F_AssignedId = newmodelT_Bus_AssignedInfo.F_Id;
  9922. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  9923. string deptname = "";
  9924. #region 20191021调整为多个主办单位时调整
  9925. //var deptinfo = new BLL.T_Sys_Department().GetModel(modelT_Bus_AssignedInfo.F_MainDeptId.Value);
  9926. var deptinfo = new BLL.T_Sys_Department().GetModel(maindeptid);
  9927. if (deptinfo != null) { deptname = deptinfo.F_DeptName; }
  9928. #endregion
  9929. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  9930. oper.F_Message = userinfo + " 重办了工单,主办单位:" + deptname;
  9931. if (!string.IsNullOrEmpty(otherdeptids))
  9932. {
  9933. string sql = "select dbo.GetDeptNames('" + otherdeptids + "')";
  9934. oper.F_Message += ",协办单位:" + DbHelperSQL.GetSingle(sql);
  9935. }
  9936. oper.F_CreateUser = userModel.F_UserCode;
  9937. oper.F_CreateTime = DateTime.Now;
  9938. oper.F_IsDelete = 0;
  9939. operBLL.Add(oper);
  9940. //推送消息表
  9941. var users = userBLL.GetModelList(" F_DeptId='" + deptinfo.F_DeptId + "' ");
  9942. foreach (var u in users)
  9943. {
  9944. msg.AddInternalMessagesInfo("工单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.workorder);
  9945. }
  9946. #endregion
  9947. trans.Complete();
  9948. }
  9949. return Success("操作成功");
  9950. }
  9951. else
  9952. {
  9953. return Error("已经处理过了");
  9954. }
  9955. }
  9956. else
  9957. {
  9958. return Error("操作失败");
  9959. }
  9960. }
  9961. else
  9962. {
  9963. return Error("权限不足");
  9964. }
  9965. }
  9966. /// <summary>
  9967. /// 结案工单
  9968. /// </summary>
  9969. /// <returns></returns>
  9970. [Authority]
  9971. public ActionResult FinishWorkOrder()
  9972. {
  9973. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  9974. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  9975. //if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY")
  9976. if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  9977. {
  9978. string workorderid = RequestString.GetFormString("workorderid");
  9979. string finalopinion = RequestString.GetFormString("finalopinion");//结案意见
  9980. int issatisfie = RequestString.GetInt("issatisfie", 0);//0不满意 1满意
  9981. int isnotice = RequestString.GetInt("isnotice", 0);//0不通告 1通告
  9982. string deptids = RequestString.GetFormString("deptids");//通告单位
  9983. string noticereson = RequestString.GetFormString("noticereson");//通告原因
  9984. //2020-3-4添加通告选项
  9985. int noticeid = RequestString.GetInt("noticeid", 0);//通告选项id
  9986. string noticeinfo = RequestString.GetFormString("noticeinfo");//通告内容
  9987. int isstandard = RequestString.GetInt("isstandard", 0);//是否规范,0是,1否
  9988. string standardids = RequestString.GetFormString("standardids");//不规范项,记录多项ID(1,2,3)
  9989. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  9990. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  9991. if (modelT_Bus_WorkOrder != null)
  9992. {
  9993. //if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  9994. //{
  9995. // return Error("操作失败");
  9996. //}
  9997. //if (modelT_Bus_WorkOrder.F_WorkState == 7)
  9998. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit || modelT_Bus_WorkOrder.F_WorkState==(int)EnumWorkState.rejload)
  9999. {
  10000. using (TransactionScope trans = new TransactionScope())
  10001. {
  10002. #region 修改工单记录
  10003. //modelT_Bus_WorkOrder.F_WorkState = 9;
  10004. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;
  10005. modelT_Bus_WorkOrder.F_IsSatisfie = issatisfie;
  10006. modelT_Bus_WorkOrder.F_IsClosed = 1;
  10007. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  10008. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  10009. modelT_Bus_WorkOrder.F_FinalOpinion = finalopinion;
  10010. modelT_Bus_WorkOrder.F_IsStandard = isstandard;
  10011. modelT_Bus_WorkOrder.F_StandardIDS = standardids;
  10012. if (isnotice == 1)
  10013. {
  10014. Model.T_Bus_NoticeCriticism modelT_Bus_NoticeCriticism = new Model.T_Bus_NoticeCriticism();
  10015. modelT_Bus_NoticeCriticism.F_DeptIds = deptids;
  10016. modelT_Bus_NoticeCriticism.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10017. modelT_Bus_NoticeCriticism.F_Content = noticereson;
  10018. modelT_Bus_NoticeCriticism.F_State = 1;
  10019. modelT_Bus_NoticeCriticism.F_IsDelete = 0;
  10020. modelT_Bus_NoticeCriticism.F_CreateTime = DateTime.Now;
  10021. modelT_Bus_NoticeCriticism.F_CreateUser = userModel.F_UserCode;
  10022. modelT_Bus_NoticeCriticism.F_NoticeID = noticeid;
  10023. modelT_Bus_NoticeCriticism.F_NoticeInfo = noticeinfo;
  10024. new BLL.T_Bus_NoticeCriticism().Add(modelT_Bus_NoticeCriticism);
  10025. modelT_Bus_AssignedInfo.F_IsNotice = 1;
  10026. modelT_Bus_AssignedInfo.F_NoticeUser = userModel.F_UserCode;
  10027. modelT_Bus_AssignedInfo.F_NoticeTime = DateTime.Now;
  10028. modelT_Bus_WorkOrder.F_IsNotice = 1;
  10029. modelT_Bus_WorkOrder.F_NoticeDeptIds = deptids;
  10030. }
  10031. modelT_Bus_AssignedInfo.F_IsStandard = isstandard;
  10032. modelT_Bus_AssignedInfo.F_StandardIDS = standardids;
  10033. assignBLL.Update(modelT_Bus_AssignedInfo);
  10034. workorderBLL.Update(modelT_Bus_WorkOrder);
  10035. #endregion
  10036. #region 插入操作记录
  10037. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10038. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10039. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10040. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10041. oper.F_Message = userinfo + " 结案了工单,结果:" + (issatisfie == 1 ? "满意" : "不满意");
  10042. if (isnotice == 1)
  10043. {
  10044. string sql = "select dbo.GetDeptNames('" + deptids + "')";
  10045. oper.F_Message = oper.F_Message + ",并通告了交办单位:" + DbHelperSQL.GetSingle(sql);
  10046. }
  10047. if (isstandard == 1)
  10048. {
  10049. var sqlstand = "select dbo.GetDictionaryNames('" + standardids + "')";
  10050. var sts= DbHelperSQL.GetSingle(sqlstand);
  10051. oper.F_Message = oper.F_Message + ";办理结果出现不规范"+ sts + "情况,请及时查看";
  10052. }
  10053. oper.F_CreateUser = userModel.F_UserCode;
  10054. oper.F_CreateTime = DateTime.Now;
  10055. oper.F_IsDelete = 0;
  10056. operBLL.Add(oper);
  10057. //调用科大讯飞
  10058. if (modelT_Bus_WorkOrder.F_InfoSource == 7)
  10059. {
  10060. Model.T_Bus_Feedback tbf = new BLL.T_Bus_Feedback().GetNewModelByWorkOrderID(oper.F_WorkOrderId);
  10061. if (tbf != null)
  10062. {
  10063. string deptname = string.Empty;
  10064. var deptinfo = new BLL.T_Sys_Department().GetModel(tbf.F_CreateDeptId.Value);
  10065. if (deptinfo != null) { deptname = deptinfo.F_DeptName; }
  10066. ShangQiuWorkOrderController sqwo = new ShangQiuWorkOrderController();
  10067. bool bl = sqwo.SaveReplyInfo(oper.F_WorkOrderId, tbf.F_DealUser, deptname, tbf.F_Result, "3", modelT_Bus_WorkOrder.F_InfoType.Value.ToString());
  10068. if (bl)
  10069. {
  10070. Success("调用成功,工单号:" + oper.F_WorkOrderId);
  10071. }
  10072. else
  10073. {
  10074. Error("调用失败,工单号:" + oper.F_WorkOrderId);
  10075. }
  10076. }
  10077. }
  10078. #endregion
  10079. trans.Complete();
  10080. }
  10081. return Success("操作成功");
  10082. }
  10083. else
  10084. {
  10085. return Error("已经处理过了");
  10086. }
  10087. }
  10088. else
  10089. {
  10090. return Error("操作失败");
  10091. }
  10092. }
  10093. else
  10094. {
  10095. return Error("权限不足");
  10096. }
  10097. }
  10098. /// <summary>
  10099. /// 结案工单
  10100. /// </summary>
  10101. /// <returns></returns>
  10102. [Authority]
  10103. public ActionResult ForceFinishWorkOrder()
  10104. {
  10105. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10106. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10107. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10108. //if (userModel.F_RoleCode == "ZJZY" || userModel.F_RoleCode == "GLY")
  10109. {
  10110. string workorderid = RequestString.GetFormString("workorderid");
  10111. string result = RequestString.GetFormString("result");//处理结果
  10112. string finalopinion = RequestString.GetFormString("finalopinion");//结案意见
  10113. int issatisfie = RequestString.GetInt("issatisfie", 0);//0不满意 1满意
  10114. int isnotice = RequestString.GetInt("isnotice", 0);//0不通告 1通告
  10115. string deptids = RequestString.GetFormString("deptids");//通告单位
  10116. string noticereson = RequestString.GetFormString("noticereson");//通告其他原因
  10117. //2020-3-4添加通告选项
  10118. int noticeid = RequestString.GetInt("noticeid", 0);//通告选项id
  10119. string noticeinfo = RequestString.GetFormString("noticeinfo");//通告内容
  10120. int isstandard = RequestString.GetInt("isstandard", 0);//是否规范,0是,1否
  10121. string standardids= RequestString.GetFormString("standardids");//不规范项,记录多项ID(1,2,3)
  10122. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  10123. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  10124. if (modelT_Bus_WorkOrder != null)
  10125. {
  10126. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  10127. {
  10128. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_CreateUser != userModel.F_UserCode)
  10129. {
  10130. return Error("操作失败");
  10131. }
  10132. }
  10133. using (TransactionScope trans = new TransactionScope())
  10134. {
  10135. #region 修改工单记录
  10136. modelT_Bus_WorkOrder.F_Result = result;
  10137. //modelT_Bus_WorkOrder.F_WorkState = 9;
  10138. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;
  10139. modelT_Bus_WorkOrder.F_IsSatisfie = issatisfie;
  10140. modelT_Bus_WorkOrder.F_IsClosed = 1;
  10141. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  10142. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  10143. modelT_Bus_WorkOrder.F_FinalOpinion = finalopinion;
  10144. modelT_Bus_WorkOrder.F_IsStandard = isstandard;
  10145. modelT_Bus_WorkOrder.F_StandardIDS = standardids;
  10146. if (isnotice == 1)
  10147. {
  10148. Model.T_Bus_NoticeCriticism modelT_Bus_NoticeCriticism = new Model.T_Bus_NoticeCriticism();
  10149. modelT_Bus_NoticeCriticism.F_DeptIds = deptids;
  10150. modelT_Bus_NoticeCriticism.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10151. modelT_Bus_NoticeCriticism.F_Content = noticereson;
  10152. modelT_Bus_NoticeCriticism.F_State = 1;
  10153. modelT_Bus_NoticeCriticism.F_IsDelete = 0;
  10154. modelT_Bus_NoticeCriticism.F_CreateTime = DateTime.Now;
  10155. modelT_Bus_NoticeCriticism.F_CreateUser = userModel.F_UserCode;
  10156. modelT_Bus_NoticeCriticism.F_NoticeID = noticeid;
  10157. modelT_Bus_NoticeCriticism.F_NoticeInfo = noticeinfo;
  10158. new BLL.T_Bus_NoticeCriticism().Add(modelT_Bus_NoticeCriticism);
  10159. modelT_Bus_WorkOrder.F_IsNotice = 1;
  10160. modelT_Bus_WorkOrder.F_NoticeDeptIds = deptids;
  10161. if (modelT_Bus_AssignedInfo != null)
  10162. {
  10163. modelT_Bus_AssignedInfo.F_IsNotice = 1;
  10164. modelT_Bus_AssignedInfo.F_NoticeUser = userModel.F_UserCode;
  10165. modelT_Bus_AssignedInfo.F_NoticeTime = DateTime.Now;
  10166. }
  10167. }
  10168. if (modelT_Bus_AssignedInfo!=null )
  10169. {
  10170. modelT_Bus_AssignedInfo.F_IsStandard = isstandard;
  10171. modelT_Bus_AssignedInfo.F_StandardIDS = standardids;
  10172. assignBLL.Update(modelT_Bus_AssignedInfo);
  10173. }
  10174. workorderBLL.Update(modelT_Bus_WorkOrder);
  10175. #endregion
  10176. #region 插入操作记录
  10177. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10178. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10179. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10180. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10181. oper.F_Message = userinfo + " 强制结案了工单,结果:" + (issatisfie == 1 ? "满意" : "不满意");
  10182. if (isnotice == 1)
  10183. {
  10184. string sql = "select dbo.GetDeptNames('" + deptids + "')";
  10185. oper.F_Message = oper.F_Message + ",并通告了交办单位:" + DbHelperSQL.GetSingle(sql);
  10186. }
  10187. if(isstandard==1)
  10188. {
  10189. oper.F_Message = oper.F_Message + ",办理结果出现不规范情况,请及时查看";
  10190. }
  10191. oper.F_CreateUser = userModel.F_UserCode;
  10192. oper.F_CreateTime = DateTime.Now;
  10193. oper.F_IsDelete = 0;
  10194. operBLL.Add(oper);
  10195. //调用科大讯飞
  10196. //if (modelT_Bus_WorkOrder.F_InfoSource == 7 && modelT_Bus_WorkOrder.F_WorkState == 9)
  10197. if (modelT_Bus_WorkOrder.F_InfoSource == 7 && modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.finish)
  10198. {
  10199. ShangQiuWorkOrderController sqwo = new ShangQiuWorkOrderController();
  10200. bool bl = sqwo.SaveReplyInfo(oper.F_WorkOrderId, userModel.F_UserCode, userModel.depname, modelT_Bus_WorkOrder.F_Result, "3", modelT_Bus_WorkOrder.F_InfoType.Value.ToString());
  10201. if (bl)
  10202. {
  10203. Success("调用成功,工单号:" + oper.F_WorkOrderId);
  10204. }
  10205. else
  10206. {
  10207. Error("调用失败,工单号:" + oper.F_WorkOrderId);
  10208. }
  10209. }
  10210. #endregion
  10211. trans.Complete();
  10212. }
  10213. return Success("操作成功");
  10214. }
  10215. else
  10216. {
  10217. return Error("操作失败");
  10218. }
  10219. }
  10220. else
  10221. {
  10222. return Error("权限不足");
  10223. }
  10224. }
  10225. /// <summary>
  10226. /// 删除工单
  10227. /// </summary>
  10228. /// <returns></returns>
  10229. public ActionResult DelWorkOrder(string[] ids)
  10230. {
  10231. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10232. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10233. if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10234. {
  10235. //StringBuilder sb = new StringBuilder();
  10236. foreach (var item in ids)
  10237. {
  10238. //sb.Append("'" + item + "',");
  10239. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(item);
  10240. if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder || modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit))//0)
  10241. {
  10242. using (TransactionScope trans = new TransactionScope())
  10243. {
  10244. #region 修改工单记录
  10245. modelT_Bus_WorkOrder.F_IsDelete = 1;
  10246. modelT_Bus_WorkOrder.F_DeleteUser= userModel.F_UserCode;
  10247. modelT_Bus_WorkOrder.F_DeleteTime = DateTime.Now;
  10248. workorderBLL.Update(modelT_Bus_WorkOrder);
  10249. #endregion
  10250. #region 插入操作记录
  10251. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10252. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10253. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10254. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10255. oper.F_Message = userinfo + " 删除了工单";
  10256. oper.F_CreateUser = userModel.F_UserCode;
  10257. oper.F_CreateTime = DateTime.Now;
  10258. oper.F_IsDelete = 0;
  10259. operBLL.Add(oper);
  10260. #endregion
  10261. trans.Complete();
  10262. }
  10263. }
  10264. }
  10265. return Success("删除成功");
  10266. }
  10267. else
  10268. {
  10269. return Error("权限不足");
  10270. }
  10271. }
  10272. /// <summary>
  10273. /// 转媒体工单
  10274. /// </summary>
  10275. /// <returns></returns>
  10276. [Authority]
  10277. public ActionResult ReleaseWorkOrder()
  10278. {
  10279. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10280. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10281. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10282. {
  10283. string workorderid = RequestString.GetFormString("workorderid");
  10284. int isrelease = RequestString.GetInt("isrelease", -1);
  10285. if (isrelease != -1)
  10286. {
  10287. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  10288. if (modelT_Bus_WorkOrder != null)
  10289. {
  10290. using (TransactionScope trans = new TransactionScope())
  10291. {
  10292. #region 修改工单记录
  10293. modelT_Bus_WorkOrder.F_IsRelease = isrelease;
  10294. workorderBLL.Update(modelT_Bus_WorkOrder);
  10295. #endregion
  10296. #region 插入操作记录
  10297. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10298. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10299. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10300. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10301. oper.F_Message = userinfo + " " + (isrelease == 1 ? "转媒体了" : "收回了转媒体") + "工单";
  10302. oper.F_CreateUser = userModel.F_UserCode;
  10303. oper.F_CreateTime = DateTime.Now;
  10304. oper.F_IsDelete = 0;
  10305. operBLL.Add(oper);
  10306. #endregion
  10307. trans.Complete();
  10308. }
  10309. return Success("操作成功");
  10310. }
  10311. else
  10312. {
  10313. return Error("操作失败");
  10314. }
  10315. }
  10316. else
  10317. {
  10318. return Error("操作失败");
  10319. }
  10320. }
  10321. else
  10322. {
  10323. return Error("权限不足");
  10324. }
  10325. }
  10326. ///// <summary>
  10327. ///// 通告和撤销通告
  10328. ///// </summary>
  10329. ///// <returns></returns>
  10330. //[Authority]
  10331. //public ActionResult NoticeWorkOrder()
  10332. //{
  10333. // int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10334. // Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10335. // if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" ||userModel.F_RoleCode == "ZXLDGLY" || userModel.F_RoleCode == "GLY")
  10336. // {
  10337. // int assignid = RequestString.GetInt("id", 0);
  10338. // int isnotice = RequestString.GetInt("isnotice", -1);
  10339. // Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetModel(assignid);
  10340. // if (modelT_Bus_AssignedInfo != null)
  10341. // {
  10342. // if (isnotice == 0 && modelT_Bus_AssignedInfo.F_IsNotice == 1)
  10343. // {
  10344. // using (TransactionScope trans = new TransactionScope())
  10345. // {
  10346. // #region 修改交办记录
  10347. // modelT_Bus_AssignedInfo.F_IsNotice = 0;
  10348. // assignBLL.Update(modelT_Bus_AssignedInfo);
  10349. // #endregion
  10350. // #region 插入操作记录
  10351. // Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10352. // oper.F_WorkOrderId = modelT_Bus_AssignedInfo.F_WorkOrderId;
  10353. // var deptinfo = new BLL.T_Sys_Department().GetModel(modelT_Bus_AssignedInfo.F_MainDeptId.Value);
  10354. // string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10355. // oper.F_Message = userinfo + " 撤销了通告交办单位:" + (deptinfo != null ? deptinfo.F_DeptName : "");
  10356. // oper.F_CreateUser = userModel.F_UserCode;
  10357. // oper.F_CreateTime = DateTime.Now;
  10358. // oper.F_IsDelete = 0;
  10359. // operBLL.Add(oper);
  10360. // #endregion
  10361. // trans.Complete();
  10362. // }
  10363. // return Success("操作成功");
  10364. // }
  10365. // else if (isnotice == 1 && modelT_Bus_AssignedInfo.F_IsNotice == 0)
  10366. // {
  10367. // using (TransactionScope trans = new TransactionScope())
  10368. // {
  10369. // #region 修改交办记录
  10370. // modelT_Bus_AssignedInfo.F_IsNotice = 1;
  10371. // assignBLL.Update(modelT_Bus_AssignedInfo);
  10372. // #endregion
  10373. // #region 插入操作记录
  10374. // Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10375. // oper.F_WorkOrderId = modelT_Bus_AssignedInfo.F_WorkOrderId;
  10376. // var deptinfo = new BLL.T_Sys_Department().GetModel(modelT_Bus_AssignedInfo.F_MainDeptId.Value);
  10377. // string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10378. // oper.F_Message = userinfo + " 通告了交办单位:" + (deptinfo != null ? deptinfo.F_DeptName : "");
  10379. // oper.F_CreateUser = userModel.F_UserCode;
  10380. // oper.F_CreateTime = DateTime.Now;
  10381. // oper.F_IsDelete = 0;
  10382. // operBLL.Add(oper);
  10383. // #endregion
  10384. // trans.Complete();
  10385. // }
  10386. // return Success("操作成功");
  10387. // }
  10388. // else
  10389. // {
  10390. // return Error("操作失败");
  10391. // }
  10392. // }
  10393. // else
  10394. // {
  10395. // return Error("操作失败");
  10396. // }
  10397. // }
  10398. // else
  10399. // {
  10400. // return Error("权限不足");
  10401. // }
  10402. //}
  10403. /// <summary>
  10404. /// 通告和撤销通告
  10405. /// </summary>
  10406. /// <returns></returns>
  10407. [Authority]
  10408. public ActionResult NoticeWorkOrder()
  10409. {
  10410. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10411. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10412. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10413. {
  10414. string workorderid = RequestString.GetFormString("workorderid");
  10415. int isnotice = RequestString.GetInt("isnotice", -1);
  10416. string deptids = RequestString.GetFormString("deptids");//通告单位
  10417. string noticereson = RequestString.GetFormString("noticereson");//通告原因
  10418. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  10419. if (modelT_Bus_WorkOrder != null)
  10420. {
  10421. if (isnotice == 0 && modelT_Bus_WorkOrder.F_IsNotice == 1)
  10422. {
  10423. using (TransactionScope trans = new TransactionScope())
  10424. {
  10425. #region 修改工单记录
  10426. modelT_Bus_WorkOrder.F_IsNotice = 0;
  10427. modelT_Bus_WorkOrder.F_NoticeDeptIds = "";
  10428. workorderBLL.Update(modelT_Bus_WorkOrder);
  10429. #endregion
  10430. #region 修改通告记录
  10431. Model.T_Bus_NoticeCriticism modelT_Bus_NoticeCriticism = new BLL.T_Bus_NoticeCriticism().GetModelList(" F_WorkOrderId='" + workorderid + "' and F_IsDelete=0 ").FirstOrDefault();
  10432. modelT_Bus_NoticeCriticism.F_IsDelete = 1;
  10433. modelT_Bus_NoticeCriticism.F_DeleteTime = DateTime.Now;
  10434. modelT_Bus_NoticeCriticism.F_DeleteUser = userModel.F_UserCode;
  10435. new BLL.T_Bus_NoticeCriticism().Update(modelT_Bus_NoticeCriticism);
  10436. #endregion
  10437. #region 插入操作记录
  10438. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10439. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10440. string sql = "select dbo.GetDeptNames('" + modelT_Bus_NoticeCriticism.F_DeptIds + "')";
  10441. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10442. oper.F_Message = userinfo + " 撤销了通告交办单位:" + DbHelperSQL.GetSingle(sql).ToString();
  10443. oper.F_CreateUser = userModel.F_UserCode;
  10444. oper.F_CreateTime = DateTime.Now;
  10445. oper.F_IsDelete = 0;
  10446. operBLL.Add(oper);
  10447. #endregion
  10448. trans.Complete();
  10449. }
  10450. return Success("操作成功");
  10451. }
  10452. else if (isnotice == 1 && modelT_Bus_WorkOrder.F_IsNotice == 0)
  10453. {
  10454. using (TransactionScope trans = new TransactionScope())
  10455. {
  10456. #region 修改工单记录
  10457. modelT_Bus_WorkOrder.F_IsNotice = 1;
  10458. modelT_Bus_WorkOrder.F_NoticeDeptIds = deptids;
  10459. workorderBLL.Update(modelT_Bus_WorkOrder);
  10460. #endregion
  10461. #region 新增通告记录
  10462. Model.T_Bus_NoticeCriticism modelT_Bus_NoticeCriticism = new Model.T_Bus_NoticeCriticism();
  10463. modelT_Bus_NoticeCriticism.F_DeptIds = deptids;
  10464. modelT_Bus_NoticeCriticism.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10465. modelT_Bus_NoticeCriticism.F_Content = noticereson;
  10466. modelT_Bus_NoticeCriticism.F_State = 1;
  10467. modelT_Bus_NoticeCriticism.F_IsDelete = 0;
  10468. modelT_Bus_NoticeCriticism.F_CreateTime = DateTime.Now;
  10469. modelT_Bus_NoticeCriticism.F_CreateUser = userModel.F_UserCode;
  10470. new BLL.T_Bus_NoticeCriticism().Add(modelT_Bus_NoticeCriticism);
  10471. #endregion
  10472. #region 插入操作记录
  10473. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10474. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10475. string sql = "select dbo.GetDeptNames('" + deptids + "')";
  10476. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10477. oper.F_Message = userinfo + " 通告了交办单位:" + DbHelperSQL.GetSingle(sql).ToString();
  10478. oper.F_CreateUser = userModel.F_UserCode;
  10479. oper.F_CreateTime = DateTime.Now;
  10480. oper.F_IsDelete = 0;
  10481. operBLL.Add(oper);
  10482. #endregion
  10483. trans.Complete();
  10484. }
  10485. return Success("操作成功");
  10486. }
  10487. else
  10488. {
  10489. return Error("操作失败");
  10490. }
  10491. }
  10492. else
  10493. {
  10494. return Error("操作失败");
  10495. }
  10496. }
  10497. else
  10498. {
  10499. return Error("权限不足");
  10500. }
  10501. }
  10502. /// <summary>
  10503. /// 市民催单
  10504. /// </summary>
  10505. /// <returns></returns>
  10506. [Authority]
  10507. public ActionResult AdditionalWorkOrder()
  10508. {
  10509. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10510. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  10511. string workorderid = RequestString.GetFormString("workorderid");
  10512. string title = RequestString.GetFormString("title");
  10513. string content = RequestString.GetFormString("content");
  10514. string files = RequestString.GetFormString("files");
  10515. string callid = RequestString.GetFormString("callid");
  10516. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  10517. if (modelT_Bus_WorkOrder != null)
  10518. {
  10519. using (TransactionScope trans = new TransactionScope())
  10520. {
  10521. #region 插入附加记录
  10522. //批示记录
  10523. Model.T_Bus_Additional model_T_Bus_Additional = new Model.T_Bus_Additional();
  10524. model_T_Bus_Additional.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
  10525. model_T_Bus_Additional.F_Title = title;
  10526. model_T_Bus_Additional.F_Content = content;
  10527. if (!string.IsNullOrEmpty(callid))
  10528. {
  10529. model_T_Bus_Additional.F_CallId = callid;
  10530. var rd = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  10531. if (rd != null)
  10532. {
  10533. model_T_Bus_Additional.F_CallRecordId = rd.CallRecordsId;
  10534. }
  10535. }
  10536. model_T_Bus_Additional.F_File = files;//附件
  10537. model_T_Bus_Additional.F_CreateUser = userModel.F_UserCode;//呈批人
  10538. model_T_Bus_Additional.F_CreateTime = DateTime.Now;//呈批时间
  10539. model_T_Bus_Additional.F_IsDelete = 0;
  10540. model_T_Bus_Additional.F_State = 1;//审批状态(0:未处理,1:通过)
  10541. new BLL.T_Bus_Additional().Add(model_T_Bus_Additional);
  10542. #endregion
  10543. #region 插入操作记录
  10544. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10545. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10546. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10547. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10548. oper.F_Message = userinfo + " 接到市民催单,内容:" + content;
  10549. oper.F_CreateUser = userModel.F_UserCode;
  10550. oper.F_CreateTime = DateTime.Now;
  10551. oper.F_IsDelete = 0;
  10552. operBLL.Add(oper);
  10553. #endregion
  10554. #region 根据状态不同给出提醒
  10555. var sqlusers = " F_DeleteFlag=0 ";
  10556. #region 获取被提醒人
  10557. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetNewModelByWorkOrderID(workorderid);
  10558. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.neworder)
  10559. sqlusers += " and F_UserCode='"+ modelT_Bus_WorkOrder.F_CreateUser + "'";//"新工单"向添加人提醒
  10560. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit)
  10561. sqlusers += " and F_RoleId in (select F_RoleId from T_Sys_RoleInfo WITH(NOLOCK) where F_RoleCode='ZXLD')";//"待交办"向所有调度提醒
  10562. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.receive)
  10563. {
  10564. if (modelT_Bus_AssignedInfo != null && modelT_Bus_AssignedInfo.F_MainDeptId != null)
  10565. sqlusers += " and F_DeptId='" + modelT_Bus_AssignedInfo.F_MainDeptId + "' ";//"待查收"向被指派单位的所有人提醒
  10566. }
  10567. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.auditreback)
  10568. {
  10569. if (modelT_Bus_AssignedInfo != null )
  10570. sqlusers += " and F_UserCode='" + modelT_Bus_AssignedInfo.F_CreateUser + "' ";//"退回审核中"向指派人提醒
  10571. }
  10572. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealing)
  10573. {
  10574. if (modelT_Bus_AssignedInfo != null && !string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_SureUser))
  10575. sqlusers += " and F_UserCode='" + modelT_Bus_AssignedInfo.F_SureUser + "' ";//"办理中"向查收人提醒
  10576. }
  10577. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.auditdelay)
  10578. {
  10579. if (modelT_Bus_AssignedInfo != null)
  10580. sqlusers += " and F_UserCode='" + modelT_Bus_AssignedInfo.F_CreateUser + "' ";//"延时审核中"
  10581. }
  10582. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.dealed)
  10583. {
  10584. sqlusers += " and F_RoleId in (select F_RoleId from T_Sys_RoleInfo WITH(NOLOCK) where F_RoleCode='ZJZY')";//"已办理"向所有质检提醒
  10585. }
  10586. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.visit)
  10587. {
  10588. sqlusers += " and F_RoleId in (select F_RoleId from T_Sys_RoleInfo WITH(NOLOCK) where F_RoleCode='ZJZY')";//"已回访"向所有质检提醒
  10589. }
  10590. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.reload)
  10591. {
  10592. if (modelT_Bus_AssignedInfo != null)
  10593. sqlusers += " and F_UserCode='" + modelT_Bus_AssignedInfo.F_CreateUser + "' ";//"重办中"向指派人提醒
  10594. }
  10595. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.audit)
  10596. {
  10597. sqlusers += " and F_RoleId in (select F_RoleId from T_Sys_RoleInfo WITH(NOLOCK) where F_RoleCode='ZXBZ')";//"待审核"向坐席班长提醒
  10598. }
  10599. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.resubmit)
  10600. {
  10601. if (modelT_Bus_AssignedInfo != null)
  10602. sqlusers += " and F_UserCode='" + modelT_Bus_AssignedInfo.F_CreateUser + "' ";//"重办待交办"向指派人提醒
  10603. }
  10604. if (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.rejload)
  10605. {
  10606. sqlusers += " and F_RoleId in (select F_RoleId from T_Sys_RoleInfo WITH(NOLOCK) where F_RoleCode='ZJZY')";//"重办驳回"向所有质检提醒
  10607. }
  10608. #endregion
  10609. var userlists = userBLL.GetModelList(sqlusers);
  10610. //推送消息表
  10611. foreach (var u in userlists)
  10612. {
  10613. msg.AddInternalMessagesInfo("催单消息", oper.F_Message + ",工单编号:" + oper.F_WorkOrderId, u.F_UserCode, userModel.F_UserCode, (int)EnumSmsType.additional);
  10614. }
  10615. #endregion
  10616. trans.Complete();
  10617. }
  10618. return Success("操作成功");
  10619. }
  10620. else
  10621. {
  10622. return Error("操作失败");
  10623. }
  10624. }
  10625. #endregion
  10626. #region 语音附件其他
  10627. /// <summary>
  10628. /// 验证当前单位是否交办单位
  10629. /// </summary>
  10630. /// <param name="modelT_Bus_AssignedInfo"></param>
  10631. /// <param name="deptid"></param>
  10632. /// <returns></returns>
  10633. public int AssignDeptType(Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo, int deptid)
  10634. {
  10635. int type = 0;
  10636. if (modelT_Bus_AssignedInfo.F_MainDeptId == deptid)
  10637. {
  10638. type = 1;//主办
  10639. }
  10640. else if (!string.IsNullOrEmpty(modelT_Bus_AssignedInfo.F_OtherDeptIds) && modelT_Bus_AssignedInfo.F_OtherDeptIds.Split(',').Contains(deptid.ToString()))
  10641. {
  10642. type = 2;//协办
  10643. }
  10644. return type;
  10645. }
  10646. /// <summary>
  10647. /// 获取留言路径
  10648. /// </summary>
  10649. /// <param name="lid">留言id</param>
  10650. /// <param name="prefix">前缀</param>
  10651. /// <returns></returns>
  10652. public string GetLeavePath(string lid, string prefix)
  10653. {
  10654. string path = string.Empty;
  10655. var liuyan = new BLL.T_Call_LeaveRecord().GetModelList(" F_Id='" + lid + "' ").FirstOrDefault();
  10656. if (liuyan != null)
  10657. {
  10658. if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
  10659. {
  10660. path = prefix + liuyan.F_RecFileUrl;
  10661. }
  10662. }
  10663. return path;
  10664. }
  10665. /// <summary>
  10666. /// 获取通话录音路径
  10667. /// </summary>
  10668. /// <param name="cid">通话id</param>
  10669. /// <param name="prefix">前缀</param>
  10670. /// <returns></returns>
  10671. public string GetCallPath(string cid, string prefix)
  10672. {
  10673. string path = string.Empty;
  10674. var luyin = new BLL.T_Call_CallRecords().GetModelList(" CallRecordsId='" + cid + "' ").FirstOrDefault();
  10675. if (luyin != null)
  10676. {
  10677. if (!string.IsNullOrEmpty(luyin.FilePath))
  10678. {
  10679. var ym = prefix;
  10680. ym = ym.Substring(0, ym.Length - 1);
  10681. string lujing = luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
  10682. path = ym + lujing;
  10683. //if (!CommonHelper.FileIsExist(path))
  10684. //{
  10685. // path = lujing;
  10686. //}
  10687. }
  10688. }
  10689. return path;
  10690. }
  10691. /// <summary>
  10692. /// 获取附件数据
  10693. /// </summary>
  10694. /// <param name="ids">附件id,多个用英文逗号,隔开</param>
  10695. /// <param name="prefix">前缀</param>
  10696. /// <returns></returns>
  10697. public DataTable GetFileData(string ids, string prefix)
  10698. {
  10699. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + ids + ")").Tables[0];
  10700. foreach (DataRow dr in dt.Rows)
  10701. {
  10702. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  10703. }
  10704. return dt;
  10705. }
  10706. /// <summary>
  10707. /// 绑定附件信息
  10708. /// </summary>
  10709. /// <param name="dt"></param>
  10710. /// <param name="prefix"></param>
  10711. /// <returns></returns>
  10712. public DataTable BindFileData(DataTable dt, string prefix)
  10713. {
  10714. dt.Columns.Add("File", typeof(object));
  10715. foreach (DataRow dr in dt.Rows)
  10716. {
  10717. if (dr["F_File"] != null && dr["F_File"].ToString() != "")
  10718. {
  10719. dr["File"] = GetFileData(dr["F_File"].ToString(), prefix);
  10720. }
  10721. }
  10722. return dt;
  10723. }
  10724. #endregion
  10725. #region 修改工单 by admin
  10726. /// <summary>
  10727. /// 获取详情
  10728. /// </summary>
  10729. /// <returns></returns>
  10730. [Authority]
  10731. public ActionResult GetInfoByAdmin(int id, int type)
  10732. {
  10733. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10734. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10735. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10736. {
  10737. //string sql = "select * from ";
  10738. string table = string.Empty;
  10739. switch (type)
  10740. {
  10741. case 1: table = "T_Bus_AssignedInfo"; break;//交办信息
  10742. case 2: table = "T_Bus_DelayTime"; break;//延时信息
  10743. case 3: table = "T_Bus_Feedback"; break;//办理信息
  10744. case 4: table = "T_Bus_RemindRecord"; break;//督办
  10745. case 5: table = "T_Bus_SubmitSuper"; break;//1领导批示 2市长指示 3回退
  10746. case 6: table = "T_Bus_VisitResult"; break;//回访
  10747. }
  10748. string sql = "select * from " + table + " WITH(NOLOCK) where F_IsDelete=0 and F_Id=" + id;
  10749. var dt = DbHelperSQL.Query(sql).Tables[0];
  10750. return Success("操作成功", dt);
  10751. }
  10752. else
  10753. {
  10754. return Error("权限不足");
  10755. }
  10756. }
  10757. /// <summary>
  10758. /// 修改工单信息
  10759. /// </summary>
  10760. /// <returns></returns>
  10761. [Authority]
  10762. public ActionResult EditWorkOrderByAdmin()
  10763. {
  10764. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10765. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10766. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10767. {
  10768. string workorderid = RequestString.GetFormString("workorderid");
  10769. int source = RequestString.GetInt("source", 0);
  10770. string cusname = RequestString.GetFormString("cusname");
  10771. string cussex = RequestString.GetFormString("cussex");
  10772. string cusphone = RequestString.GetFormString("cusphone");
  10773. string cusaddress = RequestString.GetFormString("cusaddress");
  10774. string email = RequestString.GetFormString("email");
  10775. string zipcode = RequestString.GetFormString("zipcode");
  10776. string conname = RequestString.GetFormString("conname");
  10777. string conphone = RequestString.GetFormString("conphone");
  10778. string title = RequestString.GetFormString("title");
  10779. string content = RequestString.GetFormString("content");
  10780. string files = RequestString.GetFormString("files");
  10781. int sourcearea = RequestString.GetInt("sourcearea", 0);
  10782. string sourceaddress = RequestString.GetFormString("sourceaddress");
  10783. string keys = RequestString.GetFormString("keys");
  10784. string splituser = RequestString.GetFormString("splituser");
  10785. int type = RequestString.GetInt("type", 0);
  10786. int bigtype = RequestString.GetInt("bigtype", 0);
  10787. int smalltype = RequestString.GetInt("smalltype", 0);
  10788. int isprotect = RequestString.GetInt("isprotect", 0);
  10789. int level = RequestString.GetInt("level", 0);
  10790. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  10791. if (modelT_Bus_WorkOrder != null)
  10792. {
  10793. using (TransactionScope trans = new TransactionScope())
  10794. {
  10795. #region 保存工单信息
  10796. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  10797. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  10798. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  10799. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  10800. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  10801. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  10802. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  10803. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  10804. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  10805. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  10806. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  10807. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  10808. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  10809. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  10810. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  10811. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  10812. modelT_Bus_WorkOrder.F_File = files;//附件
  10813. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  10814. modelT_Bus_WorkOrder.F_Key = keys;
  10815. modelT_Bus_WorkOrder.F_Level = level;
  10816. workorderBLL.Update(modelT_Bus_WorkOrder);
  10817. #endregion
  10818. #region 插入操作记录
  10819. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10820. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  10821. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  10822. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  10823. oper.F_File = modelT_Bus_WorkOrder.F_File;
  10824. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10825. oper.F_Message = userinfo + " 修改了工单基本信息";
  10826. oper.F_CreateUser = userModel.F_UserCode;
  10827. oper.F_CreateTime = DateTime.Now;
  10828. oper.F_IsDelete = 0;
  10829. operBLL.Add(oper);
  10830. #endregion
  10831. trans.Complete();
  10832. }
  10833. return Success("操作成功");
  10834. }
  10835. else
  10836. {
  10837. return Error("操作失败");
  10838. }
  10839. }
  10840. else
  10841. {
  10842. return Success("权限不足");
  10843. }
  10844. }
  10845. /// <summary>
  10846. /// 修改批示信息
  10847. /// </summary>
  10848. /// <returns></returns>
  10849. [Authority]
  10850. public ActionResult EditSuperInfoByAdmin()
  10851. {
  10852. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10853. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10854. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10855. {
  10856. //int type = RequestString.GetInt("type", 0);//1领导批示 2市长指示
  10857. string superuser = RequestString.GetFormString("superuser");
  10858. string superopinion = RequestString.GetFormString("superopinion");
  10859. string files = RequestString.GetFormString("files");
  10860. int id = RequestString.GetInt("id", 0);
  10861. Model.T_Bus_SubmitSuper model_T_Bus_SubmitSuper = new BLL.T_Bus_SubmitSuper().GetModel(id);
  10862. if (model_T_Bus_SubmitSuper != null)
  10863. {
  10864. using (TransactionScope trans = new TransactionScope())
  10865. {
  10866. #region 保存批示信息
  10867. //model_T_Bus_SubmitSuper.F_Type = type;//1领导批示 2市长指示
  10868. model_T_Bus_SubmitSuper.F_BatchReason = superuser;//批示人
  10869. model_T_Bus_SubmitSuper.F_SuperOpinion = superopinion;//批示内容
  10870. if (!string.IsNullOrEmpty(files))
  10871. model_T_Bus_SubmitSuper.F_File = files;//附件
  10872. new BLL.T_Bus_SubmitSuper().Update(model_T_Bus_SubmitSuper);
  10873. #endregion
  10874. #region 插入操作记录
  10875. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10876. oper.F_WorkOrderId = model_T_Bus_SubmitSuper.F_WorkOrderId;
  10877. oper.F_File = model_T_Bus_SubmitSuper.F_File;
  10878. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10879. oper.F_Message = userinfo + " 修改了工单批示信息";
  10880. oper.F_CreateUser = userModel.F_UserCode;
  10881. oper.F_CreateTime = DateTime.Now;
  10882. oper.F_IsDelete = 0;
  10883. operBLL.Add(oper);
  10884. #endregion
  10885. trans.Complete();
  10886. }
  10887. return Success("操作成功");
  10888. }
  10889. else
  10890. {
  10891. return Error("操作失败");
  10892. }
  10893. }
  10894. else
  10895. {
  10896. return Error("权限不足");
  10897. }
  10898. }
  10899. /// <summary>
  10900. /// 修改交办信息
  10901. /// </summary>
  10902. /// <returns></returns>
  10903. [Authority]
  10904. public ActionResult EditAssignInfoByAdmin()
  10905. {
  10906. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10907. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10908. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10909. {
  10910. int assignid = RequestString.GetInt("id", 0);
  10911. //int maindeptid = RequestString.GetInt("maindeptid", 0);
  10912. //string otherdeptids = RequestString.GetFormString("otherdeptids");
  10913. DateTime limittime = DateTime.Parse(RequestString.GetFormString("limittime"));
  10914. string assignedopinion = RequestString.GetFormString("assignedopinion");
  10915. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetModel(assignid);
  10916. if (modelT_Bus_AssignedInfo != null)
  10917. {
  10918. using (TransactionScope trans = new TransactionScope())
  10919. {
  10920. #region 保存交办信息
  10921. modelT_Bus_AssignedInfo.F_LimitTime = limittime;//办理时限
  10922. //modelT_Bus_AssignedInfo.F_MainDeptId = maindeptid;//主办单位id
  10923. //modelT_Bus_AssignedInfo.F_OtherDeptIds = otherdeptids;//协办单位id
  10924. modelT_Bus_AssignedInfo.F_AssignedOpinion = assignedopinion;//交办意见
  10925. assignBLL.Update(modelT_Bus_AssignedInfo);
  10926. #endregion
  10927. #region 插入操作记录
  10928. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10929. oper.F_WorkOrderId = modelT_Bus_AssignedInfo.F_WorkOrderId;
  10930. oper.F_File = modelT_Bus_AssignedInfo.F_File;
  10931. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10932. oper.F_Message = userinfo + " 修改了工单交办信息";
  10933. oper.F_CreateUser = userModel.F_UserCode;
  10934. oper.F_CreateTime = DateTime.Now;
  10935. oper.F_IsDelete = 0;
  10936. operBLL.Add(oper);
  10937. #endregion
  10938. trans.Complete();
  10939. }
  10940. return Success("操作成功");
  10941. }
  10942. else
  10943. {
  10944. return Error("操作失败");
  10945. }
  10946. }
  10947. else
  10948. {
  10949. return Error("权限不足");
  10950. }
  10951. }
  10952. /// <summary>
  10953. /// 修改办理信息
  10954. /// </summary>
  10955. /// <returns></returns>
  10956. [Authority]
  10957. public ActionResult EditFeedBackInfoByAdmin()
  10958. {
  10959. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  10960. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  10961. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  10962. {
  10963. string dealman = RequestString.GetFormString("dealman");
  10964. string result = RequestString.GetFormString("result");
  10965. string files = RequestString.GetFormString("files");
  10966. int feedbackid = RequestString.GetInt("id", 0);
  10967. Model.T_Bus_Feedback model_T_Bus_Feedback = new BLL.T_Bus_Feedback().GetModel(feedbackid);
  10968. if (model_T_Bus_Feedback != null)
  10969. {
  10970. using (TransactionScope trans = new TransactionScope())
  10971. {
  10972. #region 保存办理信息
  10973. model_T_Bus_Feedback.F_DealUser = dealman;
  10974. model_T_Bus_Feedback.F_Result = result;//反馈内容
  10975. model_T_Bus_Feedback.F_File = files;
  10976. new BLL.T_Bus_Feedback().Update(model_T_Bus_Feedback);
  10977. #endregion
  10978. #region 保存工单信息
  10979. int maxid = Int32.Parse(DbHelperSQL.GetSingle("select max(F_Id) from T_Bus_AssignedInfo WITH(NOLOCK) where F_WorkOrderId='" + model_T_Bus_Feedback.F_WorkOrderId + "' and F_State=1 and F_IsSure=1 and F_IsDelete=0 ").ToString());
  10980. var assign = assignBLL.GetModel(model_T_Bus_Feedback.F_AssignedId.Value);
  10981. if (maxid == assign.F_Id)
  10982. {
  10983. var order = workorderBLL.GetModel(model_T_Bus_Feedback.F_WorkOrderId);
  10984. order.F_Result = result;//反馈内容
  10985. workorderBLL.Update(order);
  10986. }
  10987. #endregion
  10988. #region 插入操作记录
  10989. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  10990. oper.F_WorkOrderId = model_T_Bus_Feedback.F_WorkOrderId;
  10991. oper.F_File = model_T_Bus_Feedback.F_File;
  10992. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  10993. oper.F_Message = userinfo + " 修改了工单办理信息";
  10994. oper.F_CreateUser = userModel.F_UserCode;
  10995. oper.F_CreateTime = DateTime.Now;
  10996. oper.F_IsDelete = 0;
  10997. operBLL.Add(oper);
  10998. #endregion
  10999. trans.Complete();
  11000. }
  11001. return Success("操作成功");
  11002. }
  11003. else
  11004. {
  11005. return Error("操作失败");
  11006. }
  11007. }
  11008. else
  11009. {
  11010. return Error("权限不足");
  11011. }
  11012. }
  11013. /// <summary>
  11014. /// 修改回访信息
  11015. /// </summary>
  11016. /// <returns></returns>
  11017. [Authority]
  11018. public ActionResult EditVisitInfoByAdmin()
  11019. {
  11020. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  11021. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  11022. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  11023. {
  11024. string visituser = RequestString.GetFormString("visituser");//回访人
  11025. int type = RequestString.GetInt("type", 0);//回访方式
  11026. int issatisfie = RequestString.GetInt("issatisfie", 0);//0不满意 1满意
  11027. int visitid = RequestString.GetInt("id", 0);
  11028. string result = RequestString.GetFormString("result");//回访情况
  11029. string guid = RequestString.GetFormString("guid");
  11030. Model.T_Bus_VisitResult modelT_Bus_VisitResult = new BLL.T_Bus_VisitResult().GetModel(visitid);
  11031. if (modelT_Bus_VisitResult != null)
  11032. {
  11033. using (TransactionScope trans = new TransactionScope())
  11034. {
  11035. #region 保存回访信息
  11036. modelT_Bus_VisitResult.F_VisitUser = visituser;
  11037. modelT_Bus_VisitResult.F_Type = type;
  11038. modelT_Bus_VisitResult.F_IsSatisfie = issatisfie;
  11039. modelT_Bus_VisitResult.F_Result = result;
  11040. new BLL.T_Bus_VisitResult().Update(modelT_Bus_VisitResult);
  11041. //保存回访记录
  11042. new BLL.T_Bus_VisitResultRecords().AddInfo(modelT_Bus_VisitResult, userModel.F_UserCode, guid);
  11043. #endregion
  11044. #region 插入操作记录
  11045. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  11046. oper.F_WorkOrderId = modelT_Bus_VisitResult.F_WorkOrderId;
  11047. oper.F_File = modelT_Bus_VisitResult.F_File;
  11048. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  11049. oper.F_Message = userinfo + " 修改了工单回访信息";
  11050. oper.F_CreateUser = userModel.F_UserCode;
  11051. oper.F_CreateTime = DateTime.Now;
  11052. oper.F_IsDelete = 0;
  11053. operBLL.Add(oper);
  11054. #endregion
  11055. trans.Complete();
  11056. }
  11057. return Success("操作成功");
  11058. }
  11059. else
  11060. {
  11061. return Error("操作失败");
  11062. }
  11063. }
  11064. else
  11065. {
  11066. return Error("权限不足");
  11067. }
  11068. }
  11069. /// <summary>
  11070. /// 修改退回审核信息
  11071. /// </summary>
  11072. /// <returns></returns>
  11073. [Authority]
  11074. public ActionResult EditAuditRebackByAdmin()
  11075. {
  11076. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  11077. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  11078. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  11079. {
  11080. string reason = RequestString.GetFormString("reason");
  11081. int rebackid = RequestString.GetInt("id", 0);
  11082. Model.T_Bus_Feedback modelT_Bus_Feedback = new BLL.T_Bus_Feedback().GetModel(rebackid);
  11083. if (modelT_Bus_Feedback != null)
  11084. {
  11085. using (TransactionScope trans = new TransactionScope())
  11086. {
  11087. #region 保存反馈信息
  11088. modelT_Bus_Feedback.F_AuditReason = reason;//交办意见
  11089. new BLL.T_Bus_Feedback().Update(modelT_Bus_Feedback);
  11090. #endregion
  11091. #region 插入操作记录
  11092. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  11093. oper.F_WorkOrderId = modelT_Bus_Feedback.F_WorkOrderId;
  11094. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  11095. oper.F_Message = userinfo + " 修改了工单退回审核信息";
  11096. oper.F_CreateUser = userModel.F_UserCode;
  11097. oper.F_CreateTime = DateTime.Now;
  11098. oper.F_IsDelete = 0;
  11099. operBLL.Add(oper);
  11100. #endregion
  11101. trans.Complete();
  11102. }
  11103. return Success("操作成功");
  11104. }
  11105. else
  11106. {
  11107. return Error("操作失败");
  11108. }
  11109. }
  11110. else
  11111. {
  11112. return Error("权限不足");
  11113. }
  11114. }
  11115. /// <summary>
  11116. /// 修改延时审核信息
  11117. /// </summary>
  11118. /// <returns></returns>
  11119. [Authority]
  11120. public ActionResult EditAuditDelayByAdmin()
  11121. {
  11122. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  11123. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  11124. if (userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  11125. {
  11126. string reason = RequestString.GetFormString("reason");
  11127. //DateTime newlimittime = DateTime.Parse(RequestString.GetFormString("newlimittime"));
  11128. int delayid = RequestString.GetInt("id", 0);
  11129. Model.T_Bus_DelayTime modelT_Bus_DelayTime = new BLL.T_Bus_DelayTime().GetModel(delayid);
  11130. if (modelT_Bus_DelayTime != null)
  11131. {
  11132. Model.T_Bus_AssignedInfo modelT_Bus_AssignedInfo = assignBLL.GetModel(modelT_Bus_DelayTime.F_AssignedId.Value);
  11133. using (TransactionScope trans = new TransactionScope())
  11134. {
  11135. #region 保存延时审核信息
  11136. modelT_Bus_DelayTime.F_RefuseReason = reason;
  11137. //modelT_Bus_DelayTime.F_AgreeTime = newlimittime;
  11138. new BLL.T_Bus_DelayTime().Update(modelT_Bus_DelayTime);
  11139. #endregion
  11140. #region 插入操作记录
  11141. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  11142. oper.F_WorkOrderId = modelT_Bus_DelayTime.F_WorkOrderId;
  11143. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  11144. oper.F_Message = userinfo + " 修改了工单延时审核信息";
  11145. oper.F_CreateUser = userModel.F_UserCode;
  11146. oper.F_CreateTime = DateTime.Now;
  11147. oper.F_IsDelete = 0;
  11148. operBLL.Add(oper);
  11149. #endregion
  11150. trans.Complete();
  11151. }
  11152. return Success("操作成功");
  11153. }
  11154. else
  11155. {
  11156. return Error("操作失败");
  11157. }
  11158. }
  11159. else
  11160. {
  11161. return Error("权限不足");
  11162. }
  11163. }
  11164. #endregion
  11165. #region 县级对接
  11166. /// <summary>
  11167. /// 获取网点列表
  11168. /// </summary>
  11169. /// <param name="code"></param>
  11170. /// <param name="name"></param>
  11171. /// <returns></returns>
  11172. [Authority]
  11173. public ActionResult GetCityList(string code, string name)
  11174. {
  11175. string signcode = Configs.GetValue("CityOutSignCode");
  11176. string url = Configs.GetValue("CityOutUrl");
  11177. string outsigncode = CommonHelper.getsigncode("CountyBranch", "GetCityList", signcode);
  11178. string strparams = "?code=" + code + "&name=" + name + "&signcode=" + outsigncode;
  11179. string result = HttpMethods.HttpGet(url + "/CountyBranch/GetCityList" + strparams);
  11180. return Content(result);
  11181. }
  11182. /// <summary>
  11183. /// 获取网点详情
  11184. /// </summary>
  11185. /// <param name="code"></param>
  11186. /// <returns></returns>
  11187. [Authority]
  11188. public ActionResult GetCityDetail(string code)
  11189. {
  11190. string signcode = Configs.GetValue("CityOutSignCode");
  11191. string url = Configs.GetValue("CityOutUrl");
  11192. string outsigncode = CommonHelper.getsigncode("CountyBranch", "GetCityDetail", signcode);
  11193. string strparams = "?code=" + code + "&signcode=" + outsigncode;
  11194. string result = HttpMethods.HttpGet(url + "/CountyBranch/GetCityDetail" + strparams);
  11195. return Content(result);
  11196. }
  11197. /// <summary>
  11198. /// 转派工单到县级
  11199. /// </summary>
  11200. /// <returns></returns>
  11201. [Authority]
  11202. public ActionResult TurnWorkOrder()
  11203. {
  11204. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  11205. Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
  11206. if (userModel.F_RoleCode == "ZXLD" || userModel.F_RoleCode == "ZXLDGLYGLY" || userModel.F_RoleCode == "GLY" || userModel.F_RoleCode == "DDZG")
  11207. {
  11208. string workorderid = RequestString.GetFormString("workorderid");
  11209. string citycode = RequestString.GetFormString("citycode");
  11210. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = workorderBLL.GetModel(workorderid);
  11211. if (modelT_Bus_WorkOrder != null && (modelT_Bus_WorkOrder.F_WorkState == (int)EnumWorkState.submit))
  11212. {
  11213. string code = Configs.GetValue("CityCode");
  11214. var branchmodel = GetCityInfo(code);
  11215. var citymodel = GetCityInfo(citycode);
  11216. if (branchmodel != null && citymodel != null)
  11217. {
  11218. using (TransactionScope trans = new TransactionScope())
  11219. {
  11220. string cityworkorderid = string.Empty;
  11221. #region 转单
  11222. string turnsigncode = citymodel["F_Sign"].ToString();
  11223. string turnurl = citymodel["F_Url"].ToString();
  11224. string turnoutsigncode = CommonHelper.getsigncode("CountyBusiness", "AddWorkOrder", turnsigncode);
  11225. string turnstrparams = "workorderid=" + modelT_Bus_WorkOrder.F_WorkOrderId + "&signcode=" + turnoutsigncode
  11226. + "&citycode=" + branchmodel["F_Code"].ToString() + "&cityname=" + branchmodel["F_Name"].ToString() + "&cusname=" + modelT_Bus_WorkOrder.F_CusName + "&cussex=" + modelT_Bus_WorkOrder.F_CusSex
  11227. + "&cusphone=" + modelT_Bus_WorkOrder.F_CusPhone + "&cusaddress=" + modelT_Bus_WorkOrder.F_CusAddress + "&email=" + modelT_Bus_WorkOrder.F_Email
  11228. + "&zipcode=" + modelT_Bus_WorkOrder.F_ZipCode + "&conname=" + modelT_Bus_WorkOrder.F_ConName + "&conphone=" + modelT_Bus_WorkOrder.F_ConPhone
  11229. + "&title=" + modelT_Bus_WorkOrder.F_ComTitle + "&content=" + modelT_Bus_WorkOrder.F_ComContent + "&sourceaddress=" + modelT_Bus_WorkOrder.F_SourceAddress
  11230. + "&isprotect=" + modelT_Bus_WorkOrder.F_IsProtect + "&level=" + modelT_Bus_WorkOrder.F_Level;
  11231. string turnresultstr = HttpMethods.HttpPost(turnurl + "/CountyBusiness/AddWorkOrder", turnstrparams);
  11232. var turnresult = turnresultstr.ToJObject();
  11233. if (turnresult["state"].ToString() != "success")
  11234. {
  11235. return Content(turnresultstr);
  11236. }
  11237. else
  11238. {
  11239. cityworkorderid = turnresult["data"].ToString();
  11240. }
  11241. #endregion
  11242. #region 保存工单信息
  11243. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.finish;
  11244. modelT_Bus_WorkOrder.F_IsClosed = 1;
  11245. modelT_Bus_WorkOrder.F_Result = "已转单到" + citymodel["F_Name"].ToString();
  11246. modelT_Bus_WorkOrder.F_DealUser = userModel.F_UserCode;
  11247. modelT_Bus_WorkOrder.F_DealTime = DateTime.Now;
  11248. modelT_Bus_WorkOrder.F_CloseUser = userModel.F_UserCode;
  11249. modelT_Bus_WorkOrder.F_CloseTime = DateTime.Now;
  11250. modelT_Bus_WorkOrder.F_AssignUser = userModel.F_UserCode;
  11251. modelT_Bus_WorkOrder.F_AssignTime = DateTime.Now;
  11252. workorderBLL.Update(modelT_Bus_WorkOrder);
  11253. #endregion
  11254. #region 删除草稿信息
  11255. var cglist = assignBLL.GetModelList(" F_IsDelete=0 and F_State=0 and F_WorkOrderId='" + modelT_Bus_WorkOrder.F_WorkOrderId + "'");
  11256. foreach (var cg in cglist)
  11257. {
  11258. cg.F_IsDelete = 1;
  11259. cg.F_DeleteUser = userModel.F_UserCode;
  11260. cg.F_DeleteTime = DateTime.Now;
  11261. assignBLL.Update(cg);
  11262. }
  11263. #endregion
  11264. #region 新增转单记录
  11265. Model.T_Bus_CityTurn modelT_Bus_CityTurn = new Model.T_Bus_CityTurn();
  11266. modelT_Bus_CityTurn.F_CityCode = citycode;
  11267. modelT_Bus_CityTurn.F_CityName = citymodel["F_Name"].ToString();
  11268. modelT_Bus_CityTurn.F_CityWorkOrderId = cityworkorderid;
  11269. modelT_Bus_CityTurn.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  11270. modelT_Bus_CityTurn.F_Type = 2;
  11271. modelT_Bus_CityTurn.F_State = 1;
  11272. modelT_Bus_CityTurn.F_IsSure = 0;
  11273. modelT_Bus_CityTurn.F_IsDelete = 0;
  11274. modelT_Bus_CityTurn.F_CreateTime = DateTime.Now;
  11275. new BLL.T_Bus_CityTurn().Add(modelT_Bus_CityTurn);
  11276. #endregion
  11277. #region 插入操作记录
  11278. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  11279. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  11280. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  11281. string userinfo = userModel.depname + "-" + userModel.F_UserName + "(" + userModel.F_UserCode + ")";
  11282. oper.F_Message = userinfo + " 转派工单到 " + citymodel["F_Name"].ToString();
  11283. oper.F_CreateUser = userModel.F_UserCode;
  11284. oper.F_CreateTime = DateTime.Now;
  11285. oper.F_IsDelete = 0;
  11286. operBLL.Add(oper);
  11287. #endregion
  11288. trans.Complete();
  11289. }
  11290. return Success("操作成功");
  11291. }
  11292. else
  11293. {
  11294. return Error("操作失败");
  11295. }
  11296. }
  11297. else
  11298. {
  11299. return Error("操作失败");
  11300. }
  11301. }
  11302. else
  11303. {
  11304. return Success("权限不足");
  11305. }
  11306. }
  11307. /// <summary>
  11308. /// 获取当前网点信息
  11309. /// </summary>
  11310. /// <returns></returns>
  11311. public Newtonsoft.Json.Linq.JObject GetCityInfo(string code)
  11312. {
  11313. string signcode = Configs.GetValue("CityOutSignCode");
  11314. string url = Configs.GetValue("CityOutUrl");
  11315. string outsigncode = CommonHelper.getsigncode("CountyBranch", "GetCityDetail", signcode);
  11316. string strparams = "?code=" + code + "&signcode=" + outsigncode;
  11317. var result = HttpMethods.HttpGet(url + "/CountyBranch/GetCityDetail" + strparams).ToJObject();
  11318. if (result["state"].ToString() == "success")
  11319. {
  11320. return result["data"].ToString().ToJObject();
  11321. }
  11322. else
  11323. {
  11324. return null;
  11325. }
  11326. }
  11327. #endregion
  11328. #region 私有方法
  11329. /// <summary>
  11330. /// 添加操作日志
  11331. /// </summary>
  11332. /// <param name="workorderid"></param>
  11333. /// <param name="workstate"></param>
  11334. /// <param name="msgs"></param>
  11335. /// <param name="usercode"></param>
  11336. private void addoptlog(string workorderid,int? workstate,int assid,string msgs,string usercode,int type=0)
  11337. {
  11338. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  11339. oper.F_WorkOrderId = workorderid;
  11340. oper.F_State = workstate;
  11341. oper.F_AssignedId = assid;
  11342. oper.F_Message = msgs;
  11343. oper.F_CreateUser = usercode;
  11344. oper.F_CreateTime = DateTime.Now;
  11345. oper.F_IsDelete = 0;
  11346. oper.F_Type = type;
  11347. operBLL.Add(oper);
  11348. }
  11349. #endregion
  11350. }
  11351. }