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