Bez popisu

WxLoginController.cs 287KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.App_Start;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Controllers.workorder;
  6. using CallCenterApi.Interface.Models.Enum;
  7. using CallCenterApi.Interface.Models.Input;
  8. using CallCenterAPI.WechatSDK;
  9. using CallCenterAPI.WechatSDK.Models;
  10. using qcloudsms_csharp;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Text.RegularExpressions;
  17. using System.Web;
  18. using System.Web.Mvc;
  19. namespace CallCenterApi.Interface.Controllers.weixin
  20. {
  21. public class WxLoginController : BaseController
  22. {
  23. private readonly BLL.T_Sys_UserAccount userAccountBLL = new BLL.T_Sys_UserAccount();
  24. private readonly BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
  25. private readonly BLL.T_Cus_CustomerBaseNew customerBaseBLL = new BLL.T_Cus_CustomerBaseNew();
  26. private readonly BLL.T_Cus_CustomerFinance finbll = new BLL.T_Cus_CustomerFinance();
  27. private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
  28. private readonly BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  29. private readonly BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
  30. private readonly BLL.T_Wo_WorkOrder_Logs blllogs = new BLL.T_Wo_WorkOrder_Logs();
  31. private readonly BLL.T_Sys_RoleInfo rolebll = new BLL.T_Sys_RoleInfo();
  32. private readonly BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
  33. private readonly BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
  34. BLL.T_Wo_QuestionManage quesBLL = new BLL.T_Wo_QuestionManage();
  35. ///// <summary>
  36. ///// 绑定微信号
  37. ///// </summary>
  38. ///// <param name="wxLoginDto"></param>
  39. ///// <returns></returns>
  40. //public ActionResult Login(WxLoginDto wxLoginDto)
  41. //{
  42. // var res = Redirect("获取微信openId", wxLoginDto.RedirectUrl);
  43. // var temp = WxHelper.GetOpenId(wxLoginDto);
  44. // if (string.IsNullOrWhiteSpace(temp.OpenId))
  45. // return res;
  46. // //openId => 用户
  47. // //如果不存在,跳转至登录页面
  48. // res = Redirect("绑定微信号", "");
  49. // return res;
  50. //}
  51. /// <summary>
  52. /// 绑定微信号 - 员工和业主分开登陆
  53. /// </summary>
  54. /// <param name="login"></param>
  55. /// <returns></returns>
  56. public ActionResult Login(WxLoginDto login)
  57. {
  58. #region 把其他OpenId更新为空
  59. var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
  60. if (userAccount != null)
  61. {
  62. userAccount.F_WxOpenId = "";
  63. userAccountBLL.Update(userAccount);
  64. }
  65. var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(login.OpenId);
  66. if (modelcustomer != null)
  67. {
  68. modelcustomer.F_WxOpenId = "";
  69. customerBaseBLL.Update(modelcustomer);
  70. }
  71. #endregion
  72. if (string.IsNullOrEmpty(login.UserCode))
  73. return Error("账号不能为空!");
  74. if (string.IsNullOrEmpty(login.Password))
  75. return Error("密码不能为空!");
  76. Model.T_Sys_UserAccount loginCode = new BLL.T_Sys_UserAccount().LoginGetModel(login.UserCode, login.Password);
  77. Model.T_Sys_UserAccount loginwork = new BLL.T_Sys_UserAccount().LogworkGetModel(login.UserCode, login.Password);
  78. if (loginCode != null || loginwork != null)
  79. {
  80. Model.T_Sys_UserAccount loginUser = null;
  81. string deptcode = "";
  82. if (loginCode != null)
  83. loginUser = loginCode;
  84. else
  85. loginUser = loginwork;
  86. loginUser.F_WxOpenId = login.OpenId;
  87. int UserType = 0;string rolecode = "";string UserName = "";string rolename = "";
  88. UserName = loginUser.F_UserName;
  89. //部门
  90. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(loginUser.F_DeptId);
  91. if (modelDep == null)
  92. return Error("获取失败!");
  93. #region 读取角色code
  94. var rolemodel = roleBLL.GetModel(loginUser.F_RoleId);
  95. if (rolemodel != null)
  96. rolecode = rolemodel.F_RoleCode;
  97. #endregion
  98. #region 部门角色
  99. //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
  100. if (loginUser.F_RoleId == 17 )
  101. {
  102. //-1管理员
  103. return Error("无操作权限");
  104. }
  105. else
  106. {
  107. if (loginUser.F_RoleId == 60 )
  108. {
  109. UserType = 0;
  110. rolename ="分公司经理";
  111. }
  112. else if (loginUser.F_RoleId == 62)
  113. {
  114. UserType = 0;
  115. rolename = "大区经理";
  116. }
  117. else if (loginUser.F_RoleId == 61)
  118. {
  119. UserType = 2;
  120. rolename = "高层";
  121. }
  122. else if (loginUser.F_RoleId == 58)
  123. {
  124. UserType = 4;
  125. rolename = "业务员";
  126. }
  127. else if (loginUser.F_RoleId == 59)
  128. {
  129. UserType = 3;
  130. rolename = "办理人员";
  131. }
  132. else
  133. {
  134. return Error("无操作权限");
  135. }
  136. #region
  137. ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
  138. //IF (MODELDEP.F_TYPE == 1)
  139. //{
  140. // //1--接待部
  141. // USERTYPE = 1;
  142. //}
  143. //ELSE IF (MODELDEP.F_TYPE == 2)
  144. //{
  145. // //2--办理人员
  146. // USERTYPE = 2;
  147. //}
  148. //ELSE IF (MODELDEP.F_TYPE == 3)
  149. //{
  150. // //3--区域客服
  151. // USERTYPE = 3;
  152. //}
  153. //ELSE IF (MODELDEP.F_TYPE == 4)
  154. //{
  155. // //4--监管
  156. // USERTYPE = 4;
  157. //}
  158. //ELSE
  159. //{
  160. // USERTYPE = 0;
  161. //}
  162. #endregion
  163. }
  164. #endregion
  165. var obj = new
  166. {
  167. openid = login.OpenId,
  168. usercode = login.UserCode,
  169. usertype = UserType,
  170. UserName= UserName,
  171. rolename = rolename,
  172. rolecode =rolecode,
  173. };
  174. if (userAccountBLL.Update(loginUser))
  175. return Success("绑定成功", obj);
  176. else
  177. return Error("绑定失败");
  178. }
  179. return Error("账号或密码错误,请重新登录");
  180. //else if (login.UserType == 5)
  181. //{
  182. // //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
  183. // Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
  184. // // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
  185. // //首次密码默认为身份证后6位信息
  186. // //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
  187. // 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 ";
  188. // paras_Customer.Add("@F_UserCode", login.UserCode);
  189. // paras_Customer.Add("@F_PassWord", login.Password);
  190. // var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
  191. // if (dt_Customer != null && dt_Customer.Rows.Count > 0)
  192. // {
  193. // //var customer = customerBaseBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
  194. // var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
  195. // customer.F_WxOpenId = login.OpenId;
  196. // #region 新加 - 登录后同时获取用户账号,openid,和角色
  197. // //5--业主(客户档案会员)
  198. // //int UserType = 5;
  199. // var obj = new
  200. // {
  201. // openid = login.OpenId,
  202. // usercode = login.UserCode,
  203. // companyname = customer.F_CompanyName,
  204. // //companyaddress=customer.F_CompanyAddress,
  205. // };
  206. // #endregion
  207. // if (customerBaseBLL.Update(customer))
  208. // return Success("绑定成功!", obj);
  209. // else
  210. // return Error("绑定失败!");
  211. // }
  212. // return Error("账号或密码错误或者没有注册,请重新登录");
  213. //}
  214. return Error("绑定失败");
  215. }
  216. /// <summary>
  217. /// 绑定微信号 - 员工和业主统一登陆 - 不用
  218. /// </summary>
  219. /// <param name="login"></param>
  220. /// <returns></returns>
  221. [WechatActionFilter]
  222. public ActionResult Login2(WxLoginDto login)
  223. {
  224. Dictionary<string, string> paras = new Dictionary<string, string>();
  225. string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
  226. paras.Add("@F_UserCode", login.UserCode);
  227. paras.Add("@F_PassWord", login.Password);
  228. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  229. #region 把其他OpenId更新为空
  230. var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
  231. if (userAccount != null)
  232. {
  233. userAccount.F_WxOpenId = "";
  234. userAccountBLL.Update(userAccount);
  235. }
  236. var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault();//.GetModelByOpenid(login.OpenId);
  237. if (modelcustomer != null)
  238. {
  239. modelcustomer.F_WxOpenId = "";
  240. customerBaseBLL.Update(modelcustomer);
  241. }
  242. #endregion
  243. if (dt != null && dt.Rows.Count > 0)
  244. {
  245. var user = userAccountBLL.GetModel(login.UserCode);
  246. user.F_WxOpenId = login.OpenId;
  247. //int UserType = 0;
  248. //部门
  249. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
  250. if (modelDep == null)
  251. return Error("获取失败!");
  252. #region 部门角色
  253. ////部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
  254. //if (user.F_RoleId == 17)
  255. //{
  256. // //-1管理员
  257. // UserType = -1;
  258. //}
  259. //else
  260. //{
  261. // //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  262. // if (modelDep.F_Type == 1)
  263. // {
  264. // //1--接待部
  265. // UserType = 1;
  266. // }
  267. // else if (modelDep.F_Type == 2)
  268. // {
  269. // //2--办理人员
  270. // UserType = 2;
  271. // }
  272. // else if (modelDep.F_Type == 3)
  273. // {
  274. // //3--区域客服
  275. // UserType = 3;
  276. // }
  277. // else if (modelDep.F_Type == 4)
  278. // {
  279. // //4--监管
  280. // UserType = 4;
  281. // }
  282. // else
  283. // {
  284. // UserType = 0;
  285. // }
  286. //}
  287. #endregion
  288. var obj = new
  289. {
  290. openid = login.OpenId,
  291. usercode = login.UserCode,
  292. //usertype = UserType
  293. };
  294. if (userAccountBLL.Update(user))
  295. {
  296. return Success("绑定成功", obj);
  297. }
  298. else
  299. {
  300. return Error("绑定失败");
  301. }
  302. }
  303. else
  304. {
  305. //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
  306. Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
  307. // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
  308. //首次密码默认为身份证后6位信息
  309. //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
  310. string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
  311. paras_Customer.Add("@F_UserCode", login.UserCode);
  312. paras_Customer.Add("@F_PassWord", login.Password);
  313. var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
  314. if (dt_Customer != null && dt_Customer.Rows.Count > 0)
  315. {
  316. var customer = customerBaseBLL.GetModelList(" F_CustomerCode='" + login.UserCode + "'").FirstOrDefault(); //customerBaseBLL.GetModel(login.UserCode);
  317. customer.F_WxOpenId = login.OpenId;
  318. #region 新加 - 登录后同时获取用户账号,openid,和角色
  319. //5--业主(客户档案会员)
  320. //int UserType = 5;
  321. var obj = new
  322. {
  323. openid = login.OpenId,
  324. usercode = login.UserCode,
  325. //usertype = UserType
  326. };
  327. #endregion
  328. if (customerBaseBLL.Update(customer))
  329. {
  330. return Success("绑定成功!", obj);
  331. }
  332. else
  333. {
  334. return Error("绑定失败!");
  335. }
  336. }
  337. else
  338. {
  339. return Error("账号或密码错误,请重新登录");
  340. }
  341. //return Error("账号或密码错误,请重新登录");
  342. }
  343. }
  344. /// <summary>
  345. /// 获取微信openid
  346. /// </summary>
  347. /// <param name="login"></param>
  348. /// <returns></returns>
  349. public ActionResult GetOpenId(WxLoginDto wld)
  350. {
  351. wld.RedirectUrl = RequestString.GetUrlReferrer();
  352. if (string.IsNullOrEmpty(wld.OpenId))
  353. {
  354. var temp = WxHelper.GetOpenId(wld);
  355. if (string.IsNullOrWhiteSpace(temp.OpenId))
  356. {
  357. //Request.QueryString[ ] == null
  358. return Redirect("请求", temp.RedirectUrl);
  359. }
  360. wld.OpenId = temp.OpenId;
  361. #region 获取是否绑定用户表
  362. //获取是否绑定用户表
  363. var usertemp = new BLL.T_Sys_UserAccount().GetModelByOpenid(wld.OpenId);
  364. if (usertemp != null)
  365. {
  366. //部门
  367. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(usertemp.F_DeptId);
  368. if (modelDep == null)
  369. return Error("获取失败!");
  370. wld.UserCode = usertemp.F_UserCode;
  371. #region 读取角色code
  372. var rolemodel = roleBLL.GetModel(usertemp.F_RoleId);
  373. if (rolemodel != null)
  374. wld.RoleCode = rolemodel.F_RoleCode;
  375. #endregion
  376. #region 部门角色
  377. if (usertemp.F_RoleId == 17)
  378. {
  379. //-1管理员
  380. wld.UserType = -1;
  381. }
  382. else
  383. {
  384. if (usertemp.F_RoleId == 60 || usertemp.F_RoleId == 62)
  385. {
  386. wld.UserType = 0;
  387. }
  388. else if (usertemp.F_RoleId == 61)
  389. {
  390. wld.UserType = 2;
  391. }
  392. else if (usertemp.F_RoleId == 58)
  393. {
  394. wld.UserType = 4;
  395. }
  396. else if (usertemp.F_RoleId == 59)
  397. {
  398. wld.UserType = 3;
  399. }
  400. else
  401. {
  402. wld.UserType = 1;
  403. }
  404. #region
  405. ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
  406. //IF (MODELDEP.F_TYPE == 1)
  407. //{
  408. // //1--接待部
  409. // USERTYPE = 1;
  410. //}
  411. //ELSE IF (MODELDEP.F_TYPE == 2)
  412. //{
  413. // //2--办理人员
  414. // USERTYPE = 2;
  415. //}
  416. //ELSE IF (MODELDEP.F_TYPE == 3)
  417. //{
  418. // //3--区域客服
  419. // USERTYPE = 3;
  420. //}
  421. //ELSE IF (MODELDEP.F_TYPE == 4)
  422. //{
  423. // //4--监管
  424. // USERTYPE = 4;
  425. //}
  426. //ELSE
  427. //{
  428. // USERTYPE = 0;
  429. //}
  430. #endregion
  431. #region
  432. ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
  433. //if (modelDep.F_Type == 1)
  434. //{
  435. // //1--接待部
  436. // wld.UserType = 1;
  437. //}
  438. //else if (modelDep.F_Type == 2)
  439. //{
  440. // //2--办理人员
  441. // wld.UserType = 2;
  442. //}
  443. //else if (modelDep.F_Type == 3)
  444. //{
  445. // //3--区域客服
  446. // wld.UserType = 3;
  447. //}
  448. //else if (modelDep.F_Type == 4)
  449. //{
  450. // //4--监管
  451. // wld.UserType = 4;
  452. //}
  453. //else
  454. //{
  455. // wld.UserType = 0;
  456. //}
  457. #endregion
  458. }
  459. #endregion
  460. }
  461. else
  462. {
  463. var customertemp = customerBaseBLL.GetModelByOpenid(wld.OpenId);
  464. if (customertemp != null)
  465. {
  466. wld.UserCode = customertemp.F_CustomerCode;
  467. //5--业主(客户档案会员)
  468. wld.UserType = 5;
  469. }
  470. else
  471. {
  472. wld.UserCode = "";
  473. }
  474. //wld.UserCode = "";
  475. }
  476. #endregion
  477. }
  478. var model = new BLL.T_Sys_Users().GetModel(wld.OpenId);
  479. if (model == null)
  480. {
  481. model = new Model.T_Sys_Users();
  482. model.F_OpenId = wld.OpenId;
  483. model.F_Type = 1;
  484. model.F_CreateTime = DateTime.Now;
  485. new BLL.T_Sys_Users().Add(model);
  486. }
  487. var newobj = new
  488. {
  489. openid = wld.OpenId,
  490. usercode = wld.UserCode,
  491. usertype = wld.UserType,
  492. rolecode = wld.RoleCode,
  493. };
  494. return Success("成功", newobj);
  495. }
  496. /// <summary>
  497. ///退回工单列表
  498. /// </summary>
  499. public string GetBackid(Model.T_Sys_UserAccount ua)
  500. {
  501. string str = string.Empty;
  502. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType in(" + (int)EnumItemType.deal+"," + (int)EnumItemType.audit + ")"
  503. + " and "
  504. + "F_OptType in(" + (int)EnumItemOpt.abreback + "," + (int)EnumItemOpt.reback + ") and F_NextUser='" + ua.F_UserCode + "'"
  505. + ""
  506. + " and isnull(F_IsUsed,'0')='0' ";
  507. return str;
  508. }
  509. /// <summary>
  510. ///工单列表
  511. /// </summary>
  512. public ActionResult GetList(string OpenId, string code, string cusname, string keywords, string cusphone, string companyname, string province, string city,
  513. string country, string township, string category, string salebase, string touser, int source = 0, int state = -1,int status=-1, int type = 0, int pageindex = 1, int pagesize = 10)
  514. {
  515. // int userId = CurrentUser.UserData.F_UserId;
  516. if (!string.IsNullOrEmpty(OpenId))
  517. {
  518. // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
  519. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  520. if (source !=3)
  521. {
  522. if (ua == null)
  523. {
  524. return Error("该账号已在别的设备登录,请及时修改密码重新登录。");
  525. }
  526. }
  527. // Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
  528. string sql = $" and F_IsDelete=0";
  529. DataTable dt = new DataTable();
  530. #region 筛选条件
  531. if (type > 0 && type < 5)//工单类型
  532. sql += $" and F_Type=" + type;
  533. if (source > 0)//工单来源
  534. sql += $" and F_Source=" + source;
  535. if (!string.IsNullOrWhiteSpace(touser))//参与人
  536. sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
  537. if (!string.IsNullOrWhiteSpace(code))//工单编号
  538. sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
  539. if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
  540. sql += $" and (F_QuestionType like '%" + keywords.Trim()
  541. + "%' or F_ZX_Area like '%" + keywords.Trim() + "%' or F_ZX_Branch like '%" + keywords.Trim()
  542. + "%' or F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%' ) ";
  543. if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
  544. sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
  545. if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
  546. sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
  547. if (!string.IsNullOrWhiteSpace(companyname))//公司名称
  548. sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
  549. if (!string.IsNullOrWhiteSpace(category))//产品名称
  550. sql += $" and F_TS_Category like '%" + category.Trim() + "%'";
  551. if (!string.IsNullOrWhiteSpace(salebase))//销售基地
  552. sql += $" and F_SalesBase like '%" + salebase.Trim() + "%'";
  553. if (!string.IsNullOrWhiteSpace(province))//省
  554. sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
  555. if (!string.IsNullOrWhiteSpace(province))//市
  556. sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
  557. if (!string.IsNullOrWhiteSpace(province))//县
  558. sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
  559. if (!string.IsNullOrWhiteSpace(province))//乡
  560. sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
  561. // sql += " and (F_CreateBy= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.F_ID in ( " + GetCYWorkOrderID(ua.F_UserCode) + ")) ";
  562. if (ua !=null )
  563. {
  564. Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
  565. if (source==3)
  566. {
  567. sql += $" and F_WxOpenId ='" + OpenId + "'";
  568. }
  569. switch (state)
  570. {
  571. case 0://待审批
  572. string uwhere = "";
  573. if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL")
  574. {
  575. if (GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) != "")
  576. {
  577. sql += " and T_Wo_WorkOrder.F_ID in ( " + GetApprovalOrderID(ua, OpenId, ro.F_RoleCode) + ") ";
  578. }
  579. else
  580. {
  581. return Success("暂无工单");
  582. }
  583. }
  584. else
  585. {
  586. return Success("无操作权限");
  587. }
  588. break;
  589. case 11://已创单
  590. sql += $" and F_CreateBy ='" + ua.F_UserCode + "'";
  591. break;
  592. case 12://退单
  593. if (GetBackid(ua) != "")
  594. {
  595. sql += " and T_Wo_WorkOrder.F_ID in ( " + GetBackid(ua) + ") ";
  596. }
  597. else
  598. {
  599. return Success("暂无工单");
  600. }
  601. break;
  602. case 1://已审核
  603. if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL"|| ro.F_RoleCode == "GC")
  604. {
  605. if (GetApprovedOrderID(ua.F_UserCode) != "")
  606. {
  607. sql += $" and F_ID in ( " + GetApprovedOrderID(ua.F_UserCode) + ") "; ;
  608. }
  609. else
  610. {
  611. return Error("暂无工单");
  612. }
  613. }
  614. else
  615. {
  616. return Success("暂无工单");
  617. }
  618. break;
  619. case 2://待完成的(待接单)
  620. if (GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) != "")
  621. {
  622. sql += $" and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.reassign + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.assign + ") and T_Wo_WorkOrder.F_ID in ( " +
  623. GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) + ") "; ;
  624. }
  625. else
  626. {
  627. return Success("暂无工单"); ;
  628. }
  629. break;
  630. case 5://待审批
  631. if (ro.F_RoleCode == "GC")
  632. {
  633. if (GetHApproval(ua.F_UserCode) != "")
  634. {
  635. sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetHApproval(ua.F_UserCode) + ") "; ;
  636. }
  637. }
  638. else
  639. {
  640. return Success("暂无工单"); ;
  641. }
  642. break;
  643. case 4://待完成的(待处理)
  644. if (GetDWCWorkOrderID(ua.F_UserCode) != null)
  645. {
  646. sql += " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.reassign + ") and T_Wo_WorkOrder.F_ID in ( " + GetDWCWorkOrderID(ua.F_UserCode) + ") ";
  647. }
  648. else
  649. {
  650. return Success("暂无工单"); ;
  651. }
  652. break;
  653. case 10://已完成的
  654. sql += " and F_State =" + (int)EnumWorkOrderState.finish + " and F_DealBy = '" + ua.F_UserCode + "' ";
  655. break;
  656. case 3://我参与的
  657. if (GetParticipateID(ua.F_UserCode) != "")
  658. {
  659. sql += " and T_Wo_WorkOrder.F_ID in ( " + GetParticipateID(ua.F_UserCode) + ") ";
  660. }
  661. else
  662. {
  663. return Error("暂无工单");
  664. }
  665. break;
  666. case 6://待回访
  667. if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
  668. {
  669. uwhere = "";
  670. }
  671. else
  672. {
  673. return Success("无操作权限"); ;
  674. }
  675. sql += $" and F_State=" + (int)EnumWorkOrderState.finish + " and F_IsVisit = '" + "1" + "' " + uwhere; ;
  676. break;
  677. case 7://已回访
  678. if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
  679. {
  680. if (GetCYWorkOrderID(ua.F_UserCode) != "")
  681. {
  682. sql += " and (F_CreateBy= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.F_ID in ( " + GetCYWorkOrderID(ua.F_UserCode) + ")) ";
  683. }
  684. else
  685. {
  686. return Success("暂无工单"); ;
  687. }
  688. sql += $" and F_State=" + (int)EnumWorkOrderState.evaluate;
  689. }
  690. else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
  691. {
  692. string detpid = "";
  693. var deparmentlist = new List<Model.T_Sys_Department>();
  694. Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
  695. if (dModel != null)
  696. {
  697. if (dModel.F_Layer == 1)
  698. {
  699. deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
  700. if (deparmentlist.Count > 0)
  701. {
  702. foreach (var it in deparmentlist)
  703. {
  704. if (detpid != "")
  705. {
  706. detpid += "," + it.F_DeptId;
  707. }
  708. else
  709. {
  710. detpid = "" + it.F_DeptId; ;
  711. }
  712. }
  713. }
  714. }
  715. else
  716. {
  717. detpid = ua.F_DeptId.ToString();
  718. }
  719. if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.evaluate + "") != "")
  720. {
  721. sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.evaluate + "") + ") "; ;
  722. }
  723. else
  724. {
  725. return Success("暂无工单"); ;
  726. }
  727. }
  728. else
  729. {
  730. return Error("加载失败");
  731. }
  732. }
  733. else
  734. {
  735. return Success("无操作权限"); ;
  736. }
  737. sql += $" and F_State=" + (int)EnumWorkOrderState.evaluate;
  738. break;
  739. case 8://待完结
  740. if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBZZX")
  741. {
  742. uwhere = ""; ;
  743. }
  744. else
  745. {
  746. return Success("无操作权限"); ;
  747. }
  748. sql += $" and F_State=" + (int)EnumWorkOrderState.finish + " and F_IsVisit = '" + "0" + "' "; ;
  749. break;
  750. case 9://待接单
  751. if (GetDeptWorkOrderID(ua.F_DeptId,ua .F_UserCode ) != "")
  752. {
  753. sql += $" and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.reassign + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.assign + ") and T_Wo_WorkOrder.F_ID in ( " +
  754. GetDeptWorkOrderID(ua.F_DeptId, ua.F_UserCode) + ") "; ;
  755. }
  756. else
  757. {
  758. return Success("暂无工单"); ;
  759. }
  760. break;
  761. }
  762. }
  763. else
  764. {
  765. sql += $" and F_WxOpenId ='" + OpenId+"'";
  766. }
  767. #endregion
  768. int recordCount = 0;
  769. if (!string.IsNullOrWhiteSpace(sql))
  770. {
  771. dt = BLL.PagerBLL.GetListPager(
  772. "T_Wo_WorkOrder",
  773. "F_ID",
  774. "*",
  775. sql,
  776. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  777. pagesize,
  778. pageindex,
  779. true,
  780. out recordCount);
  781. }
  782. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  783. if (modlelist.Count > 0)
  784. {
  785. List<WorkOrderNewInput> Input = modeltooip(modlelist,ua );
  786. var obj = new
  787. {
  788. state = "success",
  789. message = "成功",
  790. rows = Input,
  791. total = recordCount
  792. };
  793. return Content(obj.ToJson()); ;
  794. }
  795. else
  796. {
  797. return Success("暂无工单"); ;
  798. }
  799. }
  800. else
  801. {
  802. return Error("无操作权限!");
  803. }
  804. }
  805. /// <summary>
  806. ///综合查询列表
  807. /// </summary>
  808. public ActionResult GetComprehensive(string OpenId,string code, string createby,string cusname, string keywords, string cusphone, string companyname, string province, string city,
  809. 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)
  810. {
  811. if (!string.IsNullOrEmpty(OpenId))
  812. {
  813. // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
  814. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  815. if (ua == null)
  816. {
  817. return Error("该账号已在别的设备登录,请及时修改密码重新登录。");
  818. }
  819. string sql = $" and F_IsDelete=0";
  820. DataTable dt = new DataTable();
  821. #region 筛选条件
  822. if (type > 0 && type < 5)//工单类型
  823. sql += $" and F_Type=" + type;
  824. if (state >= 0)//
  825. sql += $" and F_State=" + state;
  826. if (source > 0)//工单来源
  827. sql += $" and F_Source=" + source;
  828. if (!string.IsNullOrWhiteSpace(createby))//创建人
  829. sql += $" and F_CreateBy like '%" + createby.Trim() + "%'";
  830. if (!string.IsNullOrWhiteSpace(touser))//参与人
  831. sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
  832. if (!string.IsNullOrWhiteSpace(code))//工单编号
  833. sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
  834. if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
  835. sql += $" and ( F_QuestionType like '%" + keywords.Trim()
  836. + "%' or F_ZX_Area like '%" + keywords.Trim() + "%' or F_ZX_Branch like '%" + keywords.Trim()
  837. + "%' or F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%') ";
  838. if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
  839. sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
  840. if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
  841. sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
  842. if (!string.IsNullOrWhiteSpace(companyname))//公司名称
  843. sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
  844. if (!string.IsNullOrWhiteSpace(category))//产品名称
  845. sql += $" and F_TS_Category like '%" + category.Trim() + "%'";
  846. if (!string.IsNullOrWhiteSpace(salebase))//销售基地
  847. sql += $" and F_SalesBase like '%" + salebase.Trim() + "%'";
  848. if (!string.IsNullOrWhiteSpace(province))//省
  849. sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
  850. if (!string.IsNullOrWhiteSpace(province))//市
  851. sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
  852. if (!string.IsNullOrWhiteSpace(province))//县
  853. sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
  854. if (!string.IsNullOrWhiteSpace(province))//乡
  855. sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
  856. if (ua !=null )
  857. {
  858. Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
  859. if (ro.F_RoleCode == "QTJS" || ro.F_RoleCode == "YWY")
  860. {
  861. sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
  862. }
  863. else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "ZG")
  864. {
  865. string detpid = "";
  866. var deparmentlist = new List<Model.T_Sys_Department>();
  867. Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
  868. if (dModel != null)
  869. {
  870. if (dModel.F_Layer == 1)
  871. {
  872. deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
  873. if (deparmentlist.Count > 0)
  874. {
  875. foreach (var it in deparmentlist)
  876. {
  877. if (detpid != "")
  878. {
  879. detpid += "," + it.F_DeptId;
  880. }
  881. else
  882. {
  883. detpid = "" + it.F_DeptId;
  884. }
  885. }
  886. }
  887. }
  888. else
  889. {
  890. detpid = ua.F_DeptId.ToString();
  891. }
  892. if (state >= 0)
  893. {
  894. if (GetDeptWorkOrderID(detpid, "" + state + "") != "")
  895. {
  896. sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + state + "") + ") ";
  897. }
  898. else
  899. {
  900. return Success("暂无工单"); ;
  901. }
  902. }
  903. else
  904. {
  905. if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.neworder + ", " + (int)EnumWorkOrderState.assign + "," +
  906. (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish
  907. + "," + (int)EnumWorkOrderState.evaluate + "") != "")
  908. {
  909. sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.neworder + ", " + (int)EnumWorkOrderState.assign + "," +
  910. (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish
  911. + "," + (int)EnumWorkOrderState.evaluate + "") + ") ";
  912. }
  913. else
  914. {
  915. return Success("暂无工单"); ;
  916. }
  917. }
  918. }
  919. else
  920. {
  921. return Error("加载失败");
  922. }
  923. }
  924. }
  925. else
  926. {
  927. return Error("无操作权限");
  928. }
  929. #endregion
  930. int recordCount = 0;
  931. if (!string.IsNullOrWhiteSpace(sql))
  932. {
  933. dt = BLL.PagerBLL.GetListPager(
  934. "T_Wo_WorkOrder",
  935. "F_ID",
  936. "*",
  937. sql,
  938. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  939. pagesize,
  940. pageindex,
  941. true,
  942. out recordCount);
  943. }
  944. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  945. if (modlelist.Count > 0)
  946. {
  947. List<WorkOrderNewInput> Input = modeltooip(modlelist,ua );
  948. var obj = new
  949. {
  950. state = "success",
  951. message = "成功",
  952. rows = Input,
  953. total = recordCount
  954. };
  955. return Content(obj.ToJson()); ;
  956. }
  957. else
  958. {
  959. return Success("暂无工单"); ;
  960. }
  961. }
  962. else
  963. {
  964. return Error("无操作权限!");
  965. }
  966. }
  967. /// <summary>
  968. /// 根据部门获取工单号
  969. /// </summary>
  970. /// <returns></returns>
  971. public string GetDeptWorkOrderID(string user, string F_ItemType)
  972. {
  973. string sql = " ";
  974. string ua = "";
  975. DataTable dt = new DataTable();
  976. if (user != "")
  977. {
  978. sql += " and F_DeptId in ( " + user + ") ";
  979. }
  980. int recordCount;
  981. dt = BLL.PagerBLL.GetListPager(
  982. "T_Sys_UserAccount",
  983. "F_UserId",
  984. "*",
  985. sql,
  986. "ORDER BY F_UserId desc",
  987. 10000,
  988. 1,
  989. true,
  990. out recordCount);
  991. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  992. if (modelList != null)
  993. {
  994. foreach (var it in modelList)
  995. {
  996. if (ua != "")
  997. ua += "," + it.F_UserCode;
  998. else
  999. ua += it.F_UserCode;
  1000. }
  1001. }
  1002. string str = string.Empty;
  1003. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType in(" + F_ItemType + ")"
  1004. + " and "
  1005. + "F_CreateUser in(" + ua + ")"
  1006. ;
  1007. return str;
  1008. }
  1009. /// <summary>
  1010. /// 获取待完成的工单编号
  1011. /// </summary>
  1012. /// <returns></returns>
  1013. public string GetDWCWorkOrderID(string user)
  1014. {
  1015. string str = string.Empty;
  1016. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
  1017. + " and ("
  1018. + "(F_WoState in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + ") and F_CreateUser='" + user + "') "//办理中和接单状态的操作人
  1019. + " or (F_WoState in(" + (int)EnumWorkOrderState.reback + ") and F_NextUser='" + user + "')"//退回下一步操作人
  1020. + ")"
  1021. + " and isnull(F_IsUsed,'0')='0' ";
  1022. return str;
  1023. }
  1024. public string GetHApproval(string user)
  1025. {
  1026. string str = string.Empty;
  1027. 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";
  1028. return str;
  1029. }
  1030. /// <summary>
  1031. /// 获取部门待完成的工单编号
  1032. /// </summary>
  1033. /// <returns></returns>
  1034. public string GetDeptWorkOrderID(int deptid, string user)
  1035. {
  1036. string str = string.Empty;
  1037. string deptuser = string.Empty;
  1038. var dept = userAccountBLL .GetModelList("F_DeptId=" + deptid);
  1039. if (dept != null)
  1040. {
  1041. foreach (var it in dept)
  1042. {
  1043. if (it.F_UserCode != user)
  1044. {
  1045. if (deptuser != "")
  1046. deptuser += "','" + it.F_UserCode;
  1047. else
  1048. deptuser += it.F_UserCode;
  1049. }
  1050. }
  1051. }
  1052. if (!string.IsNullOrEmpty(deptuser))
  1053. {
  1054. // string deptuser = "select F_WoID from T_Sys_UserAccount where F_DeptId=" + deptid;
  1055. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
  1056. + " and isnull(F_IsUsed,'0')='0' " + " and "
  1057. + "(F_WoState in(" + (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.reback + ") and F_NextDept =" + deptid + ") "//办理中和接单状态的操作人
  1058. + " or (F_WoState =" + (int)EnumWorkOrderState.receive + " and F_NextUser in('" + deptuser + "'))";//退回下一步操作人
  1059. }
  1060. else
  1061. {
  1062. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
  1063. + " and "
  1064. + "F_WoState in(" + (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.abreback + ") and F_NextDept =" + deptid + " "//办理中和接单状态的操作人
  1065. + " and isnull(F_IsUsed,'0')='0' ";
  1066. }
  1067. return str;
  1068. }
  1069. /// <summary>
  1070. /// 审核工单
  1071. /// </summary>
  1072. public ActionResult GetApproval(string OpenId,long orderid, string AuditCont, int IsAudit=0,int AuditState=0,float overtime = 0, int sms = 0)
  1073. {
  1074. if (!string.IsNullOrEmpty(OpenId))
  1075. {
  1076. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  1077. if (ua != null)
  1078. {
  1079. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  1080. if (model != null)
  1081. {
  1082. var res = Approval( OpenId, orderid, AuditCont, ua, model, overtime, sms, IsAudit, AuditState);
  1083. if (res)
  1084. return Success("审核成功");
  1085. else
  1086. return Error("审核失败");
  1087. }
  1088. else
  1089. return Error("工单不存在");
  1090. }
  1091. }
  1092. return Error("OpenId不能为空");
  1093. }
  1094. /// <summary>
  1095. /// 填写超时原因
  1096. /// </summary>
  1097. /// <param name="input"></param>
  1098. /// <returns></returns>
  1099. [WechatActionFilter]
  1100. public ActionResult Reasontimeout(string OpenId, long orderid, string cont)
  1101. {
  1102. if (!string.IsNullOrEmpty(OpenId))
  1103. {
  1104. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  1105. if (ua != null)
  1106. {
  1107. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  1108. //验证信息
  1109. if (model != null)
  1110. {
  1111. model.F_Reasontimeout = cont;
  1112. bool n = woBLL.Update(model);
  1113. if (n)
  1114. return Success("填写成功");
  1115. else
  1116. return Error("填写失败!");
  1117. }
  1118. return Error("工单不存在");
  1119. }
  1120. }
  1121. return Error("无操作权限");
  1122. }
  1123. /// <summary>
  1124. /// 审核工单
  1125. /// </summary>
  1126. [WechatActionFilter]
  1127. public bool Approval(string OpenId, long orderid, string AuditCont, Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model,float overtime = 0, int sms = 0,int IsAudit = 0, int AuditState = 0)
  1128. {
  1129. bool res=true ;
  1130. string touser = ""; string tousername = "";
  1131. string opt = "审核";
  1132. #region 获取接收人
  1133. string deptname = "";
  1134. string deptmodelsname = "";
  1135. int wostate = 0;
  1136. var toussers = "";
  1137. #region 上报
  1138. if (IsAudit!=0)
  1139. {
  1140. if (GetUser(OpenId) != null)
  1141. {
  1142. var user = GetUser(OpenId);
  1143. var deptmodel = departmentBLL.GetModel(user.F_DeptId);
  1144. var deptmodels = departmentBLL.GetModel(nowUser.F_DeptId);
  1145. if (deptmodel != null)
  1146. {
  1147. deptname = deptmodel.F_DeptName + "-";
  1148. }
  1149. if (deptmodels != null)
  1150. {
  1151. deptmodelsname = deptmodels.F_DeptName + "-";
  1152. }
  1153. 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_CreateTime desc").FirstOrDefault();
  1154. if (itemlast != null)
  1155. toussers = itemlast.F_CreateUser;
  1156. wostate = 16;
  1157. if (AuditState == 0)
  1158. {
  1159. opt = "同意上报";
  1160. 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);
  1161. 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);
  1162. if (userid <= 0 || uaid <= 0)
  1163. res = false;
  1164. }
  1165. else if (AuditState == 1)
  1166. {
  1167. opt = "驳回修订";
  1168. 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);
  1169. if (userid <= 0)
  1170. res = false;
  1171. }
  1172. else
  1173. {
  1174. opt = "强制结案";
  1175. wostate = 11;
  1176. 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);
  1177. if (userid <= 0)
  1178. res = false;
  1179. }
  1180. }
  1181. else
  1182. {
  1183. Model.T_Sys_RoleInfo ro = rolebll.GetModel(nowUser.F_RoleId);
  1184. if (ro.F_RoleCode == "DQJL")
  1185. {
  1186. 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_CreateTime desc").FirstOrDefault();
  1187. if (itemlast != null)
  1188. toussers = itemlast.F_CreateUser;
  1189. if (AuditState == 0)
  1190. {
  1191. opt = "同意上报";
  1192. 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);
  1193. res = GetDaQucirCulation(AuditCont,nowUser, DateTime.Now.ToString(), model.F_ID,true );
  1194. if (userid <= 0 || !res)
  1195. res = false;
  1196. wostate = 1;
  1197. }
  1198. else if (AuditState == 1)
  1199. {
  1200. opt = "驳回修订";
  1201. 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);
  1202. if (userid <= 0)
  1203. res = false;
  1204. wostate = 16;
  1205. }
  1206. else
  1207. {
  1208. opt = "强制结案";
  1209. 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);
  1210. if (userid <= 0 )
  1211. res = false;
  1212. wostate = 11;
  1213. }
  1214. }
  1215. else
  1216. {
  1217. res = false;
  1218. }
  1219. }
  1220. }
  1221. #endregion
  1222. #endregion
  1223. if (res)
  1224. {
  1225. model.F_State = wostate;
  1226. //处理内容
  1227. if (!string.IsNullOrEmpty(AuditCont))
  1228. model.F_AuditCont += AuditCont + ";";
  1229. model.F_IsAudit = IsAudit;
  1230. model.F_AuditState = AuditState;
  1231. model.F_AuditBy = nowUser.F_UserCode ;
  1232. model.F_AuditOn =DateTime .Now ;
  1233. woBLL .Update(model);
  1234. if (nowUser.F_UserCode != model.F_CreateBy)
  1235. {
  1236. sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//
  1237. var createmodel = userAccountBLL.GetModel(model.F_CreateBy); //
  1238. if (createmodel != null)
  1239. {
  1240. if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
  1241. {
  1242. sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
  1243. }
  1244. }
  1245. }
  1246. #region 向下一级操作人员推送消息
  1247. if (!string.IsNullOrWhiteSpace(touser))
  1248. {
  1249. sendsysmsg(model, nowUser, touser, (int)model.F_ID, opt);//
  1250. var modelUser2 = userAccountBLL.GetModel(touser); //
  1251. if (modelUser2 != null)
  1252. {
  1253. if (!string.IsNullOrEmpty(modelUser2.F_WxOpenId))
  1254. {
  1255. sendwxmsg(model, modelUser2.F_WxOpenId, nowUser, opt);
  1256. }
  1257. }
  1258. }
  1259. #endregion 向下一级操作人员推送消息
  1260. }
  1261. else
  1262. return false ;
  1263. return true ;
  1264. }
  1265. /// <summary>
  1266. /// 大区经理未审批流转市场管理科
  1267. /// </summary>
  1268. /// <param name="ua"></param>
  1269. /// <param name="time"></param>
  1270. /// <param name="id"></param>
  1271. public bool GetDaQucirCulation(string AuditCont,Model.T_Sys_UserAccount ua,string time,long id,bool istrue)
  1272. {
  1273. DateTime times = DateTime.Parse(time).AddHours(24);
  1274. Model.T_Wo_WorkOrder model = woBLL.GetModel(id);
  1275. List<Model.T_Wo_WorkOrder> modeLlist = new List<Model.T_Wo_WorkOrder>();
  1276. modeLlist.Add(model);
  1277. List<WorkOrderNewInput> Input = modeltooip(modeLlist,ua );
  1278. string cont = "";
  1279. int dapt = 0, nextda = 0; string opt = "";
  1280. var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
  1281. if (deptmodel1 != null)
  1282. {
  1283. dapt = deptmodel1.F_ParentId;
  1284. }
  1285. if (dapt != 0)
  1286. {
  1287. if (dapt == 11)
  1288. {
  1289. nextda = 37;
  1290. opt = "流转市场管理科";
  1291. }
  1292. else if (dapt == 14)
  1293. {
  1294. nextda = 57;
  1295. opt = "流转营销管理处";
  1296. }
  1297. else if (dapt == 15)
  1298. {
  1299. nextda = 74;
  1300. opt = "流转策划推广";
  1301. }
  1302. else if (dapt == 16)
  1303. {
  1304. nextda = 88;
  1305. opt = "流转销售部";
  1306. }
  1307. }
  1308. if (istrue)
  1309. {
  1310. cont = "大区经理已审批:"+ AuditCont+","+ opt;
  1311. }
  1312. else
  1313. {
  1314. cont = "大区经理未审批"+ opt;
  1315. }
  1316. if (nextda != 0)
  1317. {
  1318. var res = AssignWO(ua, model, Input[0], cont, "", nextda, 0, 0, 0, 0, 0, 0, time.ToString());
  1319. return res;
  1320. }
  1321. else
  1322. {
  1323. return false ;
  1324. }
  1325. }
  1326. /// <summary>
  1327. /// 查询工单详情
  1328. /// </summary>
  1329. [WechatActionFilter]
  1330. public ActionResult GetDetails(string OpenId,int id)
  1331. {
  1332. if (!string.IsNullOrEmpty(OpenId))
  1333. {
  1334. if (id <= 0)
  1335. {
  1336. return Error("请输入正确的id");
  1337. }
  1338. DataTable FileUrl = new DataTable();
  1339. var list = new List<Model.T_Wo_WorkOrder>();
  1340. var model = woBLL .GetModel(id);
  1341. if (model != null)
  1342. list.Add(model);
  1343. var itemlasts = itembll.GetModelList(" F_WoID=" + +id + " ");
  1344. ; var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  1345. if (!string .IsNullOrEmpty (model.F_Files))
  1346. {
  1347. FileUrl = GetFileData(model.F_Files, configfj.F_ParamValue);
  1348. }
  1349. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  1350. if (model .F_Source !="3")
  1351. {
  1352. if (ua == null)
  1353. {
  1354. return Error("该账号已在别的设备登录,请及时修改密码重新登录。");
  1355. }
  1356. }
  1357. if (list.Count > 0)
  1358. {
  1359. List<WorkOrderNewInput> Input = modeltooip(list,ua );
  1360. if (Input != null)
  1361. {
  1362. var obj = new
  1363. {
  1364. state = "success",
  1365. message = "成功",
  1366. rows = Input,
  1367. FileUrl,
  1368. total = itemlasts,
  1369. };
  1370. return Content(obj.ToJson());
  1371. }
  1372. else
  1373. {
  1374. return Error("没有查询到此工单");
  1375. }
  1376. }
  1377. else
  1378. return Error("没有查询到此工单");
  1379. }
  1380. else
  1381. {
  1382. return Error("无操作权限!");
  1383. }
  1384. }
  1385. public string GetID(string str,long id)
  1386. {
  1387. if (str != "")
  1388. {
  1389. str += "," + id;
  1390. }
  1391. else
  1392. {
  1393. str += id;
  1394. }
  1395. return str;
  1396. }
  1397. public string GetDeptment(Model.T_Sys_UserAccount ua)
  1398. {
  1399. string detpid = string.Empty;
  1400. Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
  1401. var deparmentlist = new List<Model.T_Sys_Department>();
  1402. if (dModel != null)
  1403. {
  1404. if (dModel.F_Layer == 1)
  1405. {
  1406. deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
  1407. if (deparmentlist.Count > 0)
  1408. {
  1409. foreach (var it in deparmentlist)
  1410. {
  1411. if (detpid != "")
  1412. {
  1413. detpid += "," + it.F_DeptId;
  1414. }
  1415. else
  1416. {
  1417. detpid = "" + it.F_DeptId;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. else
  1423. {
  1424. detpid = ua.F_DeptId.ToString();
  1425. }
  1426. }
  1427. return detpid;
  1428. }
  1429. /// <summary>
  1430. /// 获取待审批的工单
  1431. /// </summary>
  1432. /// <param name="user"></param>
  1433. /// <returns></returns>
  1434. public string GetApprovalOrderID(Model.T_Sys_UserAccount ua, string OpenId,string F_RoleCode)
  1435. {
  1436. string str = string.Empty;
  1437. #region 查询自己名下未审批的工单列表
  1438. var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_OptType in(" + (int)EnumItemOpt.audit + ")"+ " and "
  1439. + "F_WoState in(" + (int)EnumWorkOrderState.audit + ") and F_NextUser='" + ua.F_UserCode + "' "
  1440. + "" + " ");
  1441. foreach (var it in itemlast)
  1442. {
  1443. float hours= (DateTime .Now - DateTime.Parse (it.F_CreateTime.ToString ())).Hours;
  1444. if (F_RoleCode == "DQJL")
  1445. {
  1446. if (hours>=24)
  1447. {
  1448. GetDaQucirCulation("",ua, it.F_CreateTime.ToString (), it.F_WoID,false );
  1449. }
  1450. else
  1451. {
  1452. str = GetID(str, it.F_WoID);
  1453. }
  1454. }
  1455. else
  1456. {
  1457. var user = GetUser(OpenId);
  1458. string deptname = "";
  1459. string deptmodelsname = "";
  1460. var deptmodel = departmentBLL.GetModel(user.F_DeptId);
  1461. var deptmodels = departmentBLL.GetModel(ua.F_DeptId);
  1462. if (deptmodel != null)
  1463. {
  1464. deptname = deptmodel.F_DeptName + "-";
  1465. }
  1466. if (deptmodels != null)
  1467. {
  1468. deptmodelsname = deptmodels.F_DeptName + "-";
  1469. }
  1470. if (hours >= 24)
  1471. {
  1472. DateTime time = DateTime.Parse(it.F_CreateTime.ToString()).AddHours(24);
  1473. Model.T_Wo_WorkOrder model = woBLL.GetModel(it.F_WoID);
  1474. 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, 0, 0);
  1475. 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, 0, 0);
  1476. }
  1477. else if (hours >= 48)
  1478. {
  1479. GetDaQucirCulation("",user, it.F_CreateTime.ToString(), it.F_WoID,false );
  1480. }
  1481. else
  1482. {
  1483. str = GetID(str, it.F_WoID);
  1484. }
  1485. }
  1486. }
  1487. #endregion
  1488. if (F_RoleCode == "DQJL")
  1489. {
  1490. if (!string .IsNullOrEmpty (GetDeptment(ua)))
  1491. {
  1492. var itemlasts = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_OptType in(" + (int)EnumItemOpt.audit+ ")" + " and "
  1493. + "F_WoState in(" + (int)EnumWorkOrderState.audit + ") and F_NextUser in ( " + GetDeptment(ua) + ") ");
  1494. foreach (var it in itemlasts)
  1495. {
  1496. float hours = (DateTime.Now - DateTime.Parse(it.F_CreateTime.ToString())).Hours;
  1497. if (F_RoleCode == "DQJL")
  1498. {
  1499. if (hours >= 24)
  1500. {
  1501. Model.T_Sys_UserAccount user = userAccountBLL.GetModel(it.F_CreateUser);
  1502. DateTime time = DateTime.Parse(it.F_CreateTime.ToString()).AddHours(24);
  1503. Model.T_Wo_WorkOrder model = woBLL.GetModel(it.F_WoID);
  1504. string deptname = "";
  1505. string deptmodelsname = "";
  1506. var deptmodel = departmentBLL.GetModel(user.F_DeptId);
  1507. var deptmodels = departmentBLL.GetModel(ua.F_DeptId);
  1508. if (deptmodel != null)
  1509. {
  1510. deptname = deptmodel.F_DeptName + "-";
  1511. }
  1512. if (deptmodels != null)
  1513. {
  1514. deptmodelsname = deptmodels.F_DeptName + "-";
  1515. }
  1516. 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, 0, 0);
  1517. 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, 0, 0);
  1518. if (hours < 48)
  1519. {
  1520. str = GetID(str, it.F_WoID);
  1521. }
  1522. else
  1523. {
  1524. GetDaQucirCulation("",ua, time.ToString(), it.F_WoID,false );
  1525. }
  1526. }
  1527. }
  1528. }
  1529. }
  1530. }
  1531. return str;
  1532. }
  1533. /// <summary>
  1534. /// 获取已审批的工单列表
  1535. /// </summary>
  1536. /// <param name="user"></param>
  1537. /// <returns></returns>
  1538. public string GetApprovedOrderID( string user)
  1539. {
  1540. string str = string.Empty;
  1541. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType=" + (int)EnumItemOpt.reaudit
  1542. + " and F_CreateUser=" + user + " "//
  1543. ;
  1544. return str;
  1545. }
  1546. /// <summary>
  1547. /// 获取已审批的工单列表
  1548. /// </summary>
  1549. /// <param name="user"></param>
  1550. /// <returns></returns>
  1551. public string GetApprovedOrderID()
  1552. {
  1553. string str = string.Empty;
  1554. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_OptType=" + (int)EnumItemOpt.reaudit
  1555. //
  1556. ;
  1557. return str;
  1558. }
  1559. /// <summary>
  1560. /// 根据model返回CustomerBaseNewInput对象
  1561. /// </summary>
  1562. private List<WorkOrderNewInput> modeltooip(List<Model.T_Wo_WorkOrder> model1,Model .T_Sys_UserAccount ua)
  1563. {
  1564. if (model1 != null && model1.Count > 0)
  1565. {
  1566. List<WorkOrderNewInput> Input = new List<WorkOrderNewInput>(model1.Count);
  1567. for (int i = 0; i < model1.Count; i++)
  1568. {
  1569. WorkOrderNewInput model = new WorkOrderNewInput();
  1570. if (!string.IsNullOrEmpty(model1[i].F_CustomerID))
  1571. {
  1572. // var sql = "and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'";
  1573. //var userModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 " + sql);
  1574. Model.T_Cus_CustomerBaseNew cuModel = customerBaseBLL .GetModel(model1[i].F_CustomerID.ToString());//通过客户编号获取客户资料
  1575. if (cuModel != null)
  1576. {
  1577. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  1578. {
  1579. Model.T_Sys_Department pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  1580. if (pdModel != null)
  1581. {
  1582. model.F_AreaName = pdModel.F_DeptName;
  1583. }
  1584. }
  1585. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  1586. {
  1587. Model.T_Sys_Department pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));
  1588. if (pdModel1 != null)
  1589. {
  1590. model.F_BranchName = pdModel1.F_DeptName;
  1591. }
  1592. }
  1593. model.F_CompanyName = cuModel.F_CompanyName;//公司名称
  1594. model.F_CustomerID = cuModel.F_CustomerCode;//客户编码
  1595. model.F_Salesman = cuModel.F_Salesman;
  1596. model.F_SalesPhone = cuModel.F_SalesPhone;
  1597. model.F_Legal = cuModel.F_Legal;
  1598. model.F_LegalPhone = cuModel.F_LegalPhone;
  1599. model.F_AddressProvince = cuModel.F_AddressProvince;
  1600. model.F_AddressCity = cuModel.F_AddressCity;
  1601. model.F_AddressCountry = cuModel.F_AddressCountry;
  1602. model.F_AddressTownship = cuModel.F_AddressTownship;
  1603. model.F_AddressFull = cuModel.F_AddressFull;
  1604. model.F_Brands = cuModel.F_Brands;
  1605. model.F_Channel = cuModel.F_Channel;
  1606. model.F_IsRunXLX = cuModel.F_IsRunXLX;
  1607. model.F_AnnualSales = cuModel.F_AnnualSales;
  1608. model.F_Formula = cuModel.F_Formula;
  1609. model.F_RaiseCrops = cuModel.F_RaiseCrops;
  1610. model.F_PlantingArea = cuModel.F_PlantingArea;
  1611. model.F_FertilizerBrand = cuModel.F_FertilizerBrand;
  1612. }
  1613. }
  1614. if (valcode(model1[i].F_MaterialID.ToString(), 11))
  1615. {
  1616. model.F_MaterialID =model1[i].F_MaterialID;//验证物料编码为11位纯数字
  1617. Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(model1[i].F_MaterialID.ToString());//通过物料编码获取物料信息
  1618. if (maModel != null)
  1619. {
  1620. model.F_MaterialName = maModel.F_MaterialName;
  1621. model.F_Model = maModel.F_Model;
  1622. model.F_Specs = maModel.F_Specs;
  1623. model.F_Level1 = maModel.F_Level1;
  1624. model.F_Level2 = maModel.F_Level2;
  1625. model.F_Level3 = maModel.F_Level3;
  1626. model.F_Brand = maModel.F_Brand;
  1627. model.F_MaterialEffect = maModel.F_MaterialEffect;
  1628. model.F_Pipeline = maModel.F_Pipeline;
  1629. model.F_Craft = maModel.F_Craft;
  1630. }
  1631. }
  1632. #region 基本字段
  1633. model.F_ID = model1[i].F_ID;//
  1634. model.F_WorkOrderCode = model1[i].F_WorkOrderCode;//工单编号
  1635. #region
  1636. if (!string .IsNullOrEmpty (model1[i].F_Source))
  1637. {
  1638. model.F_Source = int.Parse(model1[i].F_Source);//工单来源
  1639. }
  1640. if (model1[i].F_Source == "1")
  1641. {
  1642. model.F_SourceName = "电话";
  1643. }
  1644. else if (model1[i].F_Source == "2")
  1645. {
  1646. model.F_SourceName = "微信业务员";
  1647. }
  1648. else if (model1[i].F_Source == "3")
  1649. {
  1650. model.F_SourceName = "微信客户";
  1651. }
  1652. else
  1653. {
  1654. model.F_SourceName = "官网";
  1655. }
  1656. model.F_Type = int.Parse(model1[i].F_Type);//工单来源
  1657. if (model1[i].F_Type == "1")
  1658. {
  1659. model.F_TypeName = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1660. }
  1661. else if (model1[i].F_Type == "2")
  1662. {
  1663. model.F_TypeName = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1664. }
  1665. else if (model1[i].F_Type == "3")
  1666. {
  1667. model.F_TypeName = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1668. }
  1669. else
  1670. {
  1671. model.F_TypeName = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1672. }
  1673. model.F_State = model1[i].F_State;
  1674. if (model1[i].F_State == 0)//工单状态
  1675. {
  1676. model.F_StateName = "待指派";
  1677. }
  1678. else if (model1[i].F_State == 1)
  1679. {
  1680. model.F_StateName = "待接单";
  1681. }
  1682. else if (model1[i].F_State == 2)
  1683. {
  1684. model.F_StateName = "待处理";
  1685. }
  1686. else if (model1[i].F_State == 3)
  1687. {
  1688. model.F_StateName = "已退回";
  1689. }
  1690. else if (model1[i].F_State == 4)
  1691. {
  1692. model.F_StateName = "异常退回";
  1693. }
  1694. else if (model1[i].F_State == 5)
  1695. {
  1696. model.F_StateName = "处理中";
  1697. }
  1698. else if (model1[i].F_State == 6)
  1699. {
  1700. model.F_StateName = "待回访";
  1701. }
  1702. else if (model1[i].F_State == 7)
  1703. {
  1704. model.F_StateName = "待完结";
  1705. }
  1706. else if (model1[i].F_State == 10)
  1707. {
  1708. model.F_StateName = "已处理";
  1709. }
  1710. else if (model1[i].F_State == 11)
  1711. {
  1712. model.F_StateName = "已评价";
  1713. }
  1714. else if (model1[i].F_State == 12)
  1715. {
  1716. model.F_StateName = "已退回";
  1717. }
  1718. else if (model1[i].F_State == 14)
  1719. {
  1720. model.F_StateName = "待办理";
  1721. }
  1722. else if (model1[i].F_State == 15)
  1723. {
  1724. model.F_StateName = "微信未通过";
  1725. }
  1726. else if (model1[i].F_State == 16)
  1727. {
  1728. model.F_StateName = "待办理";
  1729. }
  1730. #endregion
  1731. model.F_CusName = model1[i].F_CusName;//客户姓名
  1732. model.F_CusPhone = model1[i].F_CusPhone;//客户电话
  1733. model.F_Canal = model1[i].F_Canal;//
  1734. model.F_IncidentProvince = model1[i].F_IncidentProvince;//事发地-省
  1735. model.F_IncidentCity = model1[i].F_IncidentCity;//事发地-市
  1736. model.F_IncidentCountry = model1[i].F_IncidentCountry;//事发地-县
  1737. model.F_IncidentTownship = model1[i].F_IncidentTownship;//事发地-乡
  1738. model.F_IncidentDetailed = model1[i].F_IncidentDetailed;//事发地-详细
  1739. model.F_SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  1740. model.F_Description = model1[i].F_Description;//问题描述
  1741. model.F_Files = "0";//附件上传ids
  1742. model.F_DealType = model1[i].F_DealType;//处理方式:当即办理、电话转接、网络转办(点选)
  1743. #endregion
  1744. if (!string.IsNullOrEmpty(model1[i].F_QuestionType))
  1745. {
  1746. try
  1747. {
  1748. int b = int.Parse(model1[i].F_QuestionType.Trim());
  1749. Model.T_Wo_QuestionManage manage = quesBLL.GetModel(b);
  1750. if (manage != null)
  1751. {
  1752. model.F_QuestionType = manage.F_QuestionName;
  1753. if (manage.F_Label == "3")
  1754. {
  1755. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(manage.F_ParentId.ToString()));//获取问题类别
  1756. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  1757. model.F_QuestionTypeone = Manage2.F_QuestionName;//问题类别1
  1758. model.F_QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
  1759. }
  1760. }
  1761. }
  1762. catch (Exception)
  1763. {
  1764. model.F_QuestionType = model1[i].F_QuestionType; //问题类别(投诉抽捡和咨询类别不一样)
  1765. }
  1766. }
  1767. #region 投诉类
  1768. model.F_BatchNumber = model1[i].F_BatchNumber;//生产批次号
  1769. model.F_TS_Formula = model1[i].F_TS_Formula;// 投诉-配方
  1770. model.F_TS_Category = model1[i].F_TS_Category;//投诉-产品种类:化肥、化工、其他
  1771. model.F_TS_Quantity = model1[i].F_TS_Quantity;//投诉-问题数量(吨)
  1772. model.F_TS_Level = model1[i].F_TS_Level;//投诉-重要级别:轻微、一般、较大、重大
  1773. #endregion
  1774. #region 咨询类
  1775. // model.F_ZX_ProName = model1[i].F_ZX_ProName;//咨询-产品名称:三聚氰胺、甲醇、液氨、二甲醚、糠醇、其他
  1776. model.F_ZX_Quantity = model1[i].F_ZX_Quantity;// 咨询-问题数量(吨)
  1777. model.F_ZX_Area = model1[i].F_ZX_Area;// 咨询-大区
  1778. model.F_ZX_Branch = model1[i].F_ZX_Branch;// 咨询-分公司
  1779. #endregion
  1780. #region 抽检类
  1781. model.F_CJ_Time = model1[i].F_CJ_Time;// 抽检-抽检时间
  1782. model.F_CJ_Level = model1[i].F_CJ_Level;// 抽检-抽检级别:乡镇级、县级、市级、省级及以上、个人送检
  1783. model.F_CJ_Unit = model1[i].F_CJ_Unit;// 抽检-抽检单位:市场监督、农业部、土肥站、工商、联合执法、其他
  1784. model.F_CJ_TestUnit = model1[i].F_CJ_TestUnit;//抽检-化验单位
  1785. model.F_CJ_Tonnage = model1[i].F_CJ_Tonnage;//抽检-抽检吨数
  1786. model.F_CJ_BagNo = model1[i].F_CJ_BagNo;//抽检-抽检袋数
  1787. model.F_CJ_Outlay = model1[i].F_CJ_Outlay;//抽检-公关费用金额:单位元
  1788. model.F_WorkerBrand = model1[i].F_Brand;//工单品牌
  1789. model.F_DealBy = model1[i].F_DealBy;//处理人
  1790. model.F_DealTime = model1[i].F_DealTime;//处理时间
  1791. model.F_DealContent = model1[i].F_DealContent;//处理内容
  1792. model.F_DealResult = model1[i].F_DealResult;//处理结果
  1793. model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
  1794. model.F_SC_ProductBase = model1[i].F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
  1795. model.F_SC_PreliminaryOpinion = model1[i].F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
  1796. model.F_SC_QualityMonth = model1[i].F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
  1797. model.F_SC_CJ_SpotResult = model1[i].F_SC_CJ_SpotResult;/// 市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
  1798. model.F_SC_CJ_SelfResult = model1[i].F_SC_CJ_SelfResult;//市场管理科-抽检-自检结果
  1799. model.F_SC_CJ_ApprovalNo = model1[i].F_SC_CJ_ApprovalNo;// 市场管理科-抽检-对应审批工作流单号
  1800. model.F_SC_CJ_ReturnAccount = model1[i].F_SC_CJ_ReturnAccount;//市场管理科-抽检-确认返账金额(元)
  1801. model.F_ZL_QualityEventLevel = model1[i].F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
  1802. model.F_ZL_ClaimAmount = model1[i].F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
  1803. model.F_ZL_ResponsibleUnit = model1[i].F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
  1804. model.F_ZL_ApprovalOpinions = model1[i].F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  1805. model.F_ZL_ApprovalDisagree = model1[i].F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
  1806. model.F_ZL_CompensationMethod = model1[i].F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  1807. model.F_ZL_CompensationMoney = model1[i].F_ZL_CompensationMoney;// 质量管理科-补偿钱款
  1808. model.F_ZL_CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  1809. model.F_ZL_Fquantity = model1[i].F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
  1810. model.F_ZL_ImprovementRequirements = model1[i].F_ZL_ImprovementRequirements;//质量管理科-改进要求
  1811. model.F_ZL_CApprovalNo = model1[i].F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
  1812. model.F_ZL_CJ_IsRecord = model1[i].F_ZL_CJ_IsRecord;//质量管理科-抽检-未备案、已备案
  1813. model.F_VisitRemarks = model1[i].F_VisitRemarks;//回访备注
  1814. model.SuperiorOpinion = AssCont(model1[i].F_ID);//上级处理意见
  1815. if (model1[i].F_SMSReply == 1)
  1816. {
  1817. model.F_SMSReply = "满意";//短信回访结果
  1818. }
  1819. else if (model1[i].F_SMSReply == 2)
  1820. {
  1821. model.F_SMSReply = "一般";//短信回访结果
  1822. }
  1823. else if (model1[i].F_SMSReply == 3)
  1824. {
  1825. model.F_SMSReply = "不满意";//短信回访结果
  1826. }
  1827. else
  1828. {
  1829. model.F_SMSReply = "";//短信回访结果
  1830. }
  1831. if (model1[i].F_IsVisit!=0)
  1832. {
  1833. model.F_IsVisit = "是";//是否回访
  1834. }
  1835. else
  1836. {
  1837. model.F_IsVisit = "否";//是否回访
  1838. }
  1839. model.F_IsAudit = model1[i].F_IsAudit;//是否审核
  1840. model.F_Highopinions = model1[i].F_Highopinions ;//高层处理意见
  1841. model.F_CreateOn = model1[i].F_CreateOn; ;//添加时间
  1842. // model.F_CreateBy = model1[i].F_CreateBy; ;//添加人
  1843. if (!string.IsNullOrEmpty(model1[i].F_CreateBy))
  1844. {
  1845. Model.T_Sys_UserAccount creatname = userAccountBLL .GetModel(model1[i].F_CreateBy);
  1846. if (creatname != null)
  1847. {
  1848. model.F_CreateBy = creatname.F_WorkNumber; ;//添加人
  1849. model.F_CreateName = creatname.F_UserName; ;//添加人
  1850. model.CreateName = creatname.F_UserName + "(" + creatname.F_WorkNumber + ")";
  1851. }
  1852. }
  1853. model.F_UpdateBy = model1[i].F_UpdateBy;//修改人工号
  1854. model.F_UpdateOn = model1[i].F_UpdateOn; ;//修改人工号
  1855. if (model1[i].F_IsAudit!=0 && model1[i].F_IsAudit != null)
  1856. {
  1857. if (model1[i].F_AuditState == 0)
  1858. {
  1859. model.F_AuditState = "同意上报";
  1860. }
  1861. else if (model1[i].F_AuditState == 1)
  1862. {
  1863. model.F_AuditState = "驳回修订";
  1864. }
  1865. else
  1866. {
  1867. model.F_AuditState = "强制结案";
  1868. }
  1869. }
  1870. else
  1871. {
  1872. model.F_AuditState = "";
  1873. }
  1874. model.F_AuditBy = model1[i].F_AuditBy;//审核人
  1875. model.F_AuditOn = model1[i].F_AuditOn;//审核时间
  1876. model.F_AuditCont = model1[i].F_AuditCont;//审核内容
  1877. model.RemainingTime = TimeToOver(model1[i].F_ID, model1[i].F_limit );
  1878. if (ua != null)
  1879. {
  1880. var itemlast = itembll.GetModelList(" F_WoID='" + model.F_ID + "' order by F_CreateTime desc").FirstOrDefault();
  1881. if (itemlast != null)
  1882. model.F_UserCode = itemlast.F_CreateUser;
  1883. if (!string.IsNullOrEmpty(model.F_UserCode))
  1884. {
  1885. Model.T_Sys_UserAccount user = userAccountBLL.GetModel(model.F_UserCode);
  1886. model.F_UserName = user.F_UserName;
  1887. Model.T_Sys_Department dept = departmentBLL.GetModel(user.F_DeptId);
  1888. if (dept!=null )
  1889. {
  1890. model.F_NextDeptName = dept.F_DeptName ;
  1891. }
  1892. }
  1893. }
  1894. if (TimeToOver(model1[i].F_ID, model1[i].F_limit ) < 0)
  1895. {
  1896. model.F_IsOver = 1;
  1897. }
  1898. else
  1899. {
  1900. model.F_IsOver = model1[i].F_IsOver;
  1901. }
  1902. if (ua !=null )
  1903. {
  1904. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  1905. if (deptmodel != null)
  1906. {
  1907. model.F_Deptid = deptmodel.F_DeptId;
  1908. model.F_DeptName = deptmodel.F_DeptName;
  1909. }
  1910. }
  1911. #endregion
  1912. Input.Add(model);
  1913. }
  1914. return Input;
  1915. }
  1916. else
  1917. {
  1918. return null;
  1919. }
  1920. }
  1921. /// <summary>
  1922. /// 是否超时
  1923. /// </summary>
  1924. /// <param name="id"></param>
  1925. /// <returns></returns>
  1926. private float TimeToOver(int id,int limit)
  1927. {
  1928. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + "order by F_ID desc ");
  1929. string time1 = "", time2 = ""; int x = 0, y = 0;
  1930. if (itemlasts.Count > 0)
  1931. {
  1932. for (int i = 0; i < itemlasts.Count; i++)
  1933. {
  1934. if (itemlasts[i].F_WoState >= 1)
  1935. {
  1936. if (itemlasts[i].F_WoState == 1)
  1937. {
  1938. x = i;
  1939. time1 = itemlasts[i].F_CreateTime.ToString();
  1940. }
  1941. if (itemlasts[i].F_WoState == 10)
  1942. {
  1943. y = i;
  1944. time2 = itemlasts[i].F_CreateTime.ToString();
  1945. }
  1946. }
  1947. }
  1948. if (time2 != "")
  1949. {
  1950. if (time1 != "")
  1951. {
  1952. if (x > y)
  1953. {
  1954. float a = (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours;
  1955. float b = limit - a;
  1956. return b;
  1957. }
  1958. else
  1959. {
  1960. float a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  1961. float b = limit - a;
  1962. return b;
  1963. }
  1964. }
  1965. else
  1966. {
  1967. return 0;
  1968. }
  1969. }
  1970. else if (time1 != "")
  1971. {
  1972. float a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  1973. float b = limit - a;
  1974. return b;
  1975. }
  1976. else
  1977. {
  1978. return 0;
  1979. }
  1980. }
  1981. else
  1982. {
  1983. return 0;
  1984. }
  1985. }
  1986. private string AssCont(int id)
  1987. {
  1988. string cont = "";
  1989. var itemlist = itembll.GetModelList("F_WoID=" + id + "and F_IsUsed=0" + "order by F_ID desc");
  1990. if (itemlist.Count > 0)
  1991. {
  1992. cont = itemlist[0].F_OptContent;
  1993. }
  1994. return cont;
  1995. }
  1996. /// <summary>
  1997. /// 获取当前用户上一级的用户
  1998. /// </summary>
  1999. /// <param name="OpenId"></param>
  2000. /// <returns></returns>
  2001. public Model.T_Sys_UserAccount GetUser(string OpenId)
  2002. {
  2003. if (!string.IsNullOrEmpty(OpenId))
  2004. {
  2005. // int userId = CurrentUser.UserData.F_UserId;
  2006. // Model.T_Sys_UserAccount ua = userAccountBLL.GetModel(userId);
  2007. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  2008. if (ua !=null )
  2009. {
  2010. Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
  2011. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  2012. // var dept = departmentBLL.GetModel(deptmodel.F_ParentId);
  2013. #region 业务员
  2014. if (ro.F_RoleCode == "YWY")
  2015. {
  2016. if (deptmodel != null)
  2017. {
  2018. if (deptmodel.F_Layer == 2)
  2019. {
  2020. Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + deptmodel.F_DeptId + " and F_RoleId=60 ").FirstOrDefault();
  2021. return userModel;
  2022. }
  2023. if (deptmodel.F_Layer == 1)
  2024. {
  2025. Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + deptmodel.F_DeptId + " and F_RoleId=62 ").FirstOrDefault();
  2026. return userModel;
  2027. }
  2028. }
  2029. else
  2030. {
  2031. return null;
  2032. }
  2033. }
  2034. #endregion
  2035. #region 大区经理
  2036. else if (ro.F_RoleCode == "DQJL")
  2037. {
  2038. return null;
  2039. }
  2040. #endregion
  2041. #region 分公司经理
  2042. else if (ro.F_RoleCode == "FGSJL")
  2043. {
  2044. if (deptmodel != null)
  2045. {
  2046. var dept = departmentBLL.GetModel(deptmodel.F_ParentId);
  2047. if (dept != null)
  2048. {
  2049. Model.T_Sys_UserAccount userModel = userAccountBLL.GetModelList(" F_DeptId=" + dept.F_DeptId + " and F_RoleId=62 ").FirstOrDefault();
  2050. return userModel;
  2051. }
  2052. else
  2053. {
  2054. return null;
  2055. }
  2056. }
  2057. else
  2058. {
  2059. return null;
  2060. }
  2061. }
  2062. #endregion
  2063. }
  2064. return null;
  2065. }
  2066. else
  2067. {
  2068. return null;
  2069. }
  2070. }
  2071. /// <summary>
  2072. /// 获取上一级管理员
  2073. /// </summary>
  2074. /// <param name="OpenId"></param>
  2075. /// <returns></returns>
  2076. [WechatActionFilter]
  2077. public ActionResult GetDpment(string OpenId)
  2078. {
  2079. if (!string.IsNullOrEmpty(OpenId))
  2080. {
  2081. if (GetUser(OpenId)!=null )
  2082. {
  2083. return Success("获取成功!", GetUser(OpenId));
  2084. }
  2085. else
  2086. {
  2087. return Success("获取失败!",null );
  2088. }
  2089. }
  2090. else
  2091. {
  2092. return Error("OpenId不能为空!");
  2093. }
  2094. }
  2095. /// <summary>
  2096. /// 修改密码
  2097. /// </summary>
  2098. /// <returns></returns>
  2099. [WechatActionFilter]
  2100. public ActionResult UpdatePassWord()
  2101. {
  2102. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  2103. //5--业主(客户档案会员)
  2104. int usertype = RequestString.GetInt("usertype", 0);
  2105. //原密码
  2106. string oldpwd = RequestString.GetFormString("oldpwd").Trim();
  2107. string pwd = RequestString.GetFormString("pwd").Trim();
  2108. string repeatpwd = RequestString.GetFormString("repeatpwd").Trim();
  2109. if (usertype == 0)
  2110. return Error("无权修改密码");
  2111. if (string.IsNullOrWhiteSpace(oldpwd))
  2112. return Error("请输入原密码");
  2113. if (string.IsNullOrWhiteSpace(pwd))
  2114. return Error("请输入新密码");
  2115. if (string.IsNullOrWhiteSpace(repeatpwd))
  2116. return Error("请再次输入新密码");
  2117. if (!pwd.Equals(repeatpwd))
  2118. return Error("两个新密码不同,请重新输入");
  2119. var model = new Model.T_Sys_UserAccount();
  2120. var modelCus = new Model.T_Cus_CustomerBaseNew();
  2121. //坐席表
  2122. if (usertype < 5)
  2123. {
  2124. model = userAccountBLL.GetModelByOpenid(stropenid);
  2125. if (model != null)
  2126. {
  2127. if (!model.F_Password.Equals(oldpwd)) return Error("原密码不正确");
  2128. model.F_Password = pwd;
  2129. if (userAccountBLL.Update(model))
  2130. return Success("重置密码成功");
  2131. }
  2132. return Error("重置密码失败");
  2133. }
  2134. //客户档案表
  2135. modelCus = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();//customerBaseBLL.GetModelByOpenid(stropenid);
  2136. if (modelCus != null)
  2137. {
  2138. if (!modelCus.F_WxPassword.Equals(oldpwd)) return Error("原密码不正确");
  2139. modelCus.F_WxPassword = pwd;
  2140. if (customerBaseBLL.Update(modelCus))
  2141. return Success("重置密码成功");
  2142. }
  2143. return Error("重置密码失败");
  2144. }
  2145. /// <summary>
  2146. /// 验证生产批次号为15位
  2147. /// </summary>
  2148. private bool vaBatchNumber(string code)
  2149. {
  2150. var res = false;
  2151. if (code.Length == 15)
  2152. {
  2153. char chr = code[12];
  2154. if (chr > 'A' && chr < 'Z')
  2155. {
  2156. string code1 = code.Substring(0, 12);
  2157. string code2 = code.Substring(15 - 2, 2);
  2158. if (Regex.IsMatch(code1, @"^\d{12}$") && Regex.IsMatch(code2, @"^\d{2}$"))
  2159. res = true;
  2160. }
  2161. else
  2162. {
  2163. res = false;
  2164. }
  2165. }
  2166. return res;
  2167. }
  2168. /// <summary>
  2169. /// 验证物料编码为10位纯数字
  2170. /// </summary>
  2171. private bool valcode(string code, int number)
  2172. {
  2173. var res = false;
  2174. //11位数字
  2175. if (code.Length == number && Regex.IsMatch(code, @"^\d{" + number + "}$"))
  2176. res = true;
  2177. return res;
  2178. }
  2179. /// <summary>
  2180. /// 验证物料编号是否唯一
  2181. /// </summary>
  2182. private bool gematerque(int id, string code)
  2183. {
  2184. var sql = " F_IsDelete=0 ";
  2185. sql += "and (F_MaterialCode='" + code + "')";
  2186. if (id > 0)
  2187. sql += " and F_Id<>" + id;
  2188. var count = mmBLL.GetModelList(sql).Count();
  2189. return count > 0;
  2190. }
  2191. /// <summary>
  2192. /// 验证客户编号是否唯一
  2193. /// </summary>
  2194. private bool getunique(int id, string code)
  2195. {
  2196. var sql = " F_IsDelete=0 ";
  2197. sql += "and (F_CustomerCode='" + code + "')";
  2198. if (id > 0)
  2199. sql += " and F_CustomerId<>" + id;
  2200. var count = customerBaseBLL .GetModelList(sql).Count();
  2201. return count > 0;
  2202. }
  2203. /// <summary>
  2204. /// 获取我参与的工单编号
  2205. /// </summary>
  2206. /// <param name="user"></param>
  2207. /// <returns></returns>
  2208. public string GetParticipateID(string user)
  2209. {
  2210. string str = string.Empty;
  2211. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") and F_OptType in( 1,7 )";
  2212. ;
  2213. return str;
  2214. }
  2215. /// <summary>
  2216. /// 添加客户
  2217. /// </summary>
  2218. private Model.T_Cus_CustomerBaseNew inputtooCustomer(Model.T_Cus_CustomerBaseNew model, WorkOrderNewInput input)
  2219. {
  2220. var newmodel = model;
  2221. if (!string.IsNullOrWhiteSpace(input.F_CustomerID.ToString()))
  2222. model.F_CustomerCode = input.F_CustomerID.ToString();
  2223. else
  2224. model.F_CustomerCode = model.F_CustomerCode;
  2225. if (!string.IsNullOrWhiteSpace(input.F_CompanyName))
  2226. model.F_CompanyName = input.F_CompanyName;
  2227. #region 基本字段
  2228. Model.T_Sys_Department dept = departmentBLL.GetModel(input.F_AreaName);
  2229. if (dept != null)
  2230. {
  2231. model.F_AreaID = dept.F_DeptId.ToString();//大区ID
  2232. }
  2233. Model.T_Sys_Department deptBranch = departmentBLL.GetModel(input.F_BranchName);
  2234. if (dept != null)
  2235. {
  2236. model.F_BranchID = deptBranch.F_DeptId.ToString();//大区ID
  2237. }
  2238. model.F_Salesman = input.F_Salesman;//业务员
  2239. model.F_SalesPhone = input.F_SalesPhone;//业务员电话
  2240. model.F_Channel = input.F_Channel;// 渠道类型:总经销、二级商、种田大户、农户、化工客户、公司员工
  2241. model.F_Legal = input.F_Legal;//法人
  2242. model.F_LegalPhone = input.F_LegalPhone;//法人电话
  2243. model.F_AddressProvince = input.F_AddressProvince;//省
  2244. model.F_AddressCity = input.F_AddressCity;//市
  2245. model.F_AddressCountry = input.F_AddressCountry;//县
  2246. model.F_AddressTownship = input.F_AddressTownship;//乡
  2247. model.F_AddressFull = input.F_AddressFull;//详细地址
  2248. model.F_Brands = input.F_Brands;// 经营品牌:心连心、手拉手、沃利沃、双心、空
  2249. model.F_IsRunXLX = input.F_IsRunXLX;// 是否经营心连心:是、否
  2250. model.F_AnnualSales = input.F_AnnualSales;//年销量
  2251. model.F_Formula = input.F_Formula;//配方
  2252. model.F_RaiseCrops = input.F_RaiseCrops;//种植作物
  2253. model.F_PlantingArea = input.F_PlantingArea;//种植面积
  2254. model.F_FertilizerBrand = input.F_FertilizerBrand;//用肥品牌
  2255. model.F_FileId = 0;
  2256. #endregion
  2257. return model;
  2258. }
  2259. private string GetCusCode(int i)
  2260. {
  2261. DateTime times = DateTime.Now.AddMinutes(i);
  2262. string time = times.ToString("yyMMddhhmm");
  2263. return time;
  2264. }
  2265. private string GetIntCode()
  2266. {
  2267. string time = DateTime.Now.ToString("hhmmss");
  2268. Random ran = new Random();
  2269. int RandKey = ran.Next(1000, 9999);
  2270. string timecode = 3 + "" + RandKey + "" + time;
  2271. return timecode;
  2272. }
  2273. private bool IsMaterial(WorkOrderNewInput input)
  2274. {
  2275. bool n = false;
  2276. if (!string.IsNullOrEmpty(input.F_MaterialID) || !string.IsNullOrEmpty(input.F_MaterialName)
  2277. || !string.IsNullOrEmpty(input.F_Model) || !string.IsNullOrEmpty(input.F_Specs)
  2278. || !string.IsNullOrEmpty(input.F_Level1) || !string.IsNullOrEmpty(input.F_Level2)
  2279. || !string.IsNullOrEmpty(input.F_Level3) || !string.IsNullOrEmpty(input.F_Brand)
  2280. || !string.IsNullOrEmpty(input.F_MaterialEffect) || !string.IsNullOrEmpty(input.F_Craft)
  2281. || !string.IsNullOrEmpty(input.F_Pipeline))
  2282. {
  2283. n = true;
  2284. }
  2285. return n;
  2286. }
  2287. private void AddMait(WorkOrderNewInput input, string usercode)
  2288. {
  2289. Model.T_Wo_MaterialManage dModel = new Model.T_Wo_MaterialManage();
  2290. dModel.F_MaterialCode = input.F_MaterialID.ToString();//物料编号
  2291. dModel.F_MaterialName = input.F_MaterialName;//物料名称
  2292. dModel.F_Model = input.F_Model;//型号
  2293. dModel.F_Specs = input.F_Specs;//规格
  2294. dModel.F_Level1 = input.F_Level1;//一级分类
  2295. dModel.F_Level2 = input.F_Level2;//二级分类
  2296. dModel.F_Level3 = input.F_Level3;//三级分类
  2297. dModel.F_Brand = input.F_Brand;//品牌
  2298. dModel.F_MaterialEffect = input.F_MaterialEffect;//复合肥肥效
  2299. dModel.F_Craft = input.F_Craft;//工艺
  2300. dModel.F_Pipeline = input.F_Pipeline;//产品线
  2301. dModel.F_IsDelete = 0;
  2302. dModel.F_CreateOn = DateTime.Now;
  2303. dModel.F_CreateBy = usercode;
  2304. int f = mmBLL.Add(dModel);
  2305. }
  2306. /// <summary>
  2307. /// 根据传入的对象和input的内容返回对象(添加修改使用)
  2308. /// </summary>
  2309. private Model.T_Wo_WorkOrder inputtoobj(Model.T_Sys_UserAccount ua ,Model.T_Wo_WorkOrder model, WorkOrderNewInput input, int type)
  2310. {
  2311. string usercode = "";
  2312. if (ua !=null )
  2313. {
  2314. usercode = ua.F_UserCode;
  2315. }
  2316. var newmodel = model;
  2317. if (input.F_ID != 0)
  2318. {
  2319. model.F_ID = input.F_ID;
  2320. }
  2321. else
  2322. {
  2323. model.F_ID = model.F_ID;//工单ID
  2324. }
  2325. if (type == 2)
  2326. {
  2327. model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
  2328. model.F_Source = model.F_Source;
  2329. }
  2330. else
  2331. {
  2332. model.F_WorkOrderCode = model.F_WorkOrderCode;//工单编号
  2333. model.F_Source = model.F_Source.ToString();//工单来源
  2334. }
  2335. if (type == 2)
  2336. {
  2337. if (input.F_Type == 2||input.F_Type == 3)
  2338. {
  2339. //if (string .IsNullOrEmpty(input.F_CustomerID) )
  2340. //{
  2341. // int i = 0;
  2342. // while (true)
  2343. // {
  2344. // if (!getunique(0, GetCusCode(i)))
  2345. // {
  2346. // input.F_CustomerID = GetCusCode(i);
  2347. // break;
  2348. // }
  2349. // else
  2350. // {
  2351. // i++;
  2352. // }
  2353. // }
  2354. // var Customer = new Model.T_Cus_CustomerBaseNew();
  2355. // #region 保存客户基本信息
  2356. // Customer = inputtooCustomer(Customer, input);
  2357. // Customer.F_CreateBy = usercode;
  2358. // Customer.F_CreateOn = DateTime.Now;
  2359. // Customer.F_IsDelete = 0;
  2360. // #endregion
  2361. // int b = customerBaseBLL.Add(Customer);
  2362. //}
  2363. if (IsMaterial(input))
  2364. {
  2365. if (string.IsNullOrEmpty(input.F_MaterialID))
  2366. {
  2367. while (true)
  2368. {
  2369. if (!gematerque(0, GetIntCode()))
  2370. {
  2371. input.F_MaterialID = GetIntCode();
  2372. AddMait(input, usercode);
  2373. break;
  2374. }
  2375. }
  2376. }
  2377. else
  2378. {
  2379. if (!gematerque(0, input.F_MaterialID))
  2380. {
  2381. AddMait(input, usercode);
  2382. }
  2383. }
  2384. }
  2385. }
  2386. }
  2387. #region 基本字段
  2388. model.F_Source = input.F_Source.ToString();//工单来源
  2389. model.F_WxOpenId = input.F_WxOpenId;
  2390. model.F_Type = input.F_Type.ToString();//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  2391. model.F_CusName = input.F_CusName;//客户姓名
  2392. model.F_CusPhone = input.F_CusPhone;//客户电话
  2393. model.F_CompanyName = input.F_CompanyName;//公司名称
  2394. model.F_IncidentProvince = input.F_IncidentProvince;//事发地-省
  2395. model.F_IncidentCity = input.F_IncidentCity;//事发地-市
  2396. model.F_IncidentCountry = input.F_IncidentCountry;//事发地-县
  2397. model.F_IncidentTownship = input.F_IncidentTownship;//事发地-乡
  2398. model.F_IncidentDetailed = input.F_IncidentDetailed;//事发地-详细
  2399. model.F_SalesBase = input.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  2400. model.F_Description = input.F_Description;//问题描述
  2401. model.F_ZX_Area = input.F_ZX_Area;// 大区
  2402. model.F_ZX_Branch = input.F_ZX_Branch;//分公司
  2403. model.F_Files =model .F_Files;//附件上传ids
  2404. model.F_Brand = input.F_WorkerBrand;//分公司
  2405. model.F_DealType = model.F_DealType;//处理方式:当即办理、电话转接、网络转办(点选)
  2406. model.F_Canal = input.F_Canal;//处理方式:当即办理、电话转接、网络转办(点选)
  2407. #endregion
  2408. model.F_QuestionType = input.F_QuestionType;//问题类别(投诉抽捡和咨询类别不一样)
  2409. model.F_CustomerID = input.F_CustomerID;//客户编号为10为纯数字
  2410. model.F_MaterialID = input.F_MaterialID;//物料编码为11为纯数字
  2411. #region 投诉类
  2412. model.F_BatchNumber = input.F_BatchNumber;//生产批次号
  2413. model.F_TS_Formula = input.F_TS_Formula;// 投诉-配方
  2414. model.F_TS_Category = input.F_TS_Category;//投诉-产品种类:化肥、化工、其他
  2415. model.F_TS_Quantity = input.F_TS_Quantity;//投诉-问题数量(吨)
  2416. model.F_TS_Level = input.F_TS_Level;//投诉-重要级别:轻微、一般、较大、重大
  2417. #endregion
  2418. #region 咨询类
  2419. // model.F_ZX_ProName = input.F_ZX_ProName;//咨询-产品名称:三聚氰胺、甲醇、液氨、二甲醚、糠醇、其他
  2420. model.F_ZX_Quantity = input.F_ZX_Quantity;// 咨询-问题数量(吨)
  2421. #endregion
  2422. #region 抽检类
  2423. model.F_CJ_Time = input.F_CJ_Time;// 抽检-抽检时间
  2424. model.F_CJ_Level = input.F_CJ_Level;// 抽检-抽检级别:乡镇级、县级、市级、省级及以上、个人送检
  2425. model.F_CJ_Unit = input.F_CJ_Unit;// 抽检-抽检单位:市场监督、农业部、土肥站、工商、联合执法、其他
  2426. model.F_CJ_TestUnit = input.F_CJ_TestUnit;//抽检-化验单位
  2427. model.F_CJ_Tonnage = input.F_CJ_Tonnage;//抽检-抽检吨数
  2428. model.F_CJ_BagNo = input.F_CJ_BagNo;//抽检-抽检袋数
  2429. model.F_CJ_Outlay = input.F_CJ_Outlay;//抽检-公关费用金额:单位元】
  2430. // model.F_VisitRemarks = input.F_VisitRemarks;//回访备注
  2431. if (!string.IsNullOrEmpty(input.F_BatchNumber))
  2432. {
  2433. if (type == 1)
  2434. {
  2435. model.F_SC_QualityMonth = new WorkOrderController().GetProTime(input.F_BatchNumber, DateTime.Parse(model.F_CreateOn.ToString())).ToString();
  2436. }
  2437. else
  2438. {
  2439. model.F_SC_QualityMonth = new WorkOrderController().GetProTime(input.F_BatchNumber, DateTime.Now).ToString();
  2440. }
  2441. }
  2442. if (type == 1)
  2443. {
  2444. model.F_State = model.F_State;//工单状态
  2445. model.F_CreateOn = model.F_CreateOn;//添加时间
  2446. model.F_CreateBy = model.F_CreateBy;//添加人
  2447. model.F_UpdateBy = usercode;//修改人工号
  2448. model.F_UpdateOn = DateTime.Now;//修改人工号
  2449. if (input.F_UpdateCount != null)
  2450. {
  2451. model.F_UpdateCount = model.F_UpdateCount + 1;//修改次数
  2452. }
  2453. else
  2454. {
  2455. model.F_UpdateCount = 1;//修改次数
  2456. }
  2457. model.F_limit = model.F_limit;
  2458. }
  2459. else
  2460. {
  2461. model.F_limit = 0;
  2462. model.F_State = (int)EnumWorkOrderState.neworder;
  2463. model.F_CreateBy = usercode;
  2464. model.F_CreateOn = DateTime.Now;
  2465. }
  2466. model.F_IsVisit = 1;
  2467. model.F_IsDelete = 0;
  2468. model.F_IsOver = 0;
  2469. #endregion
  2470. return model;
  2471. }
  2472. /// <summary>
  2473. /// 获取我参与的工单编号
  2474. /// </summary>
  2475. /// <param name="user"></param>
  2476. /// <returns></returns>
  2477. public string GetCYWorkOrderID(string user)
  2478. {
  2479. string str = string.Empty;
  2480. str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser in(" + user + ") and F_OptType in( 1,3,13 )";
  2481. return str;
  2482. }
  2483. /// <summary>
  2484. /// 获取高层
  2485. /// </summary>
  2486. /// <param name="deptId"></param>
  2487. /// <returns></returns>
  2488. public ActionResult GetHighlevel()
  2489. {
  2490. var user = userAccountBLL.GetModelList(" F_RoleId=61");
  2491. if (user != null)
  2492. return Success("获取高层信息成功", new
  2493. {
  2494. user
  2495. });
  2496. return Error("获取高层信息失败");
  2497. }
  2498. /// <summary>
  2499. /// 验证客户电话是否唯一
  2500. /// </summary>
  2501. private bool getunphone(int id, string phone)
  2502. {
  2503. var sql = " F_IsDelete=0 ";
  2504. sql += "and (F_LegalPhone='" + phone + "')";
  2505. if (id > 0)
  2506. sql += " and F_CustomerId<>" + id;
  2507. var count = customerBaseBLL .GetModelList(sql).Count();
  2508. return count > 0;
  2509. }
  2510. /// <summary>
  2511. /// 添加工单
  2512. /// </summary>
  2513. /// <returns></returns>
  2514. public ActionResult Add(WorkOrderNewInput input,int overtime = 0, int sms = 0)
  2515. {
  2516. if (!string.IsNullOrEmpty (input.F_WxOpenId ))
  2517. {
  2518. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + input.F_WxOpenId + "'").FirstOrDefault();
  2519. // string usercode = CurrentUser.UserData.F_UserCode;
  2520. // Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
  2521. if (ua == null&&input .F_Source !=3)
  2522. {
  2523. return Error("无操作权限!");
  2524. }
  2525. if (!string.IsNullOrEmpty(input.F_BatchNumber) && !vaBatchNumber(input.F_BatchNumber))
  2526. {
  2527. return Error("请输入正确的生产批次号!");
  2528. }
  2529. else
  2530. {
  2531. if (!string.IsNullOrEmpty(input.F_BatchNumber))
  2532. {
  2533. var prono = input.F_BatchNumber.Substring(0, 6);
  2534. try
  2535. {
  2536. var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
  2537. var protime = Convert.ToDateTime(pronos);
  2538. if (DateTime.Parse(pronos) > DateTime.Now)
  2539. {
  2540. return Error("生产批次号错误,生产日期不能大于当前时间!");
  2541. }
  2542. }
  2543. catch
  2544. {
  2545. return Error("生产批次号错误,日期格式错误!");
  2546. }
  2547. }
  2548. }
  2549. if (!string.IsNullOrEmpty(input.F_CustomerID) && !valcode(input.F_CustomerID.ToString(), 10))
  2550. return Error("客户编号为10为纯数字!");
  2551. if (!string .IsNullOrEmpty (input.F_MaterialID ) && !valcode(input.F_MaterialID.ToString(), 11))
  2552. return Error("物料编码为11为纯数字!");
  2553. if (string.IsNullOrEmpty(input.F_CusName))
  2554. return Error("请输入客户姓名!");
  2555. if (string.IsNullOrEmpty(input.F_CusPhone))
  2556. return Error("请输入客户电话!");
  2557. //if (input.F_Type == 2 || input.F_Type == 3)
  2558. //{
  2559. // if (string.IsNullOrEmpty(input.F_CustomerID))
  2560. // {
  2561. // if (string.IsNullOrEmpty(input.F_LegalPhone))
  2562. // return Error("请输入客户电话");
  2563. // if (getunphone(0, input.F_LegalPhone))
  2564. // return Error("已存在该客户请勿重复添加");
  2565. // }
  2566. //}
  2567. var model = new Model.T_Wo_WorkOrder();
  2568. #region 保存客户基本信息
  2569. model = inputtoobj(ua,model, input, 2);
  2570. if (model .F_Source =="3")
  2571. {
  2572. model.F_State =(int)EnumWorkOrderState.customers;
  2573. }
  2574. else
  2575. {
  2576. model.F_State = (int)EnumWorkOrderState.audit;
  2577. }
  2578. #endregion
  2579. long n = woBLL.Add(model);
  2580. if (n > 0)
  2581. {
  2582. #region 流转上一级领导审批
  2583. Model.T_Wo_WorkOrder modlelist = new BLL.T_Wo_WorkOrder().GetModel(n);
  2584. if (modlelist!=null)
  2585. {
  2586. if (ua !=null&& model.F_Source != "3")
  2587. {
  2588. if (GetUser(input.F_WxOpenId) != null)
  2589. {
  2590. var user = GetUser(input.F_WxOpenId);
  2591. string deptname = "", deptname1="";
  2592. var deptmodel = departmentBLL.GetModel(user.F_DeptId);
  2593. if (deptmodel != null)
  2594. {
  2595. deptname = deptmodel.F_DeptName + "-";
  2596. }
  2597. var deptmodel1 = departmentBLL.GetModel(ua .F_DeptId);
  2598. if (deptmodel1 != null)
  2599. {
  2600. deptname1 = deptmodel1.F_DeptName + "-";
  2601. }
  2602. 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 , 0, 0);
  2603. 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, 0, 0);
  2604. }
  2605. else
  2606. {
  2607. string deptname1 = "";
  2608. int dapt = 0,nextda=0;
  2609. var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
  2610. if (deptmodel1 != null)
  2611. {
  2612. deptname1 = deptmodel1.F_DeptName + "-";
  2613. dapt =deptmodel1.F_ParentId ;
  2614. }
  2615. AddLog(modlelist.F_ID, 0, deptname1 + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "创建工单", (int)EnumWorkOrderState.neworder, (int)EnumItemOpt.create,"",0, ua, 0, 0);
  2616. string opt = "";
  2617. if (dapt !=0)
  2618. {
  2619. if (dapt==11)
  2620. {
  2621. nextda = 37;
  2622. opt = "流转市场管理科";
  2623. }
  2624. else if (dapt == 14)
  2625. {
  2626. nextda = 57;
  2627. opt = "流转营销管理处";
  2628. }
  2629. else if (dapt == 15)
  2630. {
  2631. nextda = 74;
  2632. opt = "流转策划推广";
  2633. }
  2634. else if (dapt == 16)
  2635. {
  2636. nextda = 88;
  2637. opt = "流转销售部";
  2638. }
  2639. }
  2640. if (nextda!=0)
  2641. {
  2642. var res = AssignWO(ua, modlelist, input, opt, "", nextda, 0, overtime, sms);
  2643. if (res)
  2644. return Success("添加成功");
  2645. else
  2646. return Error("流转失败!");
  2647. }
  2648. else
  2649. {
  2650. return Error("流转失败!");
  2651. }
  2652. }
  2653. }
  2654. else
  2655. {
  2656. AddLog(modlelist.F_ID, 0, "客户" + "创建工单", (int)EnumItemType.deal, (int)EnumItemOpt.create, "", 0, null, 0, 0);
  2657. return Success("添加成功");
  2658. }
  2659. }
  2660. #endregion
  2661. return Success("添加成功!");
  2662. }
  2663. else
  2664. return Error("添加失败!");
  2665. }
  2666. else
  2667. {
  2668. return Error("OpenId不能为空!");
  2669. }
  2670. }
  2671. /// <summary>
  2672. /// 更新市场管理科,质量管理科
  2673. /// </summary>
  2674. /// <param name="model"></param>
  2675. /// <param name="input"></param>
  2676. /// <returns></returns>
  2677. private Model.T_Wo_WorkOrder InToworkModel(Model.T_Wo_WorkOrder model, WorkOrderNewInput input)
  2678. {
  2679. if (!string.IsNullOrEmpty(input.F_SC_ProductBase))
  2680. model.F_SC_ProductBase = input.F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
  2681. if (!string.IsNullOrEmpty(input.F_SC_PreliminaryOpinion))
  2682. model.F_SC_PreliminaryOpinion = input.F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
  2683. if (!string.IsNullOrEmpty(input.F_SC_QualityMonth))
  2684. model.F_SC_QualityMonth = input.F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
  2685. if (!string.IsNullOrEmpty(input.F_SC_CJ_SpotResult))
  2686. model.F_SC_CJ_SpotResult = input.F_SC_CJ_SpotResult;/// 市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
  2687. if (!string.IsNullOrEmpty(input.F_SC_CJ_SelfResult))
  2688. model.F_SC_CJ_SelfResult = input.F_SC_CJ_SelfResult;//市场管理科-抽检-自检结果
  2689. if (!string.IsNullOrEmpty(input.F_SC_CJ_ApprovalNo))
  2690. model.F_SC_CJ_ApprovalNo = input.F_SC_CJ_ApprovalNo;// 市场管理科-抽检-对应审批工作流单号
  2691. if (!string.IsNullOrEmpty(input.F_SC_CJ_ReturnAccount))
  2692. model.F_SC_CJ_ReturnAccount = input.F_SC_CJ_ReturnAccount;//市场管理科-抽检-确认返账金额(元)
  2693. if (!string.IsNullOrEmpty(input.F_ZL_QualityEventLevel))
  2694. model.F_ZL_QualityEventLevel = input.F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
  2695. if (!string.IsNullOrEmpty(input.F_ZL_ClaimAmount))
  2696. model.F_ZL_ClaimAmount = input.F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
  2697. if (!string.IsNullOrEmpty(input.F_ZL_ResponsibleUnit))
  2698. model.F_ZL_ResponsibleUnit = input.F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
  2699. if (!string.IsNullOrEmpty(input.F_ZL_ApprovalOpinions))
  2700. model.F_ZL_ApprovalOpinions = input.F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  2701. if (!string.IsNullOrEmpty(input.F_ZL_ApprovalDisagree))
  2702. model.F_ZL_ApprovalDisagree = input.F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
  2703. if (!string.IsNullOrEmpty(input.F_ZL_CompensationMethod))
  2704. model.F_ZL_CompensationMethod = input.F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  2705. if (!string.IsNullOrEmpty(input.F_ZL_CompensationMoney))
  2706. model.F_ZL_CompensationMoney = input.F_ZL_CompensationMoney;// 质量管理科-补偿钱款
  2707. if (!string.IsNullOrEmpty(input.F_ZL_CResponsibleUnits))
  2708. model.F_ZL_CResponsibleUnits = input.F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  2709. if (!string.IsNullOrEmpty(input.F_ZL_Fquantity))
  2710. model.F_ZL_Fquantity = input.F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
  2711. if (!string.IsNullOrEmpty(input.F_ZL_ImprovementRequirements))
  2712. model.F_ZL_ImprovementRequirements = input.F_ZL_ImprovementRequirements;//质量管理科-改进要求
  2713. if (!string.IsNullOrEmpty(input.F_ZL_CApprovalNo))
  2714. model.F_ZL_CApprovalNo = input.F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
  2715. if (!string.IsNullOrEmpty(input.F_ZL_CJ_IsRecord))
  2716. model.F_ZL_CJ_IsRecord = input.F_ZL_CJ_IsRecord;//质量管理科-抽检-未备案、已备案
  2717. if (input.F_IsVisit != null)
  2718. {
  2719. try
  2720. {
  2721. model.F_IsVisit = int.Parse(input.F_IsVisit);
  2722. }
  2723. catch
  2724. {
  2725. model.F_IsVisit =1;
  2726. }
  2727. }
  2728. return model;
  2729. }
  2730. /// <summary>
  2731. /// 指派/转派工单
  2732. /// <param name="orderid">工单id</param>
  2733. /// <param name="cont">指派说明</param>
  2734. /// <param name="clbm">指派部门</param>
  2735. /// <param name="clid">指派人</param>
  2736. /// </summary>
  2737. /// <returns></returns>
  2738. [WechatActionFilter]
  2739. public ActionResult AssignWorkOrder(string OpenId, long orderid, string cont, WorkOrdeDeptment deptment, string F_Files, int isvisit = 1,
  2740. int overtime = 0, int sms = 0, int clbm = 0, int clid = 0,int isApprovalp=0, int hclbm = 0, int hclid = 0)
  2741. {
  2742. if (!string.IsNullOrEmpty(OpenId))
  2743. {
  2744. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  2745. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  2746. WorkOrderNewInput input = new WorkOrderNewInput();
  2747. if (ua != null)
  2748. {
  2749. if (hclid == 0 && hclbm == 0 && isApprovalp != 0)
  2750. {
  2751. return Error("请选择接收部门");
  2752. }
  2753. if (clbm == 0 && clid == 0)
  2754. {
  2755. return Error("请选择接收部门");
  2756. }
  2757. else
  2758. {
  2759. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  2760. if (deptmodel != null)
  2761. {
  2762. if (model != null)
  2763. {
  2764. if (model.F_Type == "2")
  2765. {
  2766. if (deptmodel.F_DeptId == 37)
  2767. {
  2768. // input. F_SC_QualityMonth = QualityMonth;//市场管理科-超出质保期限
  2769. input.F_SC_PreliminaryOpinion = deptment.PreliminaryOpinion;//市场管理科-初审意见:退货、换货、补偿、自行处理
  2770. }
  2771. else if (deptmodel.F_DeptId == 12)
  2772. {
  2773. input.F_IsVisit = isvisit.ToString ();
  2774. input.F_ZL_QualityEventLevel = deptment.QualityEventLevel;//质量管理科-质量事件等级(未遂、一般、较大、重大)
  2775. input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
  2776. input.F_ZL_ResponsibleUnit = deptment.ResponsibleUnit;// 质量管理科-责任单位(需列出,可选多个)
  2777. input.F_ZL_ApprovalOpinions = deptment.ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  2778. input.F_ZL_ApprovalDisagree = deptment.ApprovalDisagree;// 质量管理科-审批不同意意见
  2779. input.F_ZL_CompensationMethod = deptment.CompensationMethod;// 质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  2780. input.F_ZL_CompensationMoney = deptment.CompensationMoney;// 质量管理科-补偿钱款
  2781. input.F_ZL_CResponsibleUnits = deptment.CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  2782. input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
  2783. input.F_ZL_ImprovementRequirements = deptment.ImprovementRequirements;// 质量管理科-改进要求
  2784. input.F_ZL_CApprovalNo = deptment.CApprovalNo;// 质量管理科-对应审批工作流单号
  2785. }
  2786. }
  2787. else if (model.F_Type == "3")
  2788. {
  2789. if (deptmodel.F_DeptId == 37)
  2790. {
  2791. input.F_SC_CJ_SpotResult = deptment.SpotResult;//市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
  2792. input.F_SC_CJ_SelfResult = deptment.SelfResult;//市场管理科-抽检-自检结果
  2793. input.F_SC_CJ_ApprovalNo = deptment.ApprovalNo;//市场管理科-抽检-对应审批工作流单号
  2794. input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//市场管理科-抽检-确认返账金额
  2795. }
  2796. else if (deptmodel.F_DeptId == 12)
  2797. {
  2798. input.F_IsVisit = isvisit.ToString ();
  2799. input.F_ZL_CJ_IsRecord = deptment.IsRecord;//质量管理科-抽检-未备案、已备案
  2800. input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
  2801. }
  2802. }
  2803. if (deptmodel.F_DeptId == 25)
  2804. {
  2805. input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//销售内勤-确认返账金额
  2806. }
  2807. else if (deptmodel.F_DeptId == 36)
  2808. {
  2809. input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
  2810. }
  2811. }
  2812. else
  2813. return Error("工单不存在!");
  2814. }
  2815. else
  2816. {
  2817. return Error("请选择接收部门");
  2818. }
  2819. }
  2820. if (model != null)
  2821. {
  2822. var res = AssignWO(ua, model, input, cont, F_Files, clbm, clid, overtime, sms, isApprovalp, hclbm, hclid);
  2823. if (res)
  2824. return Success("转派成功");
  2825. else
  2826. return Error("转派失败!");
  2827. }
  2828. else
  2829. return Error("工单不存在!");
  2830. }
  2831. }
  2832. return Error("无操作权限!");
  2833. }
  2834. /// <summary>
  2835. /// 转派工单
  2836. /// </summary>
  2837. 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 = "")
  2838. {
  2839. string smscont = "";
  2840. if (model.F_Type == "1")
  2841. {
  2842. smscont = "您有一条新的咨询工单,请及时处理";
  2843. }
  2844. else if (model.F_Type == "2")
  2845. {
  2846. smscont = "您有一条新的投诉工单,请及时处理";
  2847. }
  2848. else if (model.F_Type == "3")
  2849. {
  2850. smscont = "您有一条新的抽检工单,请及时处理";
  2851. }
  2852. else
  2853. {
  2854. smscont = "您有一条新的建议工单,请及时处理";
  2855. }
  2856. string touser = ""; string tousername = "";
  2857. #region 获取接收人
  2858. int deptid = 0;
  2859. if (clid != 0)
  2860. {
  2861. Model.T_Sys_UserAccount clus = userAccountBLL.GetModel(clid);
  2862. deptid = clus.F_DeptId;
  2863. clbm = clus.F_DeptId;
  2864. if (clus != null)
  2865. {
  2866. touser = clus.F_UserCode;
  2867. tousername = clus.F_UserName + "(" + clus.F_WorkNumber + ")";
  2868. }
  2869. if (sms != 0)
  2870. {
  2871. if (!string.IsNullOrEmpty(clus.F_Mobile))
  2872. {
  2873. SmsSingleSenderResult result = new SMSController().SMSSingleshot(clus.F_Mobile, smscont);
  2874. }
  2875. }
  2876. }
  2877. else
  2878. {
  2879. string users = string.Empty;
  2880. deptid = clbm;
  2881. var list = userAccountBLL.GetModelList(" F_DeptId='" + clbm + "'");
  2882. foreach (var l in list)
  2883. {
  2884. if (string.IsNullOrEmpty(users))
  2885. {
  2886. users = l.F_UserCode;
  2887. tousername = l.F_UserName + "(" + l.F_WorkNumber + ")";
  2888. }
  2889. else
  2890. {
  2891. users = users + "," + l.F_UserCode;
  2892. tousername = tousername + "," + l.F_UserName + "(" + l.F_WorkNumber + ")";
  2893. }
  2894. if (sms != 0)
  2895. {
  2896. if (!string.IsNullOrEmpty(l.F_Mobile))
  2897. {
  2898. SmsSingleSenderResult result = new SMSController().SMSSingleshot(l.F_Mobile, smscont);
  2899. }
  2900. }
  2901. }
  2902. touser = users;
  2903. }
  2904. string htouser = "", htousername = "";
  2905. if (isApprovalp != 0 && nowUser .F_DeptId == 37)
  2906. {
  2907. if (hclid != 0)
  2908. {
  2909. Model.T_Sys_UserAccount clus = userAccountBLL.GetModel(hclid);
  2910. if (clus != null)
  2911. {
  2912. if (string.IsNullOrEmpty(htouser))
  2913. {
  2914. htouser = clus.F_UserCode;
  2915. htousername = clus.F_UserName + "(" + clus.F_WorkNumber + ")";
  2916. }
  2917. }
  2918. }
  2919. else
  2920. {
  2921. var list = userAccountBLL.GetModelList(" F_DeptId='" + hclbm + "'");
  2922. foreach (var l in list)
  2923. {
  2924. if (string.IsNullOrEmpty(htouser))
  2925. {
  2926. htouser = l.F_UserCode;
  2927. htousername = l.F_UserName + "(" + l.F_UserCode + ")";
  2928. }
  2929. else
  2930. {
  2931. htouser = htouser + "," + l.F_UserCode;
  2932. htousername = htousername + "," + l.F_UserName + "(" + l.F_WorkNumber + ")";
  2933. }
  2934. }
  2935. }
  2936. AddLog(model.F_ID, (int)EnumWorkOrderState.assign, htousername+ "高层待审批", (int)EnumItemType.audit, (int)EnumItemOpt.audit, htouser, hclbm, nowUser, overtime, sms, creat,2);
  2937. }
  2938. #endregion
  2939. #region 工单处理
  2940. var opt = "指派";
  2941. int optbut = (int)EnumItemOpt.assign;
  2942. int wostate = (int)EnumWorkOrderState.assign;//已指派待接单
  2943. #region 读取当前登录人部门
  2944. string deptname = "";
  2945. var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
  2946. if (deptmodel != null)
  2947. {
  2948. deptname = deptmodel.F_DeptName + "-";
  2949. }
  2950. #endregion
  2951. var optcont = "";
  2952. if (!string.IsNullOrEmpty(cont))
  2953. optcont = ",说明:" + cont;
  2954. var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单给 " + tousername + optcont;
  2955. var itemid = AddLog(model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, touser, clbm, nowUser, overtime, sms, creat);
  2956. if (itemid > 0)
  2957. {
  2958. #region 处理工单
  2959. //工单完结要更新工单的状态
  2960. // model.F_DealBy = touser;
  2961. model.F_State = wostate;
  2962. model.F_limit = overtime;
  2963. if (!string.IsNullOrEmpty(F_Files))
  2964. model.F_Files = F_Files;
  2965. //处理内容
  2966. if (!string.IsNullOrEmpty(cont))
  2967. model.F_DealContent += cont + ";";
  2968. InToworkModel(model, input);
  2969. woBLL.Update(model);
  2970. #endregion
  2971. #region 推送消息
  2972. #region 推送消息给添加的坐席 -转派和处理
  2973. if (nowUser.F_UserCode != model.F_CreateBy)
  2974. {
  2975. sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//推送系统消息
  2976. var createmodel = userAccountBLL.GetModel(model.F_CreateBy); //被指派人
  2977. if (createmodel != null)
  2978. {
  2979. if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
  2980. {
  2981. sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
  2982. }
  2983. }
  2984. }
  2985. #endregion
  2986. #region 向下一级操作人员推送消息
  2987. if (!string.IsNullOrWhiteSpace(touser))
  2988. {
  2989. sendsysmsg(model, nowUser, touser, (int)model.F_ID, opt);//推送系统消息
  2990. var modelUser2 = userAccountBLL.GetModel(touser); //被指派人
  2991. if (modelUser2 != null)
  2992. {
  2993. if (!string.IsNullOrEmpty(modelUser2.F_WxOpenId))
  2994. {
  2995. sendwxmsg(model, modelUser2.F_WxOpenId, nowUser, "指派");
  2996. }
  2997. }
  2998. }
  2999. #endregion
  3000. #endregion
  3001. return true;
  3002. }
  3003. else
  3004. return false;
  3005. #endregion
  3006. }
  3007. /// <summary>
  3008. /// 查询超时工单列表
  3009. /// </summary>
  3010. [WechatActionFilter]
  3011. public ActionResult GetOvertime(string OpenId, string code, string keywords, string cusname, string cusphone, string companyname, string province, string city,
  3012. string country, string township, string touser, int source = 0, int type = 0, int pageindex = 1, int pagesize = 10)
  3013. {
  3014. if (!string.IsNullOrEmpty(OpenId))
  3015. {
  3016. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3017. if (ua==null )
  3018. {
  3019. return Error("该账号已在别的设备登录,请及时修改密码重新登录。");
  3020. }
  3021. if (!Refresh())
  3022. {
  3023. return Error("查询失败");
  3024. }
  3025. string sql = $" and F_IsDelete=0";
  3026. DataTable dt = new DataTable();
  3027. #region 筛选条件
  3028. if (type > 0 && type < 5)//工单类型
  3029. sql += $" and F_Type=" + type;
  3030. if (source > 0)//工单来源
  3031. sql += $" and F_Source=" + source;
  3032. if (!string.IsNullOrWhiteSpace(touser))//参与人
  3033. sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
  3034. if (!string.IsNullOrWhiteSpace(code))//工单编号
  3035. sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
  3036. if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
  3037. sql += $" and (F_WorkOrderCode like '%" + keywords.Trim() + "%' or F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%' )";
  3038. if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
  3039. sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
  3040. if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
  3041. sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
  3042. if (!string.IsNullOrWhiteSpace(companyname))//公司名称
  3043. sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
  3044. if (!string.IsNullOrWhiteSpace(province))//省
  3045. sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
  3046. if (!string.IsNullOrWhiteSpace(province))//市
  3047. sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
  3048. if (!string.IsNullOrWhiteSpace(province))//县
  3049. sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
  3050. if (!string.IsNullOrWhiteSpace(province))//乡
  3051. sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
  3052. sql += $" and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
  3053. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ")";
  3054. sql += $" and F_IsOver=" + 1;
  3055. Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
  3056. if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY" || ro.F_RoleCode == "BLRY")
  3057. {
  3058. sql += $" and F_DealBy like '%" + ua.F_UserCode.Trim() + "%'";
  3059. }
  3060. else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
  3061. {
  3062. string detpid = "";
  3063. var deparmentlist = new List<Model.T_Sys_Department>();
  3064. Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
  3065. if (dModel != null)
  3066. {
  3067. if (dModel.F_Layer == 1)
  3068. {
  3069. deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
  3070. if (deparmentlist.Count > 0)
  3071. {
  3072. foreach (var it in deparmentlist)
  3073. {
  3074. if (detpid != "")
  3075. {
  3076. detpid += "," + it.F_DeptId;
  3077. }
  3078. else
  3079. {
  3080. detpid = "" + it.F_DeptId; ;
  3081. }
  3082. }
  3083. }
  3084. }
  3085. else
  3086. {
  3087. detpid = ua.F_DeptId.ToString();
  3088. }
  3089. if (GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.dealing + ", " + (int)EnumWorkOrderState.receive + "," +
  3090. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "") != "")
  3091. {
  3092. sql += $" and T_Wo_WorkOrder.F_ID in ( " + GetDeptWorkOrderID(detpid, "" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
  3093. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "") + ") "; ;
  3094. }
  3095. else
  3096. {
  3097. return Success("暂无工单"); ;
  3098. }
  3099. }
  3100. else
  3101. {
  3102. return Error("加载失败");
  3103. }
  3104. }
  3105. else if (ro.F_RoleCode == "JDYBZZX")
  3106. {
  3107. sql += $" and F_CreateBy like '%" + ua.F_UserCode.Trim() + "%'";
  3108. }
  3109. else if (ro.F_RoleCode == "QTJS")
  3110. {
  3111. return Error("无操作权限!");
  3112. }
  3113. #endregion
  3114. int recordCount = 0;
  3115. if (!string.IsNullOrWhiteSpace(sql))
  3116. {
  3117. dt = BLL.PagerBLL.GetListPager(
  3118. "T_Wo_WorkOrder",
  3119. "F_ID",
  3120. "*",
  3121. sql,
  3122. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  3123. pagesize,
  3124. pageindex,
  3125. true,
  3126. out recordCount);
  3127. }
  3128. List<long> woid = new List<long>();
  3129. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  3130. List<WorkOrderNewInput> Input = modeltooip(modlelist,ua );
  3131. var obj = new
  3132. {
  3133. state = "success",
  3134. message = "成功",
  3135. rows = Input,
  3136. total = recordCount
  3137. };
  3138. return Content(obj.ToJson()); ;
  3139. }
  3140. else
  3141. {
  3142. return Error("无操作权限!");
  3143. }
  3144. }
  3145. /// 是否超时
  3146. /// </summary>
  3147. /// <param name="id"></param>
  3148. /// <returns></returns>
  3149. private bool TimeforOver(int id)
  3150. {
  3151. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + " ");
  3152. string time1 = "", time2 = ""; int x = 0, y = 0;
  3153. float time = 0;
  3154. if (itemlasts.Count > 0)
  3155. {
  3156. for (int i = 0; i < itemlasts.Count; i++)
  3157. {
  3158. if (itemlasts[i].F_WoState >= 1)
  3159. {
  3160. if (itemlasts[i].F_WoState == 1)
  3161. {
  3162. x = i;
  3163. time1 = itemlasts[i].F_CreateTime.ToString();
  3164. time = float.Parse(itemlasts[i].F_LimitTime);
  3165. }
  3166. if (itemlasts[i].F_WoState == 10)
  3167. {
  3168. y = i;
  3169. time2 = itemlasts[i].F_CreateTime.ToString();
  3170. }
  3171. }
  3172. }
  3173. if (time2 != "")
  3174. {
  3175. if (time1 != "")
  3176. {
  3177. if (x > y)
  3178. {
  3179. int a = (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours;
  3180. if (a > time)
  3181. {
  3182. return false;
  3183. }
  3184. }
  3185. else
  3186. {
  3187. int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  3188. if (a > time)
  3189. {
  3190. return false;
  3191. }
  3192. }
  3193. }
  3194. else
  3195. {
  3196. return true;
  3197. }
  3198. }
  3199. else if (time1 != "")
  3200. {
  3201. int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  3202. if (a > time)
  3203. {
  3204. return false;
  3205. }
  3206. }
  3207. else
  3208. {
  3209. return true;
  3210. }
  3211. }
  3212. else
  3213. {
  3214. return true;
  3215. }
  3216. return true;
  3217. }
  3218. /// <summary>
  3219. /// 接单 - 确认工单
  3220. /// </summary>
  3221. /// <returns></returns>
  3222. [WechatActionFilter]
  3223. public ActionResult SureWorkOrder(long orderid, string OpenId)
  3224. {
  3225. if (!string.IsNullOrEmpty(OpenId))
  3226. {
  3227. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3228. if (ua != null)
  3229. {
  3230. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  3231. if (model != null)
  3232. {
  3233. if (model.F_State == 2)
  3234. {
  3235. return Error("工单已接单无需重新接单");
  3236. }
  3237. else
  3238. {
  3239. var res = SureWO(ua, model);
  3240. if (res)
  3241. return Success("接单成功");
  3242. else
  3243. return Error("接单失败");
  3244. }
  3245. }
  3246. else
  3247. return Error("工单不存在");
  3248. }
  3249. return Error("OpenId不能为空");
  3250. }
  3251. return Error("无操作权限");
  3252. }
  3253. /// <summary>
  3254. /// 高层审批
  3255. /// </summary>
  3256. /// <param name="input"></param>
  3257. /// <returns></returns>
  3258. [WechatActionFilter]
  3259. public ActionResult HigApprovalOrder(string OpenId, long orderid,string cont)
  3260. {
  3261. if (!string.IsNullOrEmpty(OpenId))
  3262. {
  3263. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3264. if (ua != null)
  3265. {
  3266. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  3267. //验证信息
  3268. if (model != null)
  3269. {
  3270. 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);
  3271. if (itemlast.Count > 0)
  3272. {
  3273. foreach (var it in itemlast)
  3274. {
  3275. it.F_IsUsed = 1;
  3276. itembll.Update(it);
  3277. }
  3278. }
  3279. model.F_Highopinions = cont;
  3280. string deptname = "";
  3281. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  3282. if (deptmodel != null)
  3283. {
  3284. deptname = deptmodel.F_DeptName + "-";
  3285. }
  3286. AddLog(model.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "高层已审批", (int)EnumItemType.audit, (int)EnumItemOpt.reaudit, "", 0, ua, 0, 0,"",1);
  3287. bool n = woBLL.Update(model);
  3288. if (n)
  3289. return Success("审批成功");
  3290. else
  3291. return Error("审批失败!");
  3292. }
  3293. return Error("工单不存在");
  3294. }
  3295. }
  3296. return Error("无操作权限");
  3297. }
  3298. /// <summary>
  3299. /// 接单
  3300. /// </summary>
  3301. public bool SureWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model)
  3302. {
  3303. int overtime = 0, sms = 0;
  3304. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
  3305. if (itemlasts.Count > 0)
  3306. {
  3307. foreach (var it in itemlasts)
  3308. {
  3309. if (it.F_WoState == 1)
  3310. {
  3311. overtime = int.Parse(it.F_LimitTime);
  3312. sms = int.Parse(it.F_IsSMS.ToString());
  3313. }
  3314. }
  3315. }
  3316. #region 工单处理
  3317. var opt = "处理接单";
  3318. int optbut = (int)EnumItemOpt.receive;
  3319. int wostate = (int)EnumWorkOrderState.receive;
  3320. #region 读取当前登录人部门
  3321. string deptname = "";
  3322. var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
  3323. if (deptmodel != null)
  3324. {
  3325. deptname = deptmodel.F_DeptName + "-";
  3326. }
  3327. #endregion
  3328. var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt;
  3329. var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, nowUser.F_UserCode, nowUser.F_DeptId, nowUser, overtime, sms);
  3330. if (itemid > 0)
  3331. {
  3332. #region 处理工单
  3333. model.F_State = wostate;//已接单待处理
  3334. model.F_DealBy = nowUser.F_UserCode ;//已接单待处理
  3335. woBLL .Update(model);
  3336. #endregion
  3337. #region 推送消息
  3338. //读取上一级指派人员以及添加坐席并推送系统消息和微信消息
  3339. #region 给添加坐席推送系统消息和微信消息
  3340. sendsysmsg(model, nowUser, model.F_CreateBy, (int)itemid, "处理接单");
  3341. var createUser = userAccountBLL.GetModel(model.F_CreateBy);
  3342. if (createUser != null && !string.IsNullOrEmpty(createUser.F_WxOpenId))
  3343. sendwxmsg(model, createUser.F_WxOpenId, nowUser, "接单");
  3344. #endregion
  3345. #region 读取上一级指派人员推送系统消息和微信消息
  3346. var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
  3347. if (itemlast != null)
  3348. {
  3349. if (itemlast.F_CreateUser != model.F_CreateBy)
  3350. {
  3351. sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, "处理接单");
  3352. var lastUser = userAccountBLL.GetModel(itemlast.F_CreateUser);
  3353. if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
  3354. sendwxmsg(model, lastUser.F_WxOpenId, nowUser, "接单");
  3355. }
  3356. }
  3357. #endregion
  3358. #endregion
  3359. return true;
  3360. }
  3361. else
  3362. return false;
  3363. #endregion
  3364. }
  3365. /// <summary>
  3366. /// 工单处理
  3367. /// </summary>
  3368. /// <returns></returns>
  3369. [WechatActionFilter]
  3370. public ActionResult DealWorkOrder(string OpenId,long orderid, string cont, WorkOrdeDeptment deptment,
  3371. string uncont = "",
  3372. int isvisit = 1, int isover = 0)
  3373. {
  3374. if (!string.IsNullOrEmpty(OpenId))
  3375. {
  3376. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3377. WorkOrderNewInput input = new WorkOrderNewInput();
  3378. if (ua != null)
  3379. {
  3380. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  3381. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  3382. if (deptmodel != null)
  3383. {
  3384. if (model != null)
  3385. {
  3386. if (model.F_Type == "2")
  3387. {
  3388. if (deptmodel.F_DeptId == 37)
  3389. {
  3390. input.F_SC_ProductBase = deptment.ProductBase;//
  3391. }
  3392. else if (deptmodel.F_DeptId == 12)
  3393. {
  3394. input.F_IsVisit = isvisit.ToString ();
  3395. input.F_ZL_QualityEventLevel = deptment.QualityEventLevel;//质量管理科-质量事件等级(未遂、一般、较大、重大)
  3396. input.F_ZL_ClaimAmount = deptment.ClaimAmount;// 质量管理科-索赔金额(单位元,对应责任单位)
  3397. input.F_ZL_ResponsibleUnit = deptment.ResponsibleUnit;// 质量管理科-责任单位(需列出,可选多个)
  3398. input.F_ZL_ApprovalOpinions = deptment.ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  3399. input.F_ZL_ApprovalDisagree = deptment.ApprovalDisagree;// 质量管理科-审批不同意意见
  3400. input.F_ZL_CompensationMethod = deptment.CompensationMethod;// 质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  3401. input.F_ZL_CompensationMoney = deptment.CompensationMoney;// 质量管理科-补偿钱款
  3402. input.F_ZL_CResponsibleUnits = deptment.CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  3403. input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
  3404. input.F_ZL_ImprovementRequirements = deptment.ImprovementRequirements;// 质量管理科-改进要求
  3405. input.F_ZL_CApprovalNo = deptment.CApprovalNo;// 质量管理科-对应审批工作流单号
  3406. }
  3407. }
  3408. else if (model.F_Type == "3")
  3409. {
  3410. if (deptmodel.F_DeptId == 37)
  3411. {
  3412. input.F_SC_ProductBase = deptment.ProductBase;//
  3413. }
  3414. else if (deptmodel.F_DeptId == 12)
  3415. {
  3416. input.F_IsVisit = isvisit.ToString ();
  3417. input.F_ZL_CJ_IsRecord = deptment.IsRecord;//质量管理科-抽检-未备案、已备案
  3418. }
  3419. }
  3420. if (deptmodel.F_DeptId == 25)
  3421. {
  3422. input.F_SC_CJ_ReturnAccount = deptment.ReturnAccount;//销售内勤-确认返账金额
  3423. }
  3424. else if (deptmodel.F_DeptId == 36)
  3425. {
  3426. input.F_ZL_Fquantity = deptment.Fquantity;//质量管理科-确认实收数量(吨)
  3427. }
  3428. }
  3429. else
  3430. return Error("工单不存在!");
  3431. }
  3432. else
  3433. {
  3434. return Error("请选择接收部门");
  3435. }
  3436. if (model != null)
  3437. {
  3438. var res = DealWO(ua, model, input, cont, isover, uncont);
  3439. if (res)
  3440. return Success("处理成功");
  3441. else
  3442. return Error("处理失败!");
  3443. }
  3444. else
  3445. return Error("工单不存在!");
  3446. }
  3447. }
  3448. return Error("无操作权限!");
  3449. }
  3450. /// <summary>
  3451. /// 更新工单
  3452. /// </summary>
  3453. private bool Refresh()
  3454. {
  3455. int type = 0;
  3456. var modlelist = woBLL .GetModelList(" F_IsDelete=0" + "and F_IsOver=0" + " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
  3457. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ")");
  3458. if (modlelist.Count > 0)
  3459. {
  3460. foreach (var it in modlelist)
  3461. {
  3462. if (TimeforOver(it.F_ID))
  3463. {
  3464. type = 0;
  3465. }
  3466. else
  3467. {
  3468. type = 1;
  3469. }
  3470. if (type != it.F_IsOver)
  3471. {
  3472. it.F_IsOver = type;
  3473. bool n = woBLL.Update(it);
  3474. if (!n)
  3475. {
  3476. return false;
  3477. }
  3478. }
  3479. }
  3480. }
  3481. return true;
  3482. }
  3483. /// <summary>
  3484. /// 退回工单
  3485. /// </summary>
  3486. /// <param name="input"></param>
  3487. /// <returns></returns>
  3488. [WechatActionFilter]
  3489. public ActionResult BackWorkOrder(string OpenId,long orderid, string cont, int type = 0)
  3490. {//办理人员和监管可以退回工单
  3491. if (!string.IsNullOrEmpty(OpenId))
  3492. {
  3493. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3494. //河南心连心化学工业集团股份有限公司-系统维护管理员(8000)指派工单给 李波(80324),张绍申(80325),杜爱国(80326),说明:无
  3495. if (ua != null)
  3496. {
  3497. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  3498. //验证信息
  3499. if (model != null)
  3500. {
  3501. var res = BackWO(ua, model, cont, type);
  3502. if (res)
  3503. return Success("退回成功");
  3504. else
  3505. return Error("退回失败!");
  3506. }
  3507. return Error("工单不存在");
  3508. }
  3509. }
  3510. return Error("无操作权限");
  3511. }
  3512. /// <summary>
  3513. ///申请延期
  3514. /// </summary>
  3515. /// <returns></returns>
  3516. [WechatActionFilter]
  3517. public ActionResult DelayWorkOrder(string OpenId,long orderid, string cont, float limit = 0)
  3518. {
  3519. if (!string.IsNullOrEmpty(OpenId))
  3520. {
  3521. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + OpenId + "'").FirstOrDefault();
  3522. if (ua != null)
  3523. {
  3524. Model.T_Wo_WorkOrder model = woBLL .GetModel(orderid);
  3525. //验证信息
  3526. if (model != null)
  3527. {
  3528. var res = DeWO(ua, model, cont, limit);
  3529. if (res)
  3530. return Success("延期成功");
  3531. else
  3532. return Error("延期失败!");
  3533. }
  3534. return Error("工单不存在");
  3535. }
  3536. }
  3537. return Error("无操作权限");
  3538. }
  3539. /// <summary>
  3540. /// 申请延期
  3541. /// </summary>
  3542. public bool DeWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, float limit)
  3543. {
  3544. #region 工单处理
  3545. int sms = 0; int wostate = 0;
  3546. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
  3547. if (itemlasts.Count > 0)
  3548. {
  3549. foreach (var it in itemlasts)
  3550. {
  3551. if (it.F_WoState == 1)
  3552. {
  3553. sms = int.Parse(it.F_IsSMS.ToString());
  3554. }
  3555. itembll.Update(it);
  3556. wostate = int.Parse(it.F_WoState.ToString());
  3557. }
  3558. }
  3559. int optbut = (int)EnumItemOpt.Delay;
  3560. #region 读取当前登录人部门
  3561. string deptname = "";
  3562. var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
  3563. if (deptmodel != null)
  3564. {
  3565. deptname = deptmodel.F_DeptName + "-";
  3566. }
  3567. #endregion
  3568. var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + "延期工单,延期说明:" + cont;
  3569. //获取上一级处理人员
  3570. var touser = "";
  3571. var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
  3572. if (itemlast != null)
  3573. touser = itemlast.F_CreateUser;
  3574. var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.Delay, optbut, touser, 0, nowUser, limit + model .F_limit , sms,"", 1);
  3575. #endregion
  3576. return true;
  3577. }
  3578. /// <summary>
  3579. /// 退回工单
  3580. /// </summary>
  3581. public bool BackWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, int type)
  3582. {
  3583. #region 工单处理
  3584. int sms = 0;
  3585. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
  3586. if (itemlasts.Count > 0)
  3587. {
  3588. foreach (var it in itemlasts)
  3589. {
  3590. if (it.F_WoState == 1)
  3591. {
  3592. sms = int.Parse(it.F_IsSMS.ToString());
  3593. }
  3594. }
  3595. }
  3596. var opt = "退回";
  3597. int F_OptType = 1;
  3598. int optbut = (int)EnumItemOpt.reback;
  3599. int wostate = (int)EnumWorkOrderState.reback;
  3600. if (type == 1)
  3601. {
  3602. opt = "异常退回";
  3603. optbut = (int)EnumItemOpt.abreback;
  3604. wostate = (int)EnumWorkOrderState.abreback;
  3605. F_OptType = 2;
  3606. }
  3607. #region 读取当前登录人部门
  3608. string deptname = "";
  3609. var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
  3610. if (deptmodel != null)
  3611. {
  3612. deptname = deptmodel.F_DeptName + "-";
  3613. }
  3614. #endregion
  3615. var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单,退回说明:" + cont;
  3616. //获取上一级处理人员
  3617. var touser = ""; var deptid = 0;
  3618. 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_CreateTime desc").FirstOrDefault();
  3619. if (itemlast != null)
  3620. {
  3621. touser = itemlast.F_CreateUser;
  3622. if (!string.IsNullOrEmpty(touser))
  3623. {
  3624. var ua = userAccountBLL .GetModel(touser);
  3625. if (ua != null)
  3626. {
  3627. deptid = ua.F_DeptId;
  3628. }
  3629. }
  3630. }
  3631. var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, touser, deptid, nowUser, model .F_limit , sms);
  3632. if (itemid > 0)
  3633. {
  3634. #region 处理工单
  3635. if (model.F_State == (int)EnumWorkOrderState.assign || model.F_State == (int)EnumWorkOrderState.abreback)
  3636. {
  3637. model.F_State = (int)EnumWorkOrderState.reassign;
  3638. }
  3639. else
  3640. {
  3641. model.F_State = wostate;
  3642. }
  3643. woBLL .Update(model);
  3644. #endregion
  3645. #region 推送消息
  3646. #region 向上一级操作人员推送消息
  3647. if (!string.IsNullOrWhiteSpace(touser) && touser != nowUser.F_UserCode)
  3648. {//排除上一级指派人是自己
  3649. sendsysmsg(model, nowUser, touser, (int)itemid, opt);
  3650. var lastUser = userAccountBLL .GetModel(touser);
  3651. if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
  3652. sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
  3653. }
  3654. #endregion
  3655. #endregion
  3656. return true;
  3657. }
  3658. else
  3659. return false;
  3660. #endregion
  3661. }
  3662. /// <summary>
  3663. /// 处理工单
  3664. /// </summary>
  3665. public bool DealWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, WorkOrderNewInput input, string cont, int isover = 0, string uncont = "")
  3666. {
  3667. #region 工单处理
  3668. int sms = 0;
  3669. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
  3670. if (itemlasts.Count > 0)
  3671. {
  3672. foreach (var it in itemlasts)
  3673. {
  3674. if (it.F_WoState == 1)
  3675. {
  3676. sms = int.Parse(it.F_IsSMS.ToString());
  3677. }
  3678. }
  3679. }
  3680. var opt = "处理";
  3681. int optbut = (int)EnumItemOpt.deal;
  3682. int wostate = (int)EnumWorkOrderState.receive;
  3683. if (isover == 1)
  3684. {
  3685. model.F_DealResult = "已处理";//处理结果
  3686. opt = "处理完结";
  3687. optbut = (int)EnumItemOpt.end;
  3688. wostate = (int)EnumWorkOrderState.finish;
  3689. model.F_DealBy = nowUser.F_UserCode;
  3690. model.F_DealTime = DateTime.Now;
  3691. }
  3692. else
  3693. {
  3694. model.F_DealResult = "未处理";//处理结果
  3695. model.F_DealReasons = uncont;//未处理原因
  3696. }
  3697. #region 读取当前登录人部门
  3698. string deptname = "";
  3699. var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
  3700. if (deptmodel != null)
  3701. {
  3702. deptname = deptmodel.F_DeptName + "-";
  3703. }
  3704. #endregion
  3705. var optcont = "";
  3706. if (!string.IsNullOrEmpty(cont))
  3707. optcont = ",处理内容:" + cont;
  3708. var content = deptname + nowUser.F_UserName + "(" + nowUser.F_WorkNumber + ")" + opt + "工单" + optcont;
  3709. var itemid = AddLog(model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, "", 0, nowUser, model .F_limit , sms);
  3710. if (itemid > 0)
  3711. {
  3712. #region 处理工单
  3713. model.F_State = wostate;
  3714. //处理内容
  3715. if (!string.IsNullOrEmpty(cont))
  3716. model.F_DealContent += cont + ";";
  3717. model.F_DealTime = DateTime.Now;
  3718. InToworkModel(model, input);
  3719. woBLL .Update(model);
  3720. #endregion
  3721. #region 推送消息
  3722. #region 推送消息给添加的坐席 -处理情况
  3723. if (nowUser.F_UserCode != model.F_CreateBy)
  3724. {
  3725. sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID, opt);//推送系统消息
  3726. var createmodel = userAccountBLL .GetModel(model.F_CreateBy); //被指派人
  3727. if (createmodel != null)
  3728. {
  3729. if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
  3730. {
  3731. sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
  3732. }
  3733. }
  3734. }
  3735. #endregion
  3736. #region 向上一级操作人员推送消息
  3737. var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
  3738. if (itemlast != null)
  3739. {
  3740. if (itemlast.F_CreateUser != model.F_CreateBy)
  3741. {
  3742. sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, opt);
  3743. var lastUser = userAccountBLL .GetModel(itemlast.F_CreateUser);
  3744. if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
  3745. sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
  3746. }
  3747. }
  3748. #endregion
  3749. #region 办理完结向客户发送消息
  3750. if (model.F_State == (int)EnumWorkOrderState.finish)
  3751. {
  3752. if (!string .IsNullOrEmpty (model.F_CustomerID ))
  3753. {
  3754. var cusmodel = customerBaseBLL.GetModel(model.F_CustomerID.Trim ());
  3755. if (cusmodel != null && !string.IsNullOrEmpty(cusmodel.F_WxOpenId))
  3756. {
  3757. sendwxmsg(model, cusmodel.F_WxOpenId, nowUser, opt);
  3758. }
  3759. }
  3760. }
  3761. #endregion
  3762. #endregion
  3763. return true;
  3764. }
  3765. else
  3766. return false;
  3767. #endregion
  3768. }
  3769. //推送系统提醒
  3770. public void sendsysmsg(Model.T_Wo_WorkOrder womodel, Model.T_Sys_UserAccount nowUser, string touser, int toid, string opt)
  3771. {
  3772. #region 消息提醒
  3773. string strmsg = string.Empty;
  3774. strmsg = nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + "操作" + opt + "工单";
  3775. Model.T_Msg_List msg = new Model.T_Msg_List();
  3776. msg.Type = (int)Model.MSGType.workorder;//处理
  3777. msg.ToUser = touser;
  3778. msg.ToID = toid;
  3779. msg.Detail = strmsg;
  3780. msg.State = 0;
  3781. msg.IsDel = 0;
  3782. msg.CreateUser = nowUser.F_UserCode;
  3783. msg.CreateDate = DateTime.Now;
  3784. new BLL.T_Msg_List().Add(msg);
  3785. #endregion
  3786. }
  3787. //推送微信消息
  3788. public void sendwxmsg(Model.T_Wo_WorkOrder womodel, string openid, Model.T_Sys_UserAccount nowUser, string opt)
  3789. {
  3790. #region 推送微信
  3791. try
  3792. {
  3793. if (!string.IsNullOrEmpty(openid))
  3794. {
  3795. var dicv = dicvalueBll.GetModel(int.Parse(womodel.F_Type));
  3796. string content = string.Empty;
  3797. var wotype = "";
  3798. if (dicv != null)
  3799. {
  3800. wotype = dicv.F_Name;
  3801. }
  3802. content = "编号" + womodel.F_WorkOrderCode + "的工单已" + opt + ",操作人:" + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")";
  3803. var msg = WxHelper.SendWechatMsg1(womodel.F_WorkOrderCode, "你有工单已" + opt, wotype, womodel.F_State.ToString(), content, womodel.F_ID.ToString(), openid, "");
  3804. Error("推送微信::::::" + msg.ToString());
  3805. }
  3806. }
  3807. catch { }
  3808. #endregion
  3809. }
  3810. /// <summary>
  3811. /// 修改工单
  3812. /// </summary>
  3813. /// <returns></returns>
  3814. [WechatActionFilter]
  3815. public ActionResult Update(WorkOrderNewInput input)
  3816. {
  3817. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + input.F_WxOpenId + "'").FirstOrDefault();
  3818. if (ua != null )
  3819. {
  3820. #region 添加验证判断
  3821. if (input.F_ID <= 0)
  3822. return Error("参数错误!");
  3823. if (!(input.F_Type > 0 && input.F_Type < 5))
  3824. return Error("工单类型错误!");
  3825. if (string.IsNullOrEmpty(input.F_CusName))
  3826. return Error("请输入客户姓名!");
  3827. if (string.IsNullOrEmpty(input.F_CusPhone))
  3828. return Error("请输入客户电话!");
  3829. if (!string.IsNullOrEmpty(input.F_BatchNumber) && !vaBatchNumber(input.F_BatchNumber))
  3830. {
  3831. return Error("请输入正确的生产批次号!");
  3832. }
  3833. else
  3834. {
  3835. if (!string.IsNullOrEmpty(input.F_BatchNumber))
  3836. {
  3837. var prono = input.F_BatchNumber.Substring(0, 6);
  3838. try
  3839. {
  3840. var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
  3841. var protime = Convert.ToDateTime(pronos);
  3842. if (DateTime.Parse(pronos) > DateTime.Now)
  3843. {
  3844. return Error("生产批次号错误,生产日期不能大于当前时间!");
  3845. }
  3846. }
  3847. catch
  3848. {
  3849. return Error("生产批次号错误,日期格式错误!");
  3850. }
  3851. }
  3852. }
  3853. if (!string .IsNullOrEmpty (input.F_CustomerID) && !valcode(input.F_CustomerID.ToString(), 10))
  3854. return Error("客户编号为10为纯数字!");
  3855. if (!string .IsNullOrEmpty (input.F_MaterialID) && !valcode(input.F_MaterialID.ToString(), 11))
  3856. return Error("物料编码为11为纯数字!");
  3857. #endregion
  3858. var model = woBLL.GetModel(input.F_ID);
  3859. if (model ==null )
  3860. return Error("查询不到此工单!");
  3861. if (model.F_State == 2)
  3862. {
  3863. return Error("此工单已接单不能修改!");
  3864. }
  3865. else if (model.F_State == 11 || model.F_State == 10)
  3866. {
  3867. return Error("此工单已处理不能修改!");
  3868. }
  3869. #region 保存客户基本信息
  3870. model = inputtoobj(ua,model, input, 1);
  3871. #endregion
  3872. bool n = woBLL.Update(model);
  3873. if (n)
  3874. {
  3875. WriteWorkOrderLog(model.F_WorkOrderCode, ua.F_UserCode, 0, "", 1, "修改工单");
  3876. #region 读取当前登录人的部门
  3877. string deptname = "";
  3878. var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
  3879. if (deptmodel != null)
  3880. {
  3881. deptname = deptmodel.F_DeptName + "-";
  3882. }
  3883. #endregion
  3884. AddLog(input.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_WorkNumber + ")" + "修改工单", (int)EnumItemType.update, (int)EnumItemOpt.update, "", 0, ua, 0, 0);
  3885. if (GetUser(input.F_WxOpenId) != null)
  3886. {
  3887. var user = GetUser(input.F_WxOpenId);
  3888. string deptname1 = "";
  3889. var deptmode = departmentBLL.GetModel(user.F_DeptId);
  3890. if (deptmode != null)
  3891. {
  3892. deptname1 = deptmode.F_DeptName + "-";
  3893. }
  3894. var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
  3895. 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, 0, 0);
  3896. }
  3897. else
  3898. {
  3899. string deptname1 = "";
  3900. int dapt = 0, nextda = 0; string opt = "";
  3901. var deptmodel1 = departmentBLL.GetModel(ua.F_DeptId);
  3902. if (deptmodel1 != null)
  3903. {
  3904. deptname1 = deptmodel1.F_DeptName + "-";
  3905. dapt = deptmodel1.F_ParentId;
  3906. }
  3907. if (dapt != 0)
  3908. {
  3909. if (dapt == 11)
  3910. {
  3911. nextda = 37;
  3912. opt = "流转市场管理科";
  3913. }
  3914. else if (dapt == 14)
  3915. {
  3916. nextda = 57;
  3917. opt = "流转营销管理处";
  3918. }
  3919. else if (dapt == 15)
  3920. {
  3921. nextda = 74;
  3922. opt = "流转策划推广";
  3923. }
  3924. else if (dapt == 16)
  3925. {
  3926. nextda = 88;
  3927. opt = "流转销售部";
  3928. }
  3929. }
  3930. if (nextda != 0)
  3931. {
  3932. var res = AssignWO(ua, model, input, opt, "", nextda, 0, model.F_limit, 0);
  3933. if (res)
  3934. return Success("保存成功");
  3935. else
  3936. return Error("流转失败!");
  3937. }
  3938. else
  3939. {
  3940. return Error("流转失败!");
  3941. }
  3942. }
  3943. return Success("保存成功!");
  3944. }
  3945. else
  3946. return Error("保存失败!");
  3947. }
  3948. else
  3949. {
  3950. return Error("OpenId不能为空!!");
  3951. }
  3952. }
  3953. public void WriteWorkOrderLog(string WorkOrderID, string UserCode, int IsDelete, string DelUserCode, int TypeId, string Remark)
  3954. {
  3955. var model = new Model.T_Wo_WorkOrder_Logs();
  3956. model.WorkOrderID = WorkOrderID; //工单编号
  3957. model.UserCode = UserCode; //修改人code
  3958. model.AddTime = DateTime.Now; //添加时间
  3959. model.IsDelete = IsDelete; //是否删除(0正常1删除)
  3960. model.DelUserCode = DelUserCode; //删除人code
  3961. model.TypeId = TypeId; //类型(0添加,1修改)
  3962. model.Remark = Remark; //备注
  3963. blllogs.Add(model);
  3964. }
  3965. /// <summary>
  3966. /// 添加工单记录
  3967. /// </summary>
  3968. 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)
  3969. {
  3970. Model.T_Wo_WorkOrderItem_New itemModel = new Model.T_Wo_WorkOrderItem_New();
  3971. #region
  3972. //处理当前工单的记录之前的记录过期
  3973. var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_ItemType=" + itemtype + " and F_WoID=" + woid + " ");
  3974. if (F_IsUsed==0)
  3975. {
  3976. if (itemlast.Count > 0)
  3977. {
  3978. foreach (var it in itemlast)
  3979. {
  3980. it.F_IsUsed = 1;
  3981. it.F_LimitTime = overtime.ToString();
  3982. itembll.Update(it);
  3983. }
  3984. }
  3985. }
  3986. #endregion
  3987. itemModel.F_WoID = woid;
  3988. itemModel.F_IsSMS = sms;
  3989. itemModel.F_WoState = wostate;
  3990. itemModel.F_ItemType = itemtype;
  3991. itemModel.F_OptType = opttype;
  3992. itemModel.F_OptContent = content;
  3993. itemModel.F_NextUser = nextuser;
  3994. itemModel.F_NextDept = nextdept;
  3995. itemModel.F_IsUsed = F_IsUsed;
  3996. itemModel.F_LimitTime = overtime.ToString();
  3997. if (nowUser!=null )
  3998. {
  3999. itemModel.F_CreateUser = nowUser.F_UserCode;
  4000. }
  4001. else
  4002. {
  4003. itemModel.F_CreateUser = "";
  4004. }
  4005. if (create!="" )
  4006. {
  4007. itemModel.F_CreateTime =DateTime .Parse ( create);
  4008. }
  4009. else
  4010. {
  4011. itemModel.F_CreateTime = DateTime.Now;
  4012. }
  4013. var res = itembll.Add(itemModel);
  4014. return res;
  4015. }
  4016. #region
  4017. //workorder.WoBillController blcon = new WoBillController();
  4018. ///// <summary>
  4019. ///// 获取所有业务
  4020. ///// </summary>
  4021. ///// <returns></returns>
  4022. //[WechatActionFilter]
  4023. //public ActionResult GetBusList()
  4024. //{
  4025. // var list = blcon.GetBusAllList();
  4026. // return Success("获取信息列表成功", list);
  4027. //}
  4028. ///// <summary>
  4029. ///// 获取业务内容
  4030. ///// </summary>
  4031. ///// <returns></returns>
  4032. //[WechatActionFilter]
  4033. //public ActionResult GetBusInfo()
  4034. //{
  4035. // string strbusid = HttpUtility.UrlDecode(RequestString.GetQueryString("busid"));
  4036. // if (string.IsNullOrEmpty(strbusid))
  4037. // return Error("参数错误");
  4038. // var model = blcon.GetBusInfo(strbusid);
  4039. // if (model != null)
  4040. // return Success("获取信息成功", model);
  4041. // else
  4042. // return Error("获取信息失败");
  4043. //}
  4044. ///// <summary>
  4045. ///// 获取开票列表
  4046. ///// </summary>
  4047. ///// <returns></returns>
  4048. //[WechatActionFilter]
  4049. //public ActionResult GetBillList()
  4050. //{
  4051. // DataTable dt = new DataTable();
  4052. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4053. // string strbtime = HttpUtility.UrlDecode(RequestString.GetQueryString("btime"));
  4054. // string stretime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));
  4055. // string strpageindex = RequestString.GetQueryString("pageindex");
  4056. // int pageindex = 1;
  4057. // string strpagesize = RequestString.GetQueryString("pagesize");
  4058. // int pagesize = 10;
  4059. // if (strpageindex.Trim() != "")
  4060. // {
  4061. // pageindex = Convert.ToInt32(strpageindex);
  4062. // }
  4063. // if (strpagesize.Trim() != "")
  4064. // {
  4065. // pagesize = Convert.ToInt32(strpagesize);
  4066. // }
  4067. // var obj=blcon.GetLists(stropenid, strbtime, stretime, pageindex, pagesize);
  4068. // return Content(obj.ToJson());
  4069. //}
  4070. ///// <summary>
  4071. ///// 获取开票详情
  4072. ///// </summary>
  4073. ///// <returns></returns>
  4074. //[WechatActionFilter]
  4075. //public ActionResult GetBillInfo()
  4076. //{
  4077. // string strbillid = HttpUtility.UrlDecode(RequestString.GetQueryString("billid"));
  4078. // if (string.IsNullOrEmpty(strbillid))
  4079. // return Error("参数错误");
  4080. // var model = blcon.GetBillInfo(strbillid);
  4081. // if (model != null)
  4082. // return Success("获取信息成功", model);
  4083. // else
  4084. // return Error("获取信息失败");
  4085. //}
  4086. ///// <summary>
  4087. ///// 开票
  4088. ///// </summary>
  4089. ///// <returns></returns>
  4090. //[WechatActionFilter]
  4091. //public ActionResult AddBill()
  4092. //{
  4093. // string billtype = RequestString.GetFormString("billtype");//发票类型
  4094. // string cusname = RequestString.GetFormString("cusname");//客户名称
  4095. // string taxidnum = RequestString.GetFormString("taxidnum");//纳税人识别号
  4096. // string address = RequestString.GetFormString("address");//地址
  4097. // string phone = RequestString.GetFormString("phone");//电话
  4098. // string bank = RequestString.GetFormString("bank");//开户行
  4099. // string bankaccount = RequestString.GetFormString("bankaccount");//开户行账号
  4100. // string proname = RequestString.GetFormString("proname");//项目名称
  4101. // string models = RequestString.GetFormString("models");//型号
  4102. // string unit = RequestString.GetFormString("unit");//单位
  4103. // string amount = RequestString.GetFormString("amount");//数量
  4104. // string unitprice = RequestString.GetFormString("unitprice");//单价
  4105. // string sumprice = RequestString.GetFormString("sumprice");//金额
  4106. // string taxrate = RequestString.GetFormString("taxrate");//税率
  4107. // string taxamount = RequestString.GetFormString("taxamount");//税额
  4108. // string billingMethod = RequestString.GetFormString("billingmethod");//开票方式:快递/自取
  4109. // string billingTime = RequestString.GetFormString("billingtime");//开票时间
  4110. // string remark = RequestString.GetFormString("remark");//备注
  4111. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4112. // Model.T_Wo_Bill dModel = new Model.T_Wo_Bill();
  4113. // #region 保存基本信息
  4114. // dModel.F_BillType = billtype;
  4115. // dModel.F_CusName = cusname;
  4116. // dModel.F_TaxIDNum = taxidnum;
  4117. // dModel.F_Address = address;
  4118. // dModel.F_Phone = phone;
  4119. // dModel.F_Bank = bank;
  4120. // dModel.F_BankAccount = bankaccount;
  4121. // dModel.F_ProName = proname;
  4122. // dModel.F_Models = models;
  4123. // dModel.F_Unit = unit;
  4124. // dModel.F_Amount = amount;
  4125. // dModel.F_UnitPrice = unitprice;
  4126. // dModel.F_SumPrice = sumprice;
  4127. // dModel.F_TaxRate = taxrate;
  4128. // dModel.F_TaxAmount = taxamount;
  4129. // dModel.F_BillingMethod = billingMethod;
  4130. // dModel.F_BillingTime = billingTime;
  4131. // dModel.F_Remark = remark;
  4132. // dModel.F_Openid = stropenid;
  4133. // dModel.F_CreateOn = DateTime.Now;
  4134. // dModel.F_State = 0;
  4135. // #endregion
  4136. // var res=blcon.addbills(dModel);
  4137. // if (res)
  4138. // return Success("保存成功");
  4139. // else
  4140. // return Error("保存失败");
  4141. //}
  4142. #endregion
  4143. #region 获取公司详情
  4144. ////获取公司信息
  4145. //[WechatActionFilter]
  4146. //public ActionResult GetInfo()
  4147. //{
  4148. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4149. // if (string.IsNullOrEmpty(stropenid))
  4150. // return Error("参数错误!");
  4151. // var model=customerBaseBLL.GetModelByOpenid(stropenid);
  4152. // if (model != null)
  4153. // {
  4154. // var sqlwo = " IsDel=0 and State <>2 "; var sqlno = " F_isDel=0 ";
  4155. // var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
  4156. // var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
  4157. // if (nowUser != null)
  4158. // {
  4159. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  4160. // sqlwo += " and State =1 and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(nowUser.F_UserCode) + "') ";
  4161. // sqlno += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + nowUser.F_UserId + ",%')";
  4162. // }
  4163. // else if (nowCus != null)
  4164. // {
  4165. // sqlwo += " and ( CustomerID=" + model.F_CustomerId + " or County like '%" + model.F_CompanyName + "%' )";
  4166. // 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)";
  4167. // }
  4168. // var ordercount = woBLL.GetRecordCount(sqlwo);
  4169. // var noticecount = new BLL.T_Msg_NoticeInfo().GetRecordCount(sqlno);
  4170. // var obj = new
  4171. // {
  4172. // model.F_CompanyName,//公司名称
  4173. // model.F_CompanyLogo,//logo
  4174. // model.F_CustomerCode,//编号
  4175. // model.F_CycleStart,//服务周期-开始时间
  4176. // model.F_CycleEnd,//服务周期-结束时间
  4177. // model.F_ChargeType,//收费类型:1月度,2季度,3年度
  4178. // model.F_Charges,//收费
  4179. // model.F_TaxNumber,//公司税号
  4180. // model.F_CompanyAddress,//公司地址
  4181. // ordercount,//待处理工单数量
  4182. // noticecount,//未读公告数量
  4183. // };
  4184. // return Success("获取成功", obj);
  4185. // }
  4186. // return Error("获取失败");
  4187. //}
  4188. ////获取财税信息
  4189. ////[WechatActionFilter]
  4190. //public ActionResult GetFinc()
  4191. //{
  4192. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4193. // var model = customerBaseBLL.GetModelByOpenid(stropenid);
  4194. // if (model != null)
  4195. // {
  4196. // var finmodel = finbll.GetModelList(" F_CustomerId=" + model.F_CustomerId).FirstOrDefault();
  4197. // if (finmodel != null)
  4198. // {
  4199. // var obj = new
  4200. // {
  4201. // model.F_CompanyName,//公司名称
  4202. // model.F_CompanyLogo,//logo
  4203. // model.F_CustomerCode,//编号
  4204. // finmodel.F_CusFinId,
  4205. // finmodel.F_CustomerId,
  4206. // finmodel.F_MonthState,
  4207. // finmodel.F_AnnualIncome,
  4208. // finmodel.F_AnnualProfit,
  4209. // finmodel.F_AnnualCost,
  4210. // finmodel.F_AnnualPersonCount,
  4211. // finmodel.F_AnnualWages,
  4212. // finmodel.F_QuarterlyCost,
  4213. // finmodel.F_QuarterlyPersonCount,
  4214. // finmodel.F_QuarterlyWages,
  4215. // finmodel.F_QuarterlyIncome,
  4216. // finmodel.F_QPVAT,
  4217. // finmodel.F_QPSurtax,
  4218. // finmodel.F_QPTaxes,
  4219. // finmodel.F_QPConTax,
  4220. // finmodel.F_QPPerinTax,
  4221. // finmodel.F_QPStampTax,
  4222. // finmodel.F_QPOtherTax
  4223. // };
  4224. // return Success("获取成功", obj);
  4225. // }
  4226. // }
  4227. // return Error("获取失败");
  4228. //}
  4229. #endregion
  4230. #region 工单
  4231. /// <summary>
  4232. /// 工单列表
  4233. /// </summary>
  4234. [WechatActionFilter]
  4235. public ActionResult GetWoList()
  4236. {
  4237. workorder.WorkOrderController wo = new workorder.WorkOrderController();
  4238. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
  4239. int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
  4240. DataTable dt = new DataTable();
  4241. int recordCount = 0;
  4242. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4243. //客户姓名,电话,工单号
  4244. string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  4245. //工单状态
  4246. int states = RequestString.GetInt("states", -1);
  4247. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4248. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4249. string strpageindex = RequestString.GetQueryString("page");
  4250. int pageindex = 1;
  4251. string strpagesize = RequestString.GetQueryString("pagesize");
  4252. int pagesize = 10;
  4253. //#region sql 语句相关处理
  4254. string sql = " ";
  4255. //获取坐席表信息
  4256. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  4257. //获取客户档案(业主)表信息
  4258. var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  4259. if (!string.IsNullOrEmpty(sql))
  4260. {
  4261. //sql += " and IsDel=0 ";
  4262. ////客户姓名,电话,房间号,工单号,接待描述
  4263. //if (!string.IsNullOrEmpty(keyword))
  4264. //{
  4265. // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' or County like '%" + keyword + "%' ) ";
  4266. //}
  4267. //if (states >= 0)
  4268. //{
  4269. // #region 权限限制
  4270. // if (ua != null)
  4271. // {
  4272. // string uwhere = " ";
  4273. // switch (states)
  4274. // {
  4275. // case 0://待指派的
  4276. // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
  4277. // //3区域客服可以看到区域待指派工单
  4278. // if (ua.F_RoleId != 17)
  4279. // {
  4280. // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  4281. // }
  4282. // sql += " and State =0 " + uwhere;
  4283. // break;
  4284. // case 1://待接单的
  4285. // sql += " and State =" + (int)EnumWorkOrderState.assign + " and T_Wo_WorkOrder.ID in ( " + wo.GetDJDWorkOrderID(ua.F_UserCode) + ") ";
  4286. // break;
  4287. // case 2://待完成的(待处理)
  4288. // 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) + ") ";
  4289. // break;
  4290. // case 3://已完成的
  4291. // sql += " and State =" + (int)EnumWorkOrderState.finish + " and LastDealUser = '" + ua.F_UserCode + "' ";
  4292. // break;
  4293. // case 4://我参与的
  4294. // sql += " and (CreateUser= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.ID in ( " + wo.GetCYWorkOrderID(ua.F_UserCode) + ")) ";
  4295. // break;
  4296. // case 5://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
  4297. // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < " + (int)EnumWorkOrderState.finish + " ";
  4298. // break;
  4299. // }
  4300. // }
  4301. // else if (modelCustomer != null)
  4302. // {
  4303. // sql += " and ( CustomerID=" + modelCustomer.F_CustomerId + " or County like '%"+modelCustomer.F_CompanyName+"%' )";
  4304. // }
  4305. // else
  4306. // {
  4307. // sql = "";
  4308. // }
  4309. // #endregion
  4310. //}
  4311. //if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4312. //{
  4313. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  4314. //}
  4315. //if (strendtime.Trim() != "" && strendtime != "undefined")
  4316. //{
  4317. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  4318. //}
  4319. //#endregion
  4320. //if (strpageindex.Trim() != "")
  4321. //{
  4322. // pageindex = Convert.ToInt32(strpageindex);
  4323. //}
  4324. //if (strpagesize.Trim() != "")
  4325. //{
  4326. // pagesize = Convert.ToInt32(strpagesize);
  4327. //}
  4328. //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";
  4329. //dt = BLL.PagerBLL.GetListPager(
  4330. // "T_Wo_WorkOrder (NOLOCK)",
  4331. // "WorkOrderID",
  4332. // cols,
  4333. // sql,
  4334. // "ORDER BY CreateTime DESC,State asc",
  4335. // pagesize,
  4336. // pageindex,
  4337. // true,
  4338. // out recordCount);
  4339. }
  4340. var obj = new
  4341. {
  4342. state = "success",
  4343. message = "成功",
  4344. rows = dt,
  4345. total = recordCount
  4346. };
  4347. return Content(obj.ToJson());
  4348. }
  4349. /// <summary>
  4350. /// 工单详情
  4351. /// </summary>
  4352. [WechatActionFilter]
  4353. public ActionResult GetWoInfo()
  4354. {
  4355. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  4356. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4357. if (string.IsNullOrEmpty(strworkorderid))
  4358. return Error("参数错误");
  4359. if (string.IsNullOrEmpty(stropenid))
  4360. return Error("参数错误!");
  4361. //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 "
  4362. // + " from T_Wo_WorkOrder where T_Wo_WorkOrder.ID ='" + strworkorderid + "' ";
  4363. //var dt = DbHelperSQL.Query(sql).Tables[0];
  4364. //if (dt.Rows.Count > 0)
  4365. //{
  4366. // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  4367. // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  4368. // if (configfj != null)
  4369. // {
  4370. // dt = BindFileData(dt, configfj.F_ParamValue);
  4371. // }
  4372. // string gcsql = "select *,dbo.GetUserName(F_NextUser) as F_NextUserName, dbo.GetDeptName(F_NextDept) as F_NextDeptName,dbo.GetUserName(F_CreateUser) as F_CreateUserName "
  4373. // + "from T_Wo_WorkOrderItem_New where F_WoID ='" + strworkorderid + "'";
  4374. // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  4375. // dt.Columns.Add("FilePath", typeof(string));
  4376. // if (configfj != null || config != null)
  4377. // {
  4378. // foreach (DataRow bldr in dt.Rows)
  4379. // {
  4380. // if (bldr["CallID"] != null && config != null)
  4381. // {
  4382. // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
  4383. // }
  4384. // }
  4385. // }
  4386. // var obj = new
  4387. // {
  4388. // data = dt,
  4389. // item = gcdt
  4390. // };
  4391. // return Success("查询成功", obj);
  4392. //}
  4393. return Error("查询失败");
  4394. }
  4395. #region 在用工单操作
  4396. ///// <summary>
  4397. ///// 处理工单
  4398. ///// </summary>
  4399. ///// <returns></returns>
  4400. //[WechatActionFilter]
  4401. //public ActionResult DealWorkOrder(long orderid, string cont, int isover = 0)
  4402. //{
  4403. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4404. // if (!string.IsNullOrEmpty(stropenid))
  4405. // {
  4406. // Model.T_Sys_UserAccount ua = userAccountBLL.GetModelByOpenid(stropenid);
  4407. // if (ua != null)
  4408. // {
  4409. // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  4410. // if (model != null)
  4411. // {
  4412. // bool res = new workorder.WorkOrderController().DealWO(ua, model, cont, isover);
  4413. // if (res)
  4414. // return Success("处理成功");
  4415. // else
  4416. // return Error("操作失败");
  4417. // }
  4418. // else
  4419. // return Error("工单不存在");
  4420. // }
  4421. // else
  4422. // return Error("无操作权限");
  4423. // }
  4424. // else
  4425. // return Error("参数错误");
  4426. //}
  4427. ///// <summary>
  4428. ///// 接单 - 确认工单
  4429. ///// </summary>
  4430. ///// <returns></returns>
  4431. //[WechatActionFilter]
  4432. //public ActionResult SureWorkOrder(long orderid)
  4433. //{
  4434. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4435. // if (!string.IsNullOrEmpty(stropenid))
  4436. // {
  4437. // var ua = userAccountBLL.GetModelByOpenid(stropenid);
  4438. // if (ua != null)
  4439. // {
  4440. // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  4441. // if (model != null)
  4442. // {
  4443. // bool res = new workorder.WorkOrderController().SureWO(ua, model);
  4444. // if (res)
  4445. // return Success("接单成功");
  4446. // else
  4447. // return Error("操作失败");
  4448. // }
  4449. // else
  4450. // return Error("工单不存在");
  4451. // }
  4452. // else
  4453. // return Error("无操作权限");
  4454. // }
  4455. // else
  4456. // return Error("参数错误");
  4457. //}
  4458. ///// <summary>
  4459. ///// 指派/转派工单
  4460. ///// </summary>
  4461. ///// <returns></returns>
  4462. //[WechatActionFilter]
  4463. //public ActionResult AssignWorkOrder(long orderid, string cont, int clbm = 0, int clid = 0)
  4464. //{
  4465. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4466. // if (!string.IsNullOrEmpty(stropenid))
  4467. // {
  4468. // var ua = userAccountBLL.GetModelByOpenid(stropenid);
  4469. // if (ua != null)
  4470. // {
  4471. // if (clbm != 0 && clid == 0)
  4472. // return Error("请选择接收人");
  4473. // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  4474. // if (model != null)
  4475. // {
  4476. // var res = new workorder.WorkOrderController().AssignWO(ua, model, cont, clbm, clid);
  4477. // if (res)
  4478. // return Success("转派成功");
  4479. // else
  4480. // return Error("转派失败!");
  4481. // }
  4482. // else
  4483. // return Error("工单不存在!");
  4484. // }
  4485. // }
  4486. // return Error("无操作权限!");
  4487. //}
  4488. ///// <summary>
  4489. ///// 退回工单
  4490. ///// </summary>
  4491. ///// <param name="input"></param>
  4492. ///// <returns></returns>
  4493. //[WechatActionFilter]
  4494. //public ActionResult BackWorkOrder(long orderid, string cont,int type=0)
  4495. //{//办理人员和监管可以退回工单
  4496. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4497. // if (!string.IsNullOrEmpty(stropenid))
  4498. // {
  4499. // var ua = userAccountBLL.GetModelByOpenid(stropenid);
  4500. // if (ua != null)
  4501. // {
  4502. // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  4503. // //验证信息
  4504. // if (model != null)
  4505. // {
  4506. // var res = new workorder.WorkOrderController().BackWO(ua, model, cont, type);
  4507. // if (res)
  4508. // return Success("处理成功");
  4509. // else
  4510. // return Error("处理失败!");
  4511. // }
  4512. // return Error("工单不存在");
  4513. // }
  4514. // }
  4515. // return Error("无操作权限");
  4516. //}
  4517. ///// <summary>
  4518. ///// 催办工单
  4519. ///// </summary>
  4520. ///// <returns></returns>
  4521. //[WechatActionFilter]
  4522. //public ActionResult AddWorkOrderRemind(long orderid, string cont)
  4523. //{
  4524. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  4525. // if (!string.IsNullOrEmpty(stropenid))
  4526. // {
  4527. // var ua = userAccountBLL.GetModelByOpenid(stropenid);
  4528. // if (ua != null)
  4529. // {
  4530. // Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  4531. // if (model != null)
  4532. // {
  4533. // var res = new workorder.WorkOrderController().RemindWO(ua, model, cont);
  4534. // if (res)
  4535. // Success("催办成功!");
  4536. // else
  4537. // Success("操作失败!");
  4538. // }
  4539. // return Error("工单不存在!");
  4540. // }
  4541. // }
  4542. // return Error("无操作权限!");
  4543. //}
  4544. #endregion
  4545. #endregion
  4546. #region 公告通知
  4547. /// <summary>
  4548. /// 获取公告列表
  4549. /// </summary>
  4550. /// <returns></returns>
  4551. //[WechatActionFilter]
  4552. public ActionResult GetNoticeList()
  4553. {
  4554. DataTable dt = new DataTable(); int recordCount = 0;
  4555. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4556. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4557. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4558. string strpageindex = RequestString.GetQueryString("page");
  4559. int pageindex = 1;
  4560. string strpagesize = RequestString.GetQueryString("pagesize");
  4561. int pagesize = 10;
  4562. #region sql 语句相关处理
  4563. string sql = " and F_isDel=0 ";
  4564. //获取坐席表信息
  4565. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  4566. //获取客户档案(业主)表信息
  4567. var modelCustomer = customerBaseBLL.GetModelByOpenid(stropenid);
  4568. if (ua != null)
  4569. {
  4570. sql += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + ua.F_UserId + ",%')";
  4571. }
  4572. else if (modelCustomer != null) {
  4573. sql += " and F_isCus=1";
  4574. }
  4575. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4576. {
  4577. sql += " and datediff(day,F_CreateOn,'" + strstarttime + "')<=0 ";
  4578. }
  4579. if (strendtime.Trim() != "" && strendtime != "undefined")
  4580. {
  4581. sql += " and datediff(day,F_CreateOn,'" + strendtime + "')>=0 ";
  4582. }
  4583. #endregion
  4584. if (strpageindex.Trim() != "")
  4585. {
  4586. pageindex = Convert.ToInt32(strpageindex);
  4587. }
  4588. if (strpagesize.Trim() != "")
  4589. {
  4590. pagesize = Convert.ToInt32(strpagesize);
  4591. }
  4592. dt = BLL.PagerBLL.GetListPager(
  4593. "T_Msg_NoticeInfo",
  4594. "F_NoticeId",
  4595. "*",
  4596. sql,
  4597. "ORDER BY F_NoticeId desc",
  4598. pagesize,
  4599. pageindex,
  4600. true,
  4601. out recordCount);
  4602. List<Model.T_Msg_NoticeInfo> msgList = new BLL.T_Msg_NoticeInfo().DataTableToList(dt);
  4603. List<Model.T_Sys_UserAccount> userList = new BLL.T_Sys_UserAccount().GetModelList("");
  4604. var obj = new
  4605. {
  4606. rows = msgList.Select(m =>
  4607. {
  4608. Model.T_Sys_UserAccount usermodel = userList.Where(u => u.F_UserId == m.F_CreateBy.Value).FirstOrDefault();
  4609. var uname = "";
  4610. if (usermodel != null)
  4611. uname = usermodel.F_UserName;
  4612. return new
  4613. {
  4614. F_NoticeId = m.F_NoticeId,
  4615. F_Title = m.F_Title,
  4616. F_Content = m.F_Content,
  4617. F_isCus = m.F_isCus,
  4618. F_CreateOn = m.F_CreateOn,
  4619. F_CreateBy = m.F_CreateBy,
  4620. F_CreateByName = uname
  4621. };
  4622. }),
  4623. total = recordCount
  4624. };
  4625. return Content(obj.ToJson());
  4626. }
  4627. /// <summary>
  4628. /// 获取公告详情
  4629. /// </summary>
  4630. /// <returns></returns>
  4631. //[WechatActionFilter]
  4632. public ActionResult GetNoticeInfo()
  4633. {
  4634. string strnoticeid = HttpUtility.UrlDecode(RequestString.GetQueryString("noticeid"));
  4635. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4636. if (string.IsNullOrEmpty(strnoticeid))
  4637. return Error("参数错误");
  4638. if (string.IsNullOrEmpty(stropenid))
  4639. return Error("参数错误!");
  4640. var dModel = new BLL.T_Msg_NoticeInfo().GetModel(int.Parse(strnoticeid.Trim()));
  4641. Model.T_Sys_UserAccount userModel = new Model.T_Sys_UserAccount();
  4642. if (dModel != null)
  4643. {
  4644. if (dModel.F_CreateBy != null)
  4645. userModel = userAccountBLL.GetModel(dModel.F_CreateBy.Value);
  4646. var uname = "";
  4647. if (userModel != null)
  4648. uname = userModel.F_UserName;
  4649. #region 标记为已读
  4650. var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
  4651. var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
  4652. var usercode = "";
  4653. if (nowUser != null)
  4654. {
  4655. usercode = nowUser.F_UserCode;
  4656. var msglist = new BLL.T_Msg_List().GetModelList(" State=0 and ToUser='" + usercode + "' and Type=5 and ToID=" + dModel.F_NoticeId);
  4657. foreach (var item in msglist)
  4658. {
  4659. item.State = 1;
  4660. item.ReadDate = DateTime.Now;
  4661. new BLL.T_Msg_List().Update(item);
  4662. }
  4663. }
  4664. else if (nowCus != null)
  4665. {
  4666. usercode = nowCus.F_CustomerCode;
  4667. Model.T_Msg_List msg = new Model.T_Msg_List();
  4668. msg.Type = (int)Model.MSGType.cusnotice;
  4669. msg.ToUser = usercode;
  4670. msg.ToID = dModel.F_NoticeId;
  4671. msg.Detail = "客户" + usercode + "查看了公告《" + dModel.F_Title + "》";
  4672. msg.State = 1;
  4673. msg.IsDel = 0;
  4674. msg.CreateDate = DateTime.Now;
  4675. msg.ReadDate = DateTime.Now;
  4676. new BLL.T_Msg_List().Add(msg);
  4677. }
  4678. #endregion
  4679. var obj = new
  4680. {
  4681. F_NoticeId = dModel.F_NoticeId,
  4682. F_Title = dModel.F_Title,
  4683. F_Content = dModel.F_Content,
  4684. F_isCus = dModel.F_isCus,
  4685. F_CreateOn = dModel.F_CreateOn,
  4686. F_CreateBy = dModel.F_CreateBy,
  4687. F_CreateByName = uname,
  4688. F_UserId = dModel.F_UserId,
  4689. F_RoleId = dModel.F_RoleId,
  4690. };
  4691. return Success("获取公告详情成功", dModel);
  4692. }
  4693. else
  4694. return Error("获取公告详情失败");
  4695. }
  4696. #endregion
  4697. #region 微信工单
  4698. ///// <summary>
  4699. ///// 获取工单列表
  4700. ///// </summary>
  4701. ///// <returns></returns>
  4702. //[WechatActionFilter]
  4703. //public ActionResult GetList()
  4704. //{
  4705. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  4706. // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
  4707. // int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
  4708. // DataTable dt = new DataTable();
  4709. // int recordCount = 0;
  4710. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4711. // //客户姓名,电话,房间号,工单号
  4712. // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  4713. // //工单状态(ltype:)
  4714. // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
  4715. // //工单状态
  4716. // int states = RequestString.GetInt("states", -1);
  4717. // //工单来源
  4718. // int strtype = RequestString.GetInt("type", 0);
  4719. // //工单类型
  4720. // int strtypeclass = RequestString.GetInt("typeclass", 0);
  4721. // //工单起止时间
  4722. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4723. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4724. // //来电单位
  4725. // string lddep = HttpUtility.UrlDecode(RequestString.GetQueryString("lddep"));
  4726. // //20180329 来电弹屏工单记录根据反馈单位获取列表 可以看到同一坐席组的所有人的工单记录
  4727. // string fkdep = HttpUtility.UrlDecode(RequestString.GetQueryString("fkdep"));
  4728. // int isldtp = RequestString.GetQueryInt("isldtp", 0);
  4729. // //微信列表(0未审核微信列表,1已审核微信列表)
  4730. // int isaudit = RequestString.GetInt("isaudit", -1);
  4731. // string strpageindex = RequestString.GetQueryString("page");
  4732. // int pageindex = 1;
  4733. // string strpagesize = RequestString.GetQueryString("pagesize");
  4734. // int pagesize = 10;
  4735. // #region sql 语句相关处理
  4736. // string sql = " ";
  4737. // //获取坐席表信息
  4738. // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  4739. // //获取客户档案(业主)表信息
  4740. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  4741. // #region 权限限制
  4742. // string mobile = "", roomno = "";
  4743. // int customerid = 0, areaid = 0, proid = 0, buildingid = 0;
  4744. // if (ua != null)
  4745. // {
  4746. // int deptid = ua.F_DeptId; //部门id
  4747. // string deptCode = ua.F_DeptCode; //部门code
  4748. // int userRegionId = ua.RegionId; //项目id
  4749. // //部门信息
  4750. // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  4751. // int depType = 0, depRegion = 0;
  4752. // if (modelDep != null)
  4753. // {
  4754. // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  4755. // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  4756. // }
  4757. // if (ua.F_RoleId != 17)
  4758. // {
  4759. // if (depType == 2)
  4760. // {
  4761. // if (depRegion == 1)
  4762. // {
  4763. // // 查看该区域工单
  4764. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  4765. // sql += $" and IsUserSend = {userRegionId} ";
  4766. // }
  4767. // else if (depRegion == 2)
  4768. // {
  4769. // // 查看该项目工单
  4770. // sql += $" and IsAdminSend = {userRegionId} ";
  4771. // }
  4772. // }
  4773. // else if (depType == 3)
  4774. // {
  4775. // if (depRegion == 1)
  4776. // {
  4777. // // 查看该区域工单
  4778. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  4779. // sql += $" and IsUserSend = {userRegionId} ";
  4780. // }
  4781. // }
  4782. // else if (depType == 4)
  4783. // {
  4784. // if (depRegion == 2)
  4785. // {
  4786. // // 查看该项目工单
  4787. // sql += $" and IsAdminSend = {userRegionId} ";
  4788. // }
  4789. // else if (depRegion == 9)
  4790. // {
  4791. // // 查看该部门工单(包括一级,二级)
  4792. // string deptCodeNew = String.Empty;
  4793. // int deptCodeIndex = 0; //变量声明
  4794. // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  4795. // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  4796. // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  4797. // //============== 部门权限条件 - 部门 ================
  4798. // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  4799. // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
  4800. // }
  4801. // }
  4802. // }
  4803. // string uwhere = " ";
  4804. // switch (strltype)
  4805. // {
  4806. // case "0"://待指派的
  4807. // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
  4808. // if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
  4809. // {
  4810. // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  4811. // }
  4812. // sql += " and State ='0' " + uwhere;
  4813. // break;
  4814. // case "1"://待接单的
  4815. // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDJDWorkOrderID(ua.F_UserCode) + "') ";
  4816. // break;
  4817. // case "2"://待完成的
  4818. // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(ua.F_UserCode) + "') ";
  4819. // break;
  4820. // case "3"://已完成的
  4821. // sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
  4822. // break;
  4823. // case "4"://我参与的
  4824. // sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + wo.GetCYWorkOrderID(ua.F_UserCode) + "')) ";
  4825. // break;
  4826. // case "5"://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
  4827. // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
  4828. // break;
  4829. // }
  4830. // }
  4831. // else if (modelCustomer != null)
  4832. // {
  4833. // #region 根据openid获取所有工单号
  4834. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  4835. // //if (wxuser != null)
  4836. // //{
  4837. // // sql += " and id in (select distinct F_WorkOrderID from T_WO_UserWorkOrder where F_UserId='" + wxuser.F_Id + "') ";
  4838. // //}
  4839. // #endregion
  4840. // // ============== 项目权限 - 项目 ============== 不通过项目查询,因为客户可能有多个项目的房产
  4841. // // ============== 电话,区域,项目,楼号,房间号权限条件 - 电话 ================
  4842. // //通过相关电话,区域,项目,楼号,房间号(CustomerTel,IsUserSend,IsAdminSend,IsTimeOut,Address)查询该用户查看的工单
  4843. // //mobile = modelCustomer.F_LegalTel;
  4844. // customerid = modelCustomer.F_CustomerId;
  4845. // //int CustomerClassID = modelCustomer.F_CustomerClassID ?? 0;
  4846. // ////F_Layer区域id F_CategoryId所购项目id F_CustomerType楼号 F_BusinessLicenseID房间号
  4847. // //areaid = modelCustomer.F_Layer ?? 0;
  4848. // //proid = modelCustomer.F_CategoryId ?? 0;
  4849. // //buildingid = modelCustomer.F_CustomerType ?? 0;
  4850. // //roomno = modelCustomer.F_BusinessLicenseID;
  4851. // ////查询业主和相关的亲属租户名下工单
  4852. // //sql += $" and CustomerTel IN (SELECT DISTINCT F_Mobile FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
  4853. // //if (CustomerClassID == 0)
  4854. // //{
  4855. // // //业主查看房屋所有工单
  4856. // // sql += $" and CustomerID IN (SELECT DISTINCT F_CustomerId FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
  4857. // //}
  4858. // //else
  4859. // //{
  4860. // // //租户只可查看自己工单
  4861. // // sql += $" and CustomerID = {customerid} ";
  4862. // //}
  4863. // ////查询相关房间号下工单
  4864. // //if (areaid > 0 && proid > 0 && buildingid > 0 && !string.IsNullOrEmpty(roomno))
  4865. // //{
  4866. // // sql += $" and F_Layer = {areaid} and F_CategoryId = {proid} and F_CustomerType = {buildingid} and F_BusinessLicenseID = '{roomno}' ";
  4867. // //}
  4868. // }
  4869. // else
  4870. // {
  4871. // sql = "";
  4872. // }
  4873. // #endregion
  4874. // if (!string.IsNullOrEmpty(sql))
  4875. // {
  4876. // sql += " and IsDel=0 ";
  4877. // //客户姓名,电话,房间号,工单号,接待描述
  4878. // if (!string.IsNullOrEmpty(keyword))
  4879. // {
  4880. // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' ) ";
  4881. // }
  4882. // if (isaudit >= 0)
  4883. // {
  4884. // sql += " and IsAudit = " + isaudit + " "; // ANd Type = (SELECT F_DictionaryValueId FROM dbo.T_Sys_DictionaryValue (NOLOCK) WHERE F_DictionaryFlag = 'GDLY' AND F_Name = '微信')
  4885. // }
  4886. // if (states >= 0)
  4887. // sql += " and State = " + states + " ";
  4888. // if (strtype > 0)
  4889. // {
  4890. // sql += " and Type = " + strtype + " ";
  4891. // }
  4892. // if (strtypeclass > 0)
  4893. // {
  4894. // sql += " and TypeClass = " + strtypeclass + " ";
  4895. // }
  4896. // if (lddep.Trim() != "" && lddep != "undefined")
  4897. // {
  4898. // sql += " and Address = '" + lddep.Trim() + "' ";
  4899. // }
  4900. // if (fkdep.Trim() != "" && fkdep != "undefined")
  4901. // {
  4902. // sql += " and Source = '" + fkdep.Trim() + "' ";
  4903. // }
  4904. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  4905. // {
  4906. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  4907. // }
  4908. // if (strendtime.Trim() != "" && strendtime != "undefined")
  4909. // {
  4910. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  4911. // }
  4912. // #endregion
  4913. // if (strpageindex.Trim() != "")
  4914. // {
  4915. // pageindex = Convert.ToInt32(strpageindex);
  4916. // }
  4917. // if (strpagesize.Trim() != "")
  4918. // {
  4919. // pagesize = Convert.ToInt32(strpagesize);
  4920. // }
  4921. // 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";
  4922. // dt = BLL.PagerBLL.GetListPager(
  4923. // "T_Wo_WorkOrder (NOLOCK)",
  4924. // "WorkOrderID",
  4925. // cols,
  4926. // sql,
  4927. // "ORDER BY CreateTime DESC",
  4928. // pagesize,
  4929. // pageindex,
  4930. // true,
  4931. // out recordCount);
  4932. // }
  4933. // var obj = new
  4934. // {
  4935. // state = "success",
  4936. // message = "成功",
  4937. // rows = dt,
  4938. // total = recordCount
  4939. // };
  4940. // return Content(obj.ToJson());
  4941. //}
  4942. ///// <summary>
  4943. ///// 获取可催办工单列表
  4944. ///// </summary>
  4945. ///// <returns></returns>
  4946. //[WechatActionFilter]
  4947. //public ActionResult GetNotDoneWorkList()
  4948. //{
  4949. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  4950. // DataTable dt = new DataTable();
  4951. // int recordCount = 0;
  4952. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  4953. // //客户姓名,电话,房间号,工单号
  4954. // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  4955. // //工单状态
  4956. // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
  4957. // //工单状态
  4958. // int states = RequestString.GetInt("states", -1);
  4959. // //工单来源
  4960. // int strtype = RequestString.GetInt("type", 0);
  4961. // //工单类型
  4962. // int strtypeclass = RequestString.GetInt("typeclass", 0);
  4963. // //工单起止时间
  4964. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  4965. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  4966. // //区域id
  4967. // int areaid = RequestString.GetInt("areaid", 0);
  4968. // //项目id
  4969. // int regionid = RequestString.GetInt("regionid", 0);
  4970. // //期id
  4971. // int buldingid = RequestString.GetInt("buldingid", 0);
  4972. // string uid = HttpUtility.UrlDecode(RequestString.GetQueryString("userid") == "" ? "0" : HttpUtility.UrlDecode(RequestString.GetQueryString("userid")));
  4973. // string strpageindex = RequestString.GetQueryString("page");
  4974. // int pageindex = 1;
  4975. // string strpagesize = RequestString.GetQueryString("pagesize");
  4976. // int pagesize = 10;
  4977. // string sql = " and isdel=0 and State != 2 ";
  4978. // //获取坐席表信息
  4979. // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  4980. // //获取客户档案(业主)表信息
  4981. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  4982. // if (ua != null)
  4983. // {
  4984. // #region 权限限制
  4985. // int deptid = ua.F_DeptId; //部门id
  4986. // string deptCode = ua.F_DeptCode; //部门code
  4987. // int userRegionId = ua.RegionId; //项目id
  4988. // //部门信息
  4989. // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  4990. // int depType = 0, depRegion = 0;
  4991. // if (modelDep != null)
  4992. // {
  4993. // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  4994. // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  4995. // }
  4996. // if (ua.F_RoleId != 17)
  4997. // {
  4998. // if (depType == 2)
  4999. // {
  5000. // if (depRegion == 1)
  5001. // {
  5002. // // 查看该区域工单
  5003. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  5004. // sql += $" and IsUserSend = {userRegionId} ";
  5005. // }
  5006. // else if (depRegion == 2)
  5007. // {
  5008. // // 查看该项目工单
  5009. // sql += $" and IsAdminSend = {userRegionId} ";
  5010. // }
  5011. // }
  5012. // else if (depType == 3)
  5013. // {
  5014. // if (depRegion == 1)
  5015. // {
  5016. // // 查看该区域工单
  5017. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  5018. // sql += $" and IsUserSend = {userRegionId} ";
  5019. // }
  5020. // }
  5021. // else if (depType == 4)
  5022. // {
  5023. // if (depRegion == 2)
  5024. // {
  5025. // // 查看该项目工单
  5026. // sql += $" and IsAdminSend = {userRegionId} ";
  5027. // }
  5028. // else if (depRegion == 9)
  5029. // {
  5030. // // 查看该部门工单(包括一级,二级)
  5031. // string deptCodeNew = String.Empty;
  5032. // int deptCodeIndex = 0; //变量声明
  5033. // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  5034. // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  5035. // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  5036. // //============== 部门权限条件 - 部门 ================
  5037. // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  5038. // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
  5039. // }
  5040. // }
  5041. // }
  5042. // #endregion
  5043. // //客户姓名,电话,房间号,工单号
  5044. // if (!string.IsNullOrEmpty(keyword))
  5045. // {
  5046. // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' ) ";
  5047. // }
  5048. // if (states >= 0)
  5049. // sql += " and State = " + states + " ";
  5050. // if (areaid > 0)
  5051. // sql += " and IsUserSend = " + areaid + " ";
  5052. // if (regionid > 0)
  5053. // sql += " and IsAdminSend = " + regionid + " ";
  5054. // if (buldingid > 0)
  5055. // sql += " and IsTimeOut = " + buldingid + " ";
  5056. // //坐席工号
  5057. // if (uid.Trim() != "" && uid != "0")
  5058. // {
  5059. // sql += " and CreateUser = '" + uid + "' ";
  5060. // }
  5061. // if (strtype > 0)
  5062. // {
  5063. // sql += " and Type = " + strtype + " ";
  5064. // }
  5065. // if (strtypeclass > 0)
  5066. // {
  5067. // sql += " and TypeClass = " + strtype + " ";
  5068. // }
  5069. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  5070. // {
  5071. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  5072. // }
  5073. // if (strendtime.Trim() != "" && strendtime != "undefined")
  5074. // {
  5075. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  5076. // }
  5077. // if (strpageindex.Trim() != "")
  5078. // {
  5079. // pageindex = Convert.ToInt32(strpageindex);
  5080. // }
  5081. // if (strpagesize.Trim() != "")
  5082. // {
  5083. // pagesize = Convert.ToInt32(strpagesize);
  5084. // }
  5085. // dt = BLL.PagerBLL.GetListPager(
  5086. // "T_Wo_WorkOrder",
  5087. // "T_Wo_WorkOrder.ID",
  5088. // "*,(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",
  5089. // sql,
  5090. // "ORDER BY T_Wo_WorkOrder.ID desc",
  5091. // pagesize,
  5092. // pageindex,
  5093. // true,
  5094. // out recordCount);
  5095. // dt.Columns.Add("CBCount", typeof(int));
  5096. // foreach (DataRow dr in dt.Rows)
  5097. // {
  5098. // 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];
  5099. // dr["CBCount"] = list.Rows.Count;
  5100. // }
  5101. // }
  5102. // var obj = new
  5103. // {
  5104. // state = "success",
  5105. // message = "成功",
  5106. // rows = dt,
  5107. // total = recordCount
  5108. // };
  5109. // return Content(obj.ToJson());
  5110. //}
  5111. ///// <summary>
  5112. ///// 新增工单
  5113. ///// </summary>
  5114. ///// <returns></returns>
  5115. //[WechatActionFilter]
  5116. //public ActionResult AddWorkOrder()
  5117. //{
  5118. // DataTable dt = new DataTable();
  5119. // //工单来源
  5120. // int gdly = RequestString.GetFormInt("gdly", 0);
  5121. // //工单类型
  5122. // int gdlx = RequestString.GetFormInt("gdlx", 0);
  5123. // //客户id
  5124. // int customerid = RequestString.GetFormInt("customerid", 0);
  5125. // //客户姓名
  5126. // string callCustomer = RequestString.GetFormString("callCustomer");
  5127. // //联系电话
  5128. // string tel = RequestString.GetFormString("tel");
  5129. // //处理部门
  5130. // string fkdep = RequestString.GetFormString("fkdep");
  5131. // //客服类类型
  5132. // string kfdepid = RequestString.GetFormString("kfdepid");
  5133. // //受理人 - 审核人工号
  5134. // string auditusercode = RequestString.GetFormString("auditusercode");
  5135. // //工单状态
  5136. // int gdzt = RequestString.GetFormInt("gdzt", 0);
  5137. // //接待描述 - 反馈内容
  5138. // string fkcont = RequestString.GetFormString("fkcont");
  5139. // string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
  5140. // string files = RequestString.GetFormString("files");
  5141. // //咨询类工单指派部门
  5142. // int clbm = RequestString.GetFormInt("clbm", 0);
  5143. // //备注
  5144. // string note = RequestString.GetFormString("note");
  5145. // #region 添加验证判断
  5146. // if (string.IsNullOrEmpty(callCustomer))
  5147. // return Error("姓名不能为空!");
  5148. // if (string.IsNullOrEmpty(tel))
  5149. // return Error("电话不能为空!");
  5150. // #endregion
  5151. // string workOrder = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
  5152. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5153. // var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  5154. // var model = userAccountBLL.GetModelByOpenid(stropenid);
  5155. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(stropenid);
  5156. // string usercode = "";
  5157. // if (model != null)
  5158. // {
  5159. // usercode = model.F_UserCode;
  5160. // }
  5161. // else if (modelCustomer != null)
  5162. // {
  5163. // usercode = modelCustomer.F_CustomerCode;
  5164. // customerid = modelCustomer.F_CustomerId;
  5165. // }
  5166. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  5167. // string workorderid = wo.AddWXWorkOrder(workOrder, gdly, gdlx, customerid, callCustomer, tel, fkdep, kfdepid, auditusercode, fkcont, files, gdzt, note, usercode,-1);
  5168. // if (string.IsNullOrEmpty(workorderid))
  5169. // {
  5170. // return Error("新增失败");
  5171. // }
  5172. // else
  5173. // {
  5174. // #region 咨询类工单指派至部门
  5175. // //工单类型(107咨询,108投诉)
  5176. // if (gdlx == 107)
  5177. // {
  5178. // //需要审核后,再处理
  5179. // //bool b = wo.DealWXWorkOrder(workOrder, 0, 0, clbm, 0, "", fkcont, stropenid);
  5180. // }
  5181. // #endregion
  5182. // //暂时排除客户档案用户(F_UserId无法区分是住户添加 还是管理员添加) - 后期完善
  5183. // if (wxuser != null)
  5184. // {
  5185. // Model.T_WO_UserWorkOrder tbu = new Model.T_WO_UserWorkOrder();
  5186. // tbu.F_UserId = wxuser.F_Id;
  5187. // tbu.F_WorkOrderId = workorderid;
  5188. // new BLL.T_WO_UserWorkOrder().Add(tbu);
  5189. // }
  5190. // return Success("新增成功", workorderid);
  5191. // }
  5192. //}
  5193. ///// <summary>
  5194. ///// 修改工单
  5195. ///// </summary>
  5196. ///// <returns></returns>
  5197. //[WechatActionFilter]
  5198. //public ActionResult UpdateWorkOrder()
  5199. //{
  5200. // DataTable dt = new DataTable();
  5201. // //工单id
  5202. // string workorderid = RequestString.GetFormString("orderid");
  5203. // //工单来源
  5204. // int gdly = RequestString.GetFormInt("gdly", 0);
  5205. // //工单类型
  5206. // int gdlx = RequestString.GetFormInt("gdlx", 0);
  5207. // //客户id
  5208. // int customerid = RequestString.GetFormInt("customerid", 0);
  5209. // //客户姓名
  5210. // string callCustomer = RequestString.GetFormString("callCustomer");
  5211. // //联系电话
  5212. // string tel = RequestString.GetFormString("tel");
  5213. // //处理部门
  5214. // string fkdep = RequestString.GetFormString("fkdep");
  5215. // //客服类类型
  5216. // string kfdepid = RequestString.GetFormString("kfdepid");
  5217. // //受理人 - 审核人工号
  5218. // string auditusercode = RequestString.GetFormString("auditusercode");
  5219. // //接待描述 - 反馈内容
  5220. // string fkcont = RequestString.GetFormString("fkcont");
  5221. // string files = RequestString.GetFormString("files");
  5222. // //备注
  5223. // string note = RequestString.GetFormString("note");
  5224. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5225. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  5226. // if (!string.IsNullOrEmpty(stropenid))
  5227. // {
  5228. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5229. // if (ua != null)
  5230. // {
  5231. // WorkOrderController wo = new WorkOrderController();
  5232. // if (!string.IsNullOrEmpty(workorderid))
  5233. // {
  5234. // var models = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + workorderid + "'");
  5235. // if (models.Count > 0)
  5236. // {
  5237. // var model = models.FirstOrDefault();
  5238. // string detail = model.Detail;
  5239. // model.Type = gdly; //工单来源
  5240. // model.TypeClass = gdlx; //投诉类型 -工单类型
  5241. // model.Customer = callCustomer; //客户姓名
  5242. // model.CustomerTel = tel; //联系电话
  5243. // //model.CustomerID = customerid; //用户档案Id
  5244. // model.Source = fkdep; //处理部门 反馈单位
  5245. // model.CreateUserID = kfdepid; //客服类类型
  5246. // model.AuditUser = auditusercode; //受理人 - 审核人工号
  5247. // //model.CreateUser = ua.F_UserCode; //接待人(工号)
  5248. // //model.State = 0; //工单状态
  5249. // //反馈内容
  5250. // var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
  5251. // model.Detail = detailutf8;
  5252. // if (new BLL.T_Wo_WorkOrder().Update(model))
  5253. // {
  5254. // //添加工单修改操作日志
  5255. // wo.WriteWorkOrderLog(workorderid, detail, detailutf8, ua.F_UserCode, 0, "", 1, "修改工单(微信端)");
  5256. // return Success("修改成功!");
  5257. // }
  5258. // }
  5259. // }
  5260. // }
  5261. // }
  5262. // return Error("修改失败!");
  5263. //}
  5264. ///// <summary>
  5265. ///// 处理工单
  5266. ///// </summary>
  5267. ///// <returns></returns>
  5268. //[WechatActionFilter]
  5269. //public ActionResult DealWorkOrder()
  5270. //{
  5271. // DataTable dt = new DataTable();
  5272. // string orderid = RequestString.GetFormString("orderid");
  5273. // int isend = RequestString.GetInt("isend", 0); //0转派
  5274. // int ltype = RequestString.GetInt("ltype", 0); //处理方式 1结束 0转派
  5275. // int clbm = RequestString.GetInt("clbm", 0); //部门id
  5276. // int clid = RequestString.GetInt("clid", 0); //用户接收人id
  5277. // string cont = RequestString.GetFormString("cont"); //处理内容
  5278. // string detail = RequestString.GetFormString("detail");
  5279. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5280. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  5281. // bool res = wo.DealWXWorkOrder(orderid, isend, ltype, clbm, clid, cont, detail, stropenid);
  5282. // if (res)
  5283. // {
  5284. // return Success("操作成功");
  5285. // }
  5286. // else
  5287. // {
  5288. // return Error("操作失败");
  5289. // }
  5290. //}
  5291. ///// <summary>
  5292. ///// 接单 - 确认工单
  5293. ///// </summary>
  5294. ///// <returns></returns>
  5295. //[WechatActionFilter]
  5296. //public ActionResult SureWorkOrder()
  5297. //{
  5298. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5299. // string orderid = RequestString.GetFormString("orderid");
  5300. // if (!string.IsNullOrEmpty(stropenid))
  5301. // {
  5302. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5303. // if (ua != null)
  5304. // {
  5305. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  5306. // if (model != null)
  5307. // {
  5308. // Model.T_Wo_WorkOrderItem item = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and isdel=0 and Type=1 ").OrderByDescending(p => p.CreateTime).FirstOrDefault();
  5309. // if (item != null && item.State == 0 && ("," + item.ToUser + ",").Contains("," + ua.F_UserCode + ","))
  5310. // {
  5311. // item.SureUser = ua.F_UserCode;
  5312. // item.State = 1;
  5313. // item.SureTime = DateTime.Now;
  5314. // if (new BLL.T_Wo_WorkOrderItem().Update(item))
  5315. // {
  5316. // return Success("接单成功!");
  5317. // }
  5318. // }
  5319. // return Error("操作失败,工单还没有派单!");
  5320. // }
  5321. // }
  5322. // return Error("操作失败");
  5323. // }
  5324. // return Error("参数错误");
  5325. //}
  5326. ///// <summary>
  5327. ///// 催办工单(管理员,业主)
  5328. ///// </summary>
  5329. ///// <returns></returns>
  5330. //[WechatActionFilter]
  5331. //public ActionResult RemindWorkOrder()
  5332. //{
  5333. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5334. // if (!string.IsNullOrEmpty(stropenid))
  5335. // {
  5336. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5337. // string usercode = string.Empty;
  5338. // string username = string.Empty;
  5339. // if (ua != null)
  5340. // {
  5341. // usercode = ua.F_UserCode;
  5342. // username = ua.F_UserName;
  5343. // }
  5344. // else
  5345. // {
  5346. // //获取客户档案(业主)表信息
  5347. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  5348. // if (modelCustomer != null)
  5349. // {
  5350. // usercode = modelCustomer.F_CustomerCode;
  5351. // username = modelCustomer.F_CompanyName;
  5352. // }
  5353. // }
  5354. // if (string.IsNullOrEmpty(usercode))
  5355. // return Error("参数错误!");
  5356. // string orderid = RequestString.GetFormString("orderid");
  5357. // string cont = RequestString.GetFormString("cont");
  5358. // string callid = RequestString.GetFormString("callid");
  5359. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  5360. // if (model != null)
  5361. // {
  5362. // 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();
  5363. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  5364. // if (itemlast != null)
  5365. // {
  5366. // item.ToDept = itemlast.ToDept;
  5367. // item.ToUser = itemlast.ToUser;
  5368. // }
  5369. // else
  5370. // {
  5371. // var cu = new BLL.T_Sys_UserAccount().GetModel(model.CreateUser);
  5372. // if (cu != null)
  5373. // {
  5374. // item.ToDept = cu.F_DeptId;
  5375. // item.ToUser = cu.F_UserCode;
  5376. // }
  5377. // else {
  5378. // var modelCus = customerBaseBLL.GetModelList(" F_CustomerCode='" + model.CreateUser + "'").FirstOrDefault(); //customerBaseBLL.GetModel(model.CreateUser);
  5379. // if (modelCus != null)
  5380. // {
  5381. // item.ToDept = 0;
  5382. // item.ToUser = modelCus.F_LegalTel;
  5383. // }
  5384. // }
  5385. // }
  5386. // item.WorkOrderID = orderid;
  5387. // item.Type = 2;
  5388. // item.Detail = cont;
  5389. // item.CallID = callid;
  5390. // item.State = 0;
  5391. // item.IsDel = 0;
  5392. // item.IsLast = 0;
  5393. // item.IsStart = 0;
  5394. // item.IsTimeOut = 0;
  5395. // item.CreateUser = usercode; // ua.F_UserCode;
  5396. // item.CreateTime = DateTime.Now;
  5397. // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  5398. // if (itemid > 0 && !string.IsNullOrEmpty(item.ToUser))
  5399. // {
  5400. // foreach (string ur in item.ToUser.Split(','))
  5401. // {
  5402. // Model.T_Msg_List msg = new Model.T_Msg_List();
  5403. // msg.Type = 1;
  5404. // msg.ToUser = ur;
  5405. // msg.ToID = Int32.Parse(itemid.ToString());
  5406. // msg.Detail = username + "向你催办了工单,单号:" + model.WorkOrderID;
  5407. // msg.State = 0;
  5408. // msg.IsDel = 0;
  5409. // msg.CreateUser = usercode;
  5410. // msg.CreateDate = DateTime.Now;
  5411. // new BLL.T_Msg_List().Add(msg);
  5412. // }
  5413. // return Success("催办成功!");
  5414. // }
  5415. // }
  5416. // }
  5417. // return Error("参数错误");
  5418. //}
  5419. ///// <summary>
  5420. ///// 退回工单
  5421. ///// </summary>
  5422. ///// <param name="input"></param>
  5423. ///// <returns></returns>
  5424. //[WechatActionFilter]
  5425. //public ActionResult BackWorkOrder()
  5426. //{
  5427. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5428. // if (!string.IsNullOrEmpty(stropenid))
  5429. // {
  5430. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5431. // if (ua != null)
  5432. // {
  5433. // string orderid = RequestString.GetFormString("orderid");
  5434. // var model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  5435. // //验证信息
  5436. // if (model == null)
  5437. // {
  5438. // return Error("工单不存在");
  5439. // }
  5440. // model.State = 0;
  5441. // if (new BLL.T_Wo_WorkOrder().Update(model))
  5442. // {
  5443. // 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();
  5444. // if (modelItem != null)
  5445. // {
  5446. // modelItem.State = 6;
  5447. // new BLL.T_Wo_WorkOrderItem().Update(modelItem);
  5448. // }
  5449. // return Success("操作成功");
  5450. // }
  5451. // return Error("操作失败");
  5452. // }
  5453. // }
  5454. // return Error("操作失败");
  5455. //}
  5456. ///// <summary>
  5457. ///// 评论工单(管理人员,业主)
  5458. ///// </summary>
  5459. ///// <returns></returns>
  5460. //[WechatActionFilter]
  5461. //public ActionResult CommentWorkOrder()
  5462. //{
  5463. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5464. // if (!string.IsNullOrEmpty(stropenid))
  5465. // {
  5466. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5467. // string usercode = string.Empty;
  5468. // string username = string.Empty;
  5469. // if (ua != null)
  5470. // {
  5471. // usercode = ua.F_UserCode;
  5472. // username = ua.F_UserName;
  5473. // }
  5474. // else
  5475. // {
  5476. // //获取客户档案(业主)表信息
  5477. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  5478. // if (modelCustomer != null)
  5479. // {
  5480. // usercode = modelCustomer.F_CustomerCode;
  5481. // username = modelCustomer.F_CompanyName;
  5482. // }
  5483. // }
  5484. // if (string.IsNullOrEmpty(usercode))
  5485. // return Error("参数错误!");
  5486. // string orderid = RequestString.GetFormString("orderid");
  5487. // string cont = RequestString.GetFormString("cont");
  5488. // string file = RequestString.GetFormString("file");
  5489. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  5490. // if (model != null)
  5491. // {
  5492. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  5493. // item.WorkOrderID = orderid;
  5494. // item.Type = 3; //评论
  5495. // item.Detail = cont;
  5496. // item.Files = file;
  5497. // item.State = 0;
  5498. // item.IsDel = 0;
  5499. // item.IsStart = 0;
  5500. // item.IsTimeOut = 0;
  5501. // item.IsLast = 0;
  5502. // item.CreateUser = usercode;
  5503. // item.CreateTime = DateTime.Now;
  5504. // if (new BLL.T_Wo_WorkOrderItem().Add(item) > 0)
  5505. // {
  5506. // return Success("评论成功!");
  5507. // }
  5508. // }
  5509. // }
  5510. // return Error("操作失败");
  5511. //}
  5512. ///// <summary>
  5513. ///// 刪除工单
  5514. ///// </summary>
  5515. ///// <returns></returns>
  5516. //[WechatActionFilter]
  5517. //public ActionResult DelWorkOrder(string[] ids)
  5518. //{
  5519. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5520. // if (!string.IsNullOrEmpty(stropenid))
  5521. // {
  5522. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5523. // if (ua != null)
  5524. // {
  5525. // if (ids != null && ids.Length > 0)
  5526. // {
  5527. // string idd = " ";
  5528. // foreach (string str in ids)
  5529. // {
  5530. // idd += str + ",";
  5531. // }
  5532. // string sql = "update T_Wo_WorkOrder set IsDel=1,DelUser='" + ua.F_UserCode + "',DelTime=getdate() where ID in (" + idd.TrimEnd(',') + ")";
  5533. // if (!string.IsNullOrEmpty(idd.Trim()))
  5534. // {
  5535. // if (DbHelperSQL.ExecuteSql(sql) > 0)
  5536. // {
  5537. // return Success("删除成功");
  5538. // }
  5539. // }
  5540. // else
  5541. // {
  5542. // return Error("请选择记录");
  5543. // }
  5544. // }
  5545. // else
  5546. // {
  5547. // return Error("获取参数失败");
  5548. // }
  5549. // }
  5550. // }
  5551. // return Error("操作失败");
  5552. //}
  5553. ///// <summary>
  5554. ///// 获取工单详情
  5555. ///// </summary>
  5556. ///// <returns></returns>
  5557. //[WechatActionFilter]
  5558. //public ActionResult GetWorkOrder()
  5559. //{
  5560. // string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5561. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  5562. // if (string.IsNullOrEmpty(strworkorderid))
  5563. // return Error("参数错误");
  5564. // if (string.IsNullOrEmpty(stropenid))
  5565. // return Error("参数错误!");
  5566. // #region pc端工单也可以查看,所以注释(注释功能只能查看自己创建的工单)
  5567. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  5568. // //if (wxuser != null)
  5569. // //{
  5570. // // var tbu = new BLL.T_WO_UserWorkOrder().GetList(" F_UserId='" + wxuser.F_Id + "' and F_WorkOrderId=" + strworkorderid + " ").Tables[0];
  5571. // // if (tbu.Rows.Count > 0)
  5572. // // {
  5573. // // }
  5574. // //}
  5575. // #endregion
  5576. // 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 "
  5577. // + " from T_Wo_WorkOrder where WorkOrderID ='" + strworkorderid + "' ";
  5578. // var dt = DbHelperSQL.Query(sql).Tables[0];
  5579. // if (dt.Rows.Count > 0)
  5580. // {
  5581. // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  5582. // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  5583. // if (configfj != null)
  5584. // {
  5585. // dt = BindFileData(dt, configfj.F_ParamValue);
  5586. // }
  5587. // string gcsql = "select *,dbo.GetUserName(CreateUser) as UserName "
  5588. // + "from T_Wo_WorkOrderItem where IsDel=0 and WorkOrderID ='" + dt.Rows[0]["WorkOrderId"] + "'";
  5589. // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  5590. // dt.Columns.Add("FilePath", typeof(string));
  5591. // if (configfj != null || config != null)
  5592. // {
  5593. // foreach (DataRow bldr in dt.Rows)
  5594. // {
  5595. // if (bldr["CallID"] != null && config != null)
  5596. // {
  5597. // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
  5598. // }
  5599. // }
  5600. // }
  5601. // var obj = new
  5602. // {
  5603. // data = dt,
  5604. // item = gcdt
  5605. // };
  5606. // return Success("查询成功", obj);
  5607. // }
  5608. // return Error("查询失败");
  5609. //}
  5610. ///// <summary>
  5611. ///// 获取工单明细列表
  5612. ///// </summary>
  5613. ///// <returns></returns>
  5614. //[WechatActionFilter]
  5615. //public ActionResult GetItemList()
  5616. //{
  5617. // string sql = " and IsDel=0 ";
  5618. // DataTable dt = new DataTable();
  5619. // string strid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  5620. // string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  5621. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  5622. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  5623. // string strpageindex = RequestString.GetQueryString("page");
  5624. // int pageindex = 1;
  5625. // string strpagesize = RequestString.GetQueryString("pagesize");
  5626. // int pagesize = 10;
  5627. // if (strid.Trim() != "" && strid != "undefined")
  5628. // {
  5629. // sql += " and WorkOrderID = '" + strid.Trim() + "' ";
  5630. // }
  5631. // if (strtype.Trim() != "" && strtype != "undefined")
  5632. // {
  5633. // sql += " and Type = '" + strtype.Trim() + "' ";
  5634. // }
  5635. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  5636. // {
  5637. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  5638. // }
  5639. // if (strendtime.Trim() != "" && strendtime != "undefined")
  5640. // {
  5641. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  5642. // }
  5643. // if (strpageindex.Trim() != "")
  5644. // {
  5645. // pageindex = Convert.ToInt32(strpageindex);
  5646. // }
  5647. // if (strpagesize.Trim() != "")
  5648. // {
  5649. // pagesize = Convert.ToInt32(strpagesize);
  5650. // }
  5651. // int recordCount = 0;
  5652. // dt = BLL.PagerBLL.GetListPager(
  5653. // "T_Wo_WorkOrderItem",
  5654. // "T_Wo_WorkOrderItem.ID",
  5655. // "*,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",
  5656. // sql,
  5657. // "ORDER BY T_Wo_WorkOrderItem.ID desc",
  5658. // pagesize,
  5659. // pageindex,
  5660. // true,
  5661. // out recordCount);
  5662. // var obj = new
  5663. // {
  5664. // state = "success",
  5665. // message = "成功",
  5666. // rows = dt,
  5667. // total = recordCount
  5668. // };
  5669. // return Content(obj.ToJson());
  5670. //}
  5671. ///// <summary>
  5672. ///// 获取工作动态列表 - 工单明细动态列表 - 管理员功能
  5673. ///// </summary>
  5674. ///// <returns></returns>
  5675. //[WechatActionFilter]
  5676. //public ActionResult GetWorkOrderItemList()
  5677. //{
  5678. // DataTable dt = new DataTable();
  5679. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  5680. // //string stropenid = "oXF5e1mWpX5DajW5_yjNLPKb8ThE";
  5681. // //获取客户档案(业主)表信息
  5682. // var model = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  5683. // string sql = " and IsDel=0 ";
  5684. // string daytype = HttpUtility.UrlDecode(RequestString.GetQueryString("daytype"));
  5685. // string strpageindex = RequestString.GetQueryString("page");
  5686. // int pageindex = 1;
  5687. // string strpagesize = RequestString.GetQueryString("pagesize");
  5688. // int pagesize = 10;
  5689. // #region 权限限制
  5690. // //if (model != null) {
  5691. // // var sqlUser = "";
  5692. // // //部门信息
  5693. // // var modelDep = new BLL.T_Sys_Department().GetModel(model.F_DeptId);
  5694. // // int depType = 0, depRegion = 0;
  5695. // // if (modelDep != null)
  5696. // // {
  5697. // // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  5698. // // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  5699. // // }
  5700. // // //根据部门查询工单(可查看当前部门工单)
  5701. // // string deptCode = model.F_DeptCode; //部门code
  5702. // // int userRegionId = model.RegionId; //项目id
  5703. // // ////接待部(坐席)可以看到所有的工单
  5704. // // //if (model.F_RoleId != 17 && depType != 1)
  5705. // // //{
  5706. // // // //if (depType == 2 || depType == 3)
  5707. // // // //{
  5708. // // // // // ============== 项目权限 - 项目 ==============
  5709. // // // // sqlUser += $" and IsAdminSend = {userRegionId} ";
  5710. // // // //}
  5711. // // // //else if (depType == 4)
  5712. // // // //{
  5713. // // // // // 查看该部门工单(包括一级,二级)
  5714. // // // // string deptCodeNew = String.Empty;
  5715. // // // // int deptCodeIndex = 0; //变量声明
  5716. // // // // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  5717. // // // // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  5718. // // // // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  5719. // // // // // ============== 部门权限条件 - 部门 ================
  5720. // // // // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  5721. // // // // sql += $" and ToUser IN ({arrUser}) and WorkOrderID IN (SELECT WorkOrderID FROM dbo.T_Wo_WorkOrder WHERE 1=1 {sqlUser} ) ";
  5722. // // // //}
  5723. // // //}
  5724. // //}
  5725. // #endregion
  5726. // switch (daytype)
  5727. // {
  5728. // case "today":
  5729. // sql += " and DateDiff(dd,CreateTime,getdate())=0 ";
  5730. // break;
  5731. // case "yesterday":
  5732. // sql += " and DateDiff(dd,CreateTime,getdate())=1 ";
  5733. // break;
  5734. // case "month":
  5735. // sql += " and DateDiff(mm,CreateTime,getdate())=0 ";
  5736. // break;
  5737. // default:
  5738. // break;
  5739. // }
  5740. // if (strpageindex.Trim() != "")
  5741. // {
  5742. // pageindex = Convert.ToInt32(strpageindex);
  5743. // }
  5744. // if (strpagesize.Trim() != "")
  5745. // {
  5746. // pagesize = Convert.ToInt32(strpagesize);
  5747. // }
  5748. // int recordCount = 0;
  5749. // dt = BLL.PagerBLL.GetListPager(
  5750. // "T_Wo_WorkOrderItem",
  5751. // "T_Wo_WorkOrderItem.ID",
  5752. // "*,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",
  5753. // sql,
  5754. // "ORDER BY T_Wo_WorkOrderItem.ID desc",
  5755. // pagesize,
  5756. // pageindex,
  5757. // true,
  5758. // out recordCount);
  5759. // var obj = new
  5760. // {
  5761. // state = "success",
  5762. // message = "成功",
  5763. // rows = dt,
  5764. // total = recordCount
  5765. // };
  5766. // return Content(obj.ToJson());
  5767. //}
  5768. #endregion
  5769. #region 附件和语音文件
  5770. /// <summary>
  5771. /// 获取留言路径
  5772. /// </summary>
  5773. /// <param name="lid">留言id</param>
  5774. /// <param name="prefix">前缀</param>
  5775. /// <returns></returns>
  5776. public string GetLeavePath(string lid, string prefix)
  5777. {
  5778. string path = string.Empty;
  5779. var liuyan = new BLL.T_Call_LeaveRecord().GetModelList(" F_Id='" + lid + "' ").FirstOrDefault();
  5780. if (liuyan != null)
  5781. {
  5782. if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
  5783. {
  5784. path = prefix + liuyan.F_RecFileUrl;
  5785. }
  5786. }
  5787. return path;
  5788. }
  5789. /// <summary>
  5790. /// 获取通话录音路径
  5791. /// </summary>
  5792. /// <param name="cid">通话id</param>
  5793. /// <param name="prefix">前缀</param>
  5794. /// <returns></returns>
  5795. public string GetCallPath(string cid, string prefix)
  5796. {
  5797. string path = string.Empty;
  5798. var luyin = new BLL.T_Call_CallRecords().GetModelList(" callid='" + cid + "' ").FirstOrDefault();
  5799. if (luyin != null)
  5800. {
  5801. if (!string.IsNullOrEmpty(luyin.FilePath))
  5802. {
  5803. var ym = prefix;
  5804. ym = ym.Substring(0, ym.Length - 1);
  5805. path = ym + luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
  5806. }
  5807. }
  5808. return path;
  5809. }
  5810. /// <summary>
  5811. /// 获取附件数据
  5812. /// </summary>
  5813. /// <param name="ids">附件id,多个用英文逗号,隔开</param>
  5814. /// <param name="prefix">前缀</param>
  5815. /// <returns></returns>
  5816. public DataTable GetFileData(string ids, string prefix)
  5817. {
  5818. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
  5819. foreach (DataRow dr in dt.Rows)
  5820. {
  5821. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  5822. }
  5823. return dt;
  5824. }
  5825. /// <summary>
  5826. /// 绑定附件信息
  5827. /// </summary>
  5828. /// <param name="dt"></param>
  5829. /// <param name="prefix"></param>
  5830. /// <returns></returns>
  5831. public DataTable BindFileData(DataTable dt, string prefix)
  5832. {
  5833. dt.Columns.Add("File", typeof(object));
  5834. foreach (DataRow dr in dt.Rows)
  5835. {
  5836. if (dr["Files"] != null && dr["Files"].ToString() != "")
  5837. {
  5838. dr["File"] = GetFileData(dr["Files"].ToString(), prefix);
  5839. }
  5840. }
  5841. return dt;
  5842. }
  5843. #endregion
  5844. #region 上传附件
  5845. /// <summary>
  5846. /// 上传附件
  5847. /// </summary>
  5848. /// <returns></returns>
  5849. public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
  5850. {
  5851. try
  5852. {
  5853. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  5854. string filePathName = string.Empty;
  5855. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy/MM/dd") + "/";
  5856. string localPath = Server.MapPath(Path.Combine(HttpRuntime.AppDomainAppPath, path));
  5857. if (Request.Files.Count == 0)
  5858. {
  5859. return Error("保存失败");
  5860. }
  5861. string ex = Path.GetExtension(file.FileName);
  5862. filePathName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + ex;
  5863. if (!System.IO.Directory.Exists(localPath))
  5864. {
  5865. System.IO.Directory.CreateDirectory(localPath);
  5866. }
  5867. file.SaveAs(Path.Combine(localPath, filePathName));
  5868. #region 添加日志
  5869. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  5870. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  5871. model_T_Sys_Accessories.F_FileName = filePathName;//附件名称
  5872. model_T_Sys_Accessories.F_FileType = type;//附件类型
  5873. model_T_Sys_Accessories.F_FileUrl = path + filePathName;//附件地址
  5874. model_T_Sys_Accessories.F_Size = size;
  5875. model_T_Sys_Accessories.F_UserCode = stropenid;//上传人
  5876. int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  5877. #endregion
  5878. if (fid > 0)
  5879. {//返回附件的ID
  5880. model_T_Sys_Accessories.F_FileId = fid;//修改为返回对象以便查看图片
  5881. return Success("文件日志都成功", model_T_Sys_Accessories);
  5882. }
  5883. else
  5884. return Success("文件成功");
  5885. }
  5886. catch (Exception ex)
  5887. {
  5888. return Error(ex.Message);
  5889. }
  5890. }
  5891. #endregion
  5892. }
  5893. }