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