| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685 |
- using CallCenter.Utility;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Enum;
- using CallCenterApi.Model;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Web;
- using System.Web.Mvc;
- using System.Dynamic;
- namespace CallCenterApi.Interface.Controllers.report
- {
- public class WOReportController : BaseController
- {
- BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
- BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
- BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
- BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
- BLL.T_Wo_QuestionManage quesBLL = new BLL.T_Wo_QuestionManage();
- private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
- BLL.T_Wo_WorkOrder workOrder = new BLL.T_Wo_WorkOrder();
- public ActionResult GetDicValueListByFlag(string flag)
- {
- DataTable dt = new DataTable();
- dt = new BLL.T_Sys_DictionaryValue().GetList(" F_DictionaryFlag='" + flag + "' and F_State=1 ").Tables[0];
- return Success("列表加载成功", dt);
- }
- public ActionResult GetDataList(string stime, string endtime, int deptid = 0)
- {
- DataTable dtNew = new DataTable();//getData(stime, endtime, deptid);
- var obj = new
- {
- dtNew,
- totle = dtNew.Rows.Count
- };
- return Success("获取业务报表数据", obj);
- }
- public ActionResult ExptList(string stime, string endtime, int deptid = 0)
- {
- NPOIHelper npoi = new NPOIHelper();
- DataTable dt = new DataTable();
- // DataTable dt = getData(stime, endtime, deptid);
- if (npoi.ExportToExcel("业务报表数据", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- public class market
- {
- public string typename;
- public string salexinxiang;
- public string salejiujiang;
- public string salexinjiang;
- public string saledongbei;
- public string cheyong;
- public string total;
- }
- public class marketList
- {
- public string typename;
- public int salexinxinag;
- public int salejiujiang;
- public int salexinjiang;
- public int saledongbei;
- public int cheyongniaosu;
- public int total;
- public string immediate;
- public int overdue;
- public int satisfied;
- public int dissatisfied;
- }
- /// <summary>
- /// 导出反馈类型明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult ExitTypelist(string stime, string endtime)
- {
- DataTable dt = new DataTable();
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "XSJD" + "' and F_State=1 ").Tables[0];
- List<Brand> list = new List<Brand>();
- List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
- if (dicv != null)
- {
- dicval = dicvalueBll.DataTableToList(dicv);
- }
- dt.Columns.Add("反馈类型");
- foreach (var it in dicval)
- {
- dt.Columns.Add(it.F_Name );
- }
- dt.Columns.Add("合计");
- dt.Columns.Add("即时办结率");
-
- for (int i = 0; i < 8; i++)
- {
- DataRow drNew = dt.NewRow();
- switch (i)
- {
- case 0:
- drNew["反馈类型"] = "合计";
- break;
- case 1:
- drNew["反馈类型"] = "咨询";
- break;
- case 2:
- drNew["反馈类型"] = "投诉";
- break;
- case 3:
- drNew["反馈类型"] = "抽检";
- break;
- case 4:
- drNew["反馈类型"] = "建议";
- break;
- case 5:
- drNew["反馈类型"] = "超期数量";
- break;
- case 6:
- drNew["反馈类型"] = "满意数量";
- break;
- case 7:
- drNew["反馈类型"] = "不满意数量";
- break;
- }
- string nsg = "";
- if (i > 0&& i<5)
- {
- nsg = "and F_Type=" + i;
- }
- else if (i > 4)
- {
- if (i ==5)
- {
- nsg = " and F_IsOver=" + 1 ;
- }
- else if (i == 6)
- {
- nsg = "and F_VisitResult in('非常满意','满意')";
- }
- else if (i == 7)
- {
- nsg = "and F_VisitResult='不满意'";
- }
- }
- foreach (var it in dicval)
- {
- drNew[it.F_Name ] = woBLL.GetModelList(sql + "and F_SalesBase='"+ it.F_Name+"'" + nsg).Count.ToString();
- }
- drNew["合计"] = woBLL.GetModelList(sql + nsg).Count.ToString();
- int a = woBLL.GetModelList(sql + "and F_DealType='当即办理'" + nsg).Count;
- int b = woBLL.GetModelList(sql + nsg).Count;
- if (b > 0)
- {
- drNew["即时办结率"] = string.Format("{0:f2}%", a / b * 100);
- }
- else
- {
- drNew["即时办结率"] = string.Format("0.00%");
- }
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("反馈类型明细表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 反馈类型明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetTypelist(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
-
- List<marketList> markets = new List<marketList>();
- for (int i = 0; i < 8; i++)
- {
- marketList brand = new marketList();
- switch (i)
- {
- case 0:
- brand.typename = "合计";
- break;
- case 1:
- brand.typename = "咨询";
- break;
- case 2:
- brand.typename = "投诉";
- break;
- case 3:
- brand.typename = "抽检";
- break;
- case 4:
- brand.typename = "建议";
- break;
- case 5:
- brand.typename = "超期数量";
- break;
- case 6:
- brand.typename = "满意数量";
- break;
- case 7:
- brand.typename = "不满意数量";
- break;
- }
- string nsg = "";
- if (i > 0 && i < 5)
- {
- nsg = "and F_Type=" + i;
- }
- else if (i > 4)
- {
- if (i == 5)
- {
- nsg = " and F_IsOver=" + 1;
- }
- else if (i == 6)
- {
- nsg = "and F_VisitResult in('非常满意','满意')";
- }
- else if (i == 7)
- {
- nsg = "and F_VisitResult='不满意'";
- }
- }
- brand.salexinxinag = woBLL.GetModelList(sql + "and F_SalesBase='新乡'" + nsg).Count;
- brand.salejiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'" + nsg).Count;
- brand.salexinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'" + nsg).Count;
- brand.saledongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'" + nsg).Count;
- brand.cheyongniaosu = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'" + nsg).Count;
- brand.total = woBLL.GetModelList(sql + nsg).Count;
- int a = woBLL.GetModelList(sql + "and F_DealType='当即办理'" + nsg).Count;
- int b = woBLL.GetModelList(sql + nsg).Count;
- if (b > 0)
- {
- brand.immediate = string.Format("{0:f2}%", a / b * 100);
- }
- else
- {
- brand.immediate = string.Format("0.00%");
- }
- markets.Add(brand);
- }
- return Success("获取成功", markets);
- }
- /// <summary>
- /// 导出销售基地明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult ExitSalesBaselist(string stime, string endtime)
- {
- DataTable dt = new DataTable();
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
- var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
- var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
- List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
- List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
- List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
- List<Model.T_Wo_WorkOrder> workerdongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'");
- List<Model.T_Wo_WorkOrder> workerjiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'");
- List<Model.T_Wo_WorkOrder> workerxinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'");
- List<Model.T_Wo_WorkOrder> workerxinxiang = woBLL.GetModelList(sql + "and F_SalesBase='新乡'");
- List<Model.T_Wo_WorkOrder> workercheyong = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'");
- List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
- dt.Columns.Add("类型");
- dt.Columns.Add("新乡");
- dt.Columns.Add("九江");
- dt.Columns.Add("新疆");
- dt.Columns.Add("东北");
- dt.Columns.Add("车用尿素");
- dt.Columns.Add("合计");
- for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
- {
- DataRow drNew = dt.NewRow();
- int saledongbei = 0;
- int salejiujiang = 0;
- int salexinjiang = 0;
- int salexinxiang = 0;
- int cheyongniaosu = 0;
- int total = 0;
- saledongbei = workercount(i, workerdongbei, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salejiujiang = workercount(i, workerjiujiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salexinjiang = workercount(i, workerxinjiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salexinxiang = workercount(i, workerxinxiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- cheyongniaosu= workercount(i, workercheyong, ConsultingNeedslist, Complaintlist, SpotChecklist);
- total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
- market brand = new market();
- switch (i)
- {
- case 0:
- drNew["类型"] = "合计";
- break;
- case 1:
- drNew["类型"] = "即时办结率";
- break;
- case 2:
- drNew["类型"] = "超期数量";
- break;
- case 3:
- drNew["类型"] = "满意数量";
- break;
- case 4:
- drNew["类型"] = "不满意数量";
- break;
- }
- if (i < ConsultingNeedslist.Count + 5 && i >= 5)
- {
- drNew["类型"] = ConsultingNeedslist[i - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
- {
- drNew["类型"] = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
- {
- drNew["类型"] = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
- }
- if (i == 1)
- {
- if (total > 0)
- {
- drNew["东北"] = string.Format("{0:f2}%", saledongbei / total * 100);
- drNew["九江"] = string.Format("{0:f2}%", salejiujiang / total * 100);
- drNew["新疆"] = string.Format("{0:f2}%", salexinjiang / total * 100);
- drNew["新乡"] = string.Format("{0:f2}%", salexinxiang / total * 100);
- drNew["车用尿素"] = string.Format("{0:f2}%", cheyongniaosu / total * 100);
- drNew["合计"] = string.Format("{0:f2}%", 100);
- }
- else
- {
- drNew["东北"] = "0.00%";
- drNew["九江"] = "0.00%";
- drNew["新疆"] = "0.00%";
- drNew["新乡"] = "0.00%";
- drNew["车用尿素"] = "0.00%";
- drNew["合计"] = "0.00%";
- }
- }
- else
- {
- drNew["东北"] = saledongbei.ToString();
- drNew["九江"] = salejiujiang.ToString();
- drNew["新疆"] = salexinjiang.ToString();
- drNew["新乡"] = salexinxiang.ToString();
- drNew["车用尿素"] = cheyongniaosu.ToString();
- drNew["合计"] = total.ToString();
- }
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("销售基地明细表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 销售基地明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetSalesBaselist(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
- var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
- var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
- List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
- List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
- List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
- List<Model.T_Wo_WorkOrder> workerdongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'");
- List<Model.T_Wo_WorkOrder> workerjiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'");
- List<Model.T_Wo_WorkOrder> workerxinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'");
- List<Model.T_Wo_WorkOrder> workerxinxiang = woBLL.GetModelList(sql + "and F_SalesBase='新乡'");
- List<Model.T_Wo_WorkOrder> workerniaosu = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'");
- List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
- List<market> markets = new List<market>();
- for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
- {
- int saledongbei = 0;
- int salejiujiang = 0;
- int salexinjiang = 0;
- int salexinxiang = 0;
- int cheyong = 0;
- int total = 0;
- saledongbei = workercount(i, workerdongbei, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salejiujiang = workercount(i, workerjiujiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salexinjiang = workercount(i, workerxinjiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- salexinxiang = workercount(i, workerxinxiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
- cheyong = workercount(i, workerniaosu, ConsultingNeedslist, Complaintlist, SpotChecklist);
- total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
- market brand = new market();
- switch (i)
- {
- case 0:
- brand.typename = "合计";
- break;
- case 1:
- brand.typename = "即时办结率";
- break;
- case 2:
- brand.typename = "超期数量";
- break;
- case 3:
- brand.typename = "满意数量";
- break;
- case 4:
- brand.typename = "不满意数量";
- break;
- }
- if (i < ConsultingNeedslist.Count + 5 && i >= 5)
- {
- brand.typename = ConsultingNeedslist[i - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
- {
- brand.typename = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
- {
- brand.typename = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
- }
- if (i == 1)
- {
- if (total > 0)
- {
- brand.saledongbei = string.Format("{0:f2}%", saledongbei / total * 100);
- brand.salejiujiang = string.Format("{0:f2}%", salejiujiang / total * 100);
- brand.salexinjiang = string.Format("{0:f2}%", salexinjiang / total * 100);
- brand.salexinxiang = string.Format("{0:f2}%", salexinxiang / total * 100);
- brand.cheyong = string.Format("{0:f2}%", cheyong / total * 100);
- brand.total = string.Format("{0:f2}%", 100);
- }
- else
- {
- brand.saledongbei = "0.00%";
- brand.salejiujiang = "0.00%";
- brand.salexinjiang = "0.00%";
- brand.salexinxiang = "0.00%";
- brand.cheyong = "0.00%";
- brand.total = "0.00%";
- }
- }
- else
- {
- brand.saledongbei = saledongbei.ToString();
- brand.salejiujiang = salejiujiang.ToString();
- brand.salexinjiang = salexinjiang.ToString();
- brand.salexinxiang = salexinxiang.ToString();
- brand.cheyong = cheyong.ToString();
- brand.total = total.ToString();
- }
- markets.Add(brand);
- }
- return Success("获取成功", markets);
- }
- public class Category
- {
- public string typename;
- public string urea;//尿素
- public string compound;//复合肥
- public string fertilizer;//水溶肥
- public string vehicle;//车用尿素
- public string melamine;//三聚氰胺
- public string methanol;//甲醇
- public string furfuryl;//糠醇
- public string humic;//腐植酸
- public string dimethyl;//二甲醚
- public string furfural;//糠醛
- public string liquid;//液氨
- public string other;//其他
-
- }
- /// <summary>
- /// 导出产品名称明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult ExitProductlist(string stime, string endtime)
- {
- DataTable dt = new DataTable();
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
- var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
- var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
- List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
- List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
- List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
- List<Model.T_Wo_WorkOrder> workerurea = woBLL.GetModelList(sql + "and F_TS_Category='尿素'");
- List<Model.T_Wo_WorkOrder> workercompound = woBLL.GetModelList(sql + "and F_TS_Category='复合肥'");
- List<Model.T_Wo_WorkOrder> workerfertilizer = woBLL.GetModelList(sql + "and F_TS_Category='水溶肥'");
- List<Model.T_Wo_WorkOrder> workervehicle = woBLL.GetModelList(sql + "and F_TS_Category='车用尿素'");
- List<Model.T_Wo_WorkOrder> workermelamine = woBLL.GetModelList(sql + "and F_TS_Category='三聚氰胺'");
- List<Model.T_Wo_WorkOrder> workermethanol = woBLL.GetModelList(sql + "and F_TS_Category='甲醇'");
- List<Model.T_Wo_WorkOrder> workerfurfuryl = woBLL.GetModelList(sql + "and F_TS_Category='糠醇'");
- List<Model.T_Wo_WorkOrder> workerhumic = woBLL.GetModelList(sql + "and F_TS_Category='腐植酸'");
- List<Model.T_Wo_WorkOrder> workerdimethyl = woBLL.GetModelList(sql + "and F_TS_Category='二甲醚'");
- List<Model.T_Wo_WorkOrder> workerfurfural = woBLL.GetModelList(sql + "and F_TS_Category='糠醛'");
- List<Model.T_Wo_WorkOrder> workerliquid = woBLL.GetModelList(sql + "and F_TS_Category='液氨'");
- List<Model.T_Wo_WorkOrder> workerother = woBLL.GetModelList(sql + "and F_TS_Category='其他'");
- List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
- dt.Columns.Add("类型");
- dt.Columns.Add("尿素");
- dt.Columns.Add("复合肥");
- dt.Columns.Add("水溶肥");
- dt.Columns.Add("车用尿素");
- dt.Columns.Add("三聚氰胺");
- dt.Columns.Add("甲醇");
- dt.Columns.Add("糠醇");
- dt.Columns.Add("腐植酸");
- dt.Columns.Add("二甲醚");
- dt.Columns.Add("糠醛");
- dt.Columns.Add("液氨");
- dt.Columns.Add("其他");
- for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
- {
- DataRow drNew = dt.NewRow();
- int urea = 0, compound = 0, fertilizer = 0, vehicle = 0, total = 0, melamine = 0, methanol = 0, furfuryl = 0
- , humic = 0, dimethyl = 0, furfural = 0, liquid = 0, other = 0;
- urea = workercount(i, workerurea, ConsultingNeedslist, Complaintlist, SpotChecklist);
- compound = workercount(i, workercompound, ConsultingNeedslist, Complaintlist, SpotChecklist);
- fertilizer = workercount(i, workerfertilizer, ConsultingNeedslist, Complaintlist, SpotChecklist);
- vehicle = workercount(i, workervehicle, ConsultingNeedslist, Complaintlist, SpotChecklist);
- melamine = workercount(i, workermelamine, ConsultingNeedslist, Complaintlist, SpotChecklist);
- methanol = workercount(i, workermethanol, ConsultingNeedslist, Complaintlist, SpotChecklist);
- furfuryl = workercount(i, workerfurfuryl, ConsultingNeedslist, Complaintlist, SpotChecklist);
- humic = workercount(i, workerhumic, ConsultingNeedslist, Complaintlist, SpotChecklist);
- dimethyl = workercount(i, workerdimethyl, ConsultingNeedslist, Complaintlist, SpotChecklist);
- furfural = workercount(i, workerfurfural, ConsultingNeedslist, Complaintlist, SpotChecklist);
- liquid = workercount(i, workerliquid, ConsultingNeedslist, Complaintlist, SpotChecklist);
- other = workercount(i, workerother, ConsultingNeedslist, Complaintlist, SpotChecklist);
- total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
- Category brand = new Category();
- switch (i)
- {
- case 0:
- drNew["类型"] = "合计";
- break;
- case 1:
- drNew["类型"] = "即时办结率";
- break;
- case 2:
- drNew["类型"] = "超期数量";
- break;
- case 3:
- drNew["类型"] = "满意数量";
- break;
- case 4:
- drNew["类型"] = "不满意数量";
- break;
- }
- if (i < ConsultingNeedslist.Count + 5 && i >= 5)
- {
- drNew["类型"] = ConsultingNeedslist[i - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
- {
- drNew["类型"] = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
- {
- drNew["类型"] = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
- }
- if (i == 1)
- {
- if (total > 0)
- {
- drNew["尿素"] = string.Format("{0:f2}%", urea / total * 100);
- drNew["复合肥"] = string.Format("{0:f2}%", compound / total * 100);
- drNew["水溶肥"] = string.Format("{0:f2}%", fertilizer / total * 100);
- drNew["车用尿素"] = string.Format("{0:f2}%", vehicle / total * 100);
- drNew["三聚氰胺"] = string.Format("{0:f2}%", melamine / total * 100);
- drNew["甲醇"] = string.Format("{0:f2}%", methanol / total * 100);
- drNew["糠醇"] = string.Format("{0:f2}%", furfuryl / total * 100);
- drNew["腐植酸"] = string.Format("{0:f2}%", humic / total * 100);
- drNew["二甲醚"] = string.Format("{0:f2}%", dimethyl / total * 100);
- drNew["糠醛"] =string.Format("{0:f2}%", furfural / total * 100);
- drNew["液氨"] = string.Format("{0:f2}%", liquid / total * 100);
- drNew["其他"] = string.Format("{0:f2}%", other / total * 100);
- }
- else
- {
- drNew["尿素"] = "0.00%";
- drNew["复合肥"] = "0.00%";
- drNew["水溶肥"] = "0.00%";
- drNew["车用尿素"] = "0.00%";
- drNew["三聚氰胺"] = "0.00%";
- drNew["甲醇"] = "0.00%";
- drNew["糠醇"] = "0.00%";
- drNew["腐植酸"] = "0.00%";
- drNew["二甲醚"] = "0.00%";
- drNew["糠醛"] = "0.00%";
- drNew["液氨"] = "0.00%";
- drNew["其他"] = "0.00%";
- }
- }
- else
- {
- drNew["尿素"] = urea.ToString();
- drNew["复合肥"] = compound.ToString();
- drNew["水溶肥"] = fertilizer.ToString();
- drNew["车用尿素"] = vehicle.ToString();
- drNew["三聚氰胺"] = melamine.ToString();
- drNew["甲醇"] = methanol.ToString();
- drNew["糠醇"] = furfuryl.ToString();
- drNew["腐植酸"] = humic.ToString();
- drNew["二甲醚"] = dimethyl.ToString();
- drNew["糠醛"] = furfural.ToString();
- drNew["液氨"] = liquid.ToString();
- drNew["其他"] = other.ToString();
- }
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("产品名称明细表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 产品名称明细表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetProductlist(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
- var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
- var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
- List<Model.T_Wo_WorkOrder> workerurea = woBLL.GetModelList(sql + "and F_TS_Category='尿素'");
- List<Model.T_Wo_WorkOrder> workercompound = woBLL.GetModelList(sql + "and F_TS_Category='复合肥'");
- List<Model.T_Wo_WorkOrder> workerfertilizer = woBLL.GetModelList(sql + "and F_TS_Category='水溶肥'");
- List<Model.T_Wo_WorkOrder> workervehicle = woBLL.GetModelList(sql + "and F_TS_Category='车用尿素'");
- List<Model.T_Wo_WorkOrder> workermelamine = woBLL.GetModelList(sql + "and F_TS_Category='三聚氰胺'");
- List<Model.T_Wo_WorkOrder> workermethanol = woBLL.GetModelList(sql + "and F_TS_Category='甲醇'");
- List<Model.T_Wo_WorkOrder> workerfurfuryl = woBLL.GetModelList(sql + "and F_TS_Category='糠醇'");
- List<Model.T_Wo_WorkOrder> workerhumic = woBLL.GetModelList(sql + "and F_TS_Category='腐植酸'");
- List<Model.T_Wo_WorkOrder> workerdimethyl = woBLL.GetModelList(sql + "and F_TS_Category='二甲醚'");
- List<Model.T_Wo_WorkOrder> workerfurfural = woBLL.GetModelList(sql + "and F_TS_Category='糠醛'");
- List<Model.T_Wo_WorkOrder> workerliquid = woBLL.GetModelList(sql + "and F_TS_Category='液氨'");
- List<Model.T_Wo_WorkOrder> workerother = woBLL.GetModelList(sql + "and F_TS_Category='其他'");
- List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql );
- List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
- List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
- List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
- List<Category> markets = new List<Category>();
- for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
- {
- float urea = 0, compound=0, fertilizer=0, vehicle=0, total=0, melamine=0, methanol=0, furfuryl=0
- , humic=0, dimethyl=0, furfural=0, liquid=0, other=0;
- urea = workercount(i, workerurea, ConsultingNeedslist, Complaintlist, SpotChecklist);
- compound = workercount(i, workercompound, ConsultingNeedslist, Complaintlist, SpotChecklist);
- fertilizer = workercount(i, workerfertilizer, ConsultingNeedslist, Complaintlist, SpotChecklist);
- vehicle = workercount(i, workervehicle, ConsultingNeedslist, Complaintlist, SpotChecklist);
- melamine = workercount(i, workermelamine, ConsultingNeedslist, Complaintlist, SpotChecklist);
- methanol = workercount(i, workermethanol, ConsultingNeedslist, Complaintlist, SpotChecklist);
- furfuryl = workercount(i, workerfurfuryl, ConsultingNeedslist, Complaintlist, SpotChecklist);
- humic = workercount(i, workerhumic, ConsultingNeedslist, Complaintlist, SpotChecklist);
- dimethyl = workercount(i, workerdimethyl, ConsultingNeedslist, Complaintlist, SpotChecklist);
- furfural = workercount(i, workerfurfural, ConsultingNeedslist, Complaintlist, SpotChecklist);
- liquid = workercount(i, workerliquid, ConsultingNeedslist, Complaintlist, SpotChecklist);
- other = workercount(i, workerother, ConsultingNeedslist, Complaintlist, SpotChecklist);
- total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
- Category brand = new Category();
- switch (i)
- {
- case 0:
- brand.typename = "合计";
- break;
- case 1:
- brand.typename = "即时办结率";
- break;
- case 2:
- brand.typename = "超期数量";
- break;
- case 3:
- brand.typename = "满意数量";
- break;
- case 4:
- brand.typename = "不满意数量";
- break;
- }
- if (i < ConsultingNeedslist.Count + 5 && i >= 5)
- {
- brand.typename = ConsultingNeedslist[i - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
- {
- brand.typename = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
- }
- else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
- {
- brand.typename = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
- }
- if (i == 1)
- {
- if (total > 0)
- {
- brand.urea = string.Format("{0:f2}%", urea / total * 100);
- brand.compound = string.Format("{0:f2}%", compound / total * 100);
- brand.fertilizer = string.Format("{0:f2}%", fertilizer / total * 100);
- brand.vehicle = string.Format("{0:f2}%", vehicle / total * 100);
- brand.melamine = string.Format("{0:f2}%", melamine / total * 100);
- brand.methanol = string.Format("{0:f2}%", methanol / total * 100);
- brand.furfuryl = string.Format("{0:f2}%", furfuryl / total * 100);
- brand.humic = string.Format("{0:f2}%", humic / total * 100);
- brand.dimethyl = string.Format("{0:f2}%", dimethyl / total * 100);
- brand.furfural = string.Format("{0:f2}%", furfural / total * 100);
- brand.liquid = string.Format("{0:f2}%", liquid / total * 100);
- brand.other = string.Format("{0:f2}%", other / total * 100);
- }
- else
- {
-
- brand.urea = "0.00%";
- brand.compound = "0.00%";
- brand.fertilizer = "0.00%";
- brand.vehicle = "0.00%";
- brand.melamine = "0.00%";
- brand.methanol = "0.00%";
- brand.furfuryl = "0.00%";
- brand.humic = "0.00%";
- brand.dimethyl = "0.00%";
- brand.furfural = "0.00%";
- brand.liquid = "0.00%";
- brand.other = "0.00%";
- }
- }
- else
- {
- brand.urea = urea.ToString();
- brand.compound = compound.ToString();
- brand.fertilizer = fertilizer.ToString();
- brand.vehicle = vehicle.ToString();
- brand.melamine = melamine.ToString();
- brand.methanol = methanol.ToString();
- brand.furfuryl = furfuryl.ToString();
- brand.humic = humic.ToString();
- brand.dimethyl = dimethyl.ToString();
- brand.furfural = furfural.ToString();
- brand.liquid = liquid.ToString();
- brand.other = other.ToString();
- }
- markets.Add(brand);
- }
- return Success("获取成功", markets);
- }
- public class Department
- {
- public string dapatname;
- public int pending;//待接单
- public int beprocessed;//待处理
- public int processed;//已处理
- public int Overdue;//超期
- public int satisfied;//满意
- public int dissatisfied;//不满意
- }
- public int GetDeptWorkOrderID(int deptId)
- {
- int str =0;
- var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + deptId);
-
- foreach (var it in user)
- {
- if (it .F_RoleId==59)
- {
- str = deptId;
- break;
- }
- }
- return str;
- }
- /// <summary>
- /// 导出部门工单数量表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult ExitDepartmentlist(string stime, string endtime)
- {
- DataTable dt = new DataTable();
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- var tab = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=0");
- List<int> modeldeptid = new List<int>();
- List<string> modeldeptname = new List<string>();
- foreach (var it in tab)
- {
- if (GetDeptWorkOrderID(it.F_DeptId) > 0)
- {
- modeldeptid.Add(it.F_DeptId);
- modeldeptname.Add(it.F_DeptName);
- }
- }
- dt.Columns.Add("部门名称");
- dt.Columns.Add("待接单");
- dt.Columns.Add("待处理");
- dt.Columns.Add("已处理");
- dt.Columns.Add("超期数量");
- dt.Columns.Add("满意数量");
- dt.Columns.Add("不满意数量");
-
- for (int i = 0; i < modeldeptid.Count; i++)
- {
- DataRow drNew = dt.NewRow();
- var itemlist = itembll.GetModelList("F_NextDept=" + modeldeptid[i]);
- drNew["部门名称"] = modeldeptname[i];
- int pending = 0; int beprocessed = 0; int processed = 0; int Overdue = 0; int satisfied = 0; int dissatisfied = 0;
- foreach (var it in itemlist)
- {
- if (it.F_IsUsed == 0 && it.F_OptType == 1)
- {
- pending++;
- var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
- Overdue++;
- }
- if (it.F_OptType == 2 && it.F_IsUsed == 0)
- {
- beprocessed++;
- var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
- Overdue++;
- }
- }
- var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + modeldeptid[i]);
- foreach (var it in user)
- {
- if (it.F_RoleId == 59)
- {
- var workorder = woBLL.GetModelList(sql + "and F_State=10 and F_DealBy='" + it.F_UserCode + "'");
- processed += workorder.Count;
- foreach (var im in workorder)
- {
- if (im.F_IsOver == 1)
- Overdue++;
- if (im.F_VisitResult == "满意" || im.F_VisitResult == "非常满意")
- satisfied++;
- if (im.F_VisitResult == "不满意")
- dissatisfied++;
- }
- }
-
- }
- drNew["待接单"] = pending;
- drNew["待处理"] = beprocessed;
- drNew["已处理"] = processed;
- drNew["超期数量"] = Overdue;
- drNew["满意数量"] = satisfied;
- drNew["不满意数量"] = dissatisfied;
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("部门工单数量表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 部门工单数量表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetDepartmentList(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- var tab = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=0");
- List<int> modeldeptid = new List<int>();
- List<string > modeldeptname= new List<string>();
- foreach (var it in tab)
- {
- if (GetDeptWorkOrderID(it .F_DeptId )>0)
- {
- modeldeptid.Add(it.F_DeptId);
- modeldeptname.Add(it.F_DeptName);
- }
- }
- List<Department> Departmentlist = new List<Department>();
- for (int i=0;i< modeldeptid.Count;i++)
- {
- var itemlist = itembll.GetModelList("F_NextDept=" + modeldeptid[i]);
- Department model = new Department();
- model.dapatname = modeldeptname[i];
- int pending = 0;int beprocessed = 0;int processed = 0;int Overdue = 0;int satisfied = 0;int dissatisfied = 0;
- foreach (var it in itemlist)
- {
- if (it .F_IsUsed ==0&&it .F_OptType ==1)
- {
- pending++;
- var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID );
- Overdue++;
- }
- if (it .F_OptType ==2&& it.F_IsUsed == 0)
- {
- beprocessed++;
- var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
- Overdue++;
- }
- }
- var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + modeldeptid[i ]);
- foreach (var it in user)
- {
- if (it.F_RoleId == 59)
- {
- var workorder = woBLL.GetModelList(sql + "and F_State=10 and F_DealBy='" + it.F_UserCode + "'");
- processed += workorder.Count;
- foreach (var im in workorder)
- {
- if (im .F_IsOver ==1)
- Overdue++;
- if (im.F_VisitResult == "满意" || im.F_VisitResult == "非常满意")
- satisfied++;
- if (im.F_VisitResult == "不满意")
- dissatisfied++;
- }
- }
- }
- model.pending = pending;
- model.beprocessed = beprocessed;
- model.processed = processed;
- model.Overdue = Overdue;
- model.satisfied = satisfied;
- model.dissatisfied = dissatisfied;
- Departmentlist.Add(model);
- }
- if (Departmentlist.Count > 0)
- {
- for (int j = 0; j < Departmentlist.Count - 1; j++)
- {
- for (int z = 0; z < Departmentlist.Count - 1 - j; z++)
- {
- if (Departmentlist[z].processed < Departmentlist[z + 1].processed)
- {
- var temp = Departmentlist[z + 1];
- Departmentlist[z + 1] = Departmentlist[z];
- Departmentlist[z] = temp;
- }
- }
- }
- }
- return Success("获取成功", Departmentlist);
- }
- public class Returnvisit
- {
- public string name;
- public int bevisit;
- public int visit;
- public int Overdue;
- public int visitcont;
- public int verysatisfied;
- public int satisfied;
- public int commonly;
- public int dissatisfied;
- public int other;
-
- }
- /// <summary>
- /// 导出客户回访数量表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult ExitReturnvisitList(string stime, string endtime)
- {
- DataTable dt = new DataTable();
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- dt.Columns.Add("类别");
- dt.Columns.Add("待回访");
- dt.Columns.Add("已回访");
- dt.Columns.Add("回访总数");
- dt.Columns.Add("超期数量");
- dt.Columns.Add("满意数量");
- dt.Columns.Add("不满意数量");
- var workordewr = woBLL.GetModelList(sql + "and F_State in(10,11) and F_IsVisit =1");
- string name = "客户回访"; int bevisit = 0, visit = 0, Overdue = 0, satisfied = 0, dissatisfied = 0; int visitcont = 0;
- var workorder = woBLL.GetModelList(sql + "and F_State in(10,11)");
- visitcont = workorder.Count;
- foreach (var it in workordewr)
- {
- if (it.F_State == 10)
- bevisit++;
- if (it.F_State == 11)
- visit++;
- if (it.F_IsOver == 1&&it .F_Type !="3")
- Overdue++;
- if (it.F_VisitResult == "满意" || it.F_VisitResult == "非常满意")
- satisfied++;
- if (it.F_VisitResult == "不满意")
- dissatisfied++;
- }
- var obj = new
- {
- name,
- bevisit,
- visit,
- visitcont,
- Overdue,
- satisfied,
- dissatisfied
- };
- DataRow drNew = dt.NewRow();
- drNew["类别"] = name;
- drNew["待回访"] = bevisit;
- drNew["已回访"] = visit;
- drNew["回访总数"] = visitcont;
- drNew["超期数量"] = Overdue;
- drNew["满意数量"] = satisfied;
- drNew["不满意数量"] = dissatisfied;
- dt.Rows.Add(drNew);
-
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("客户回访数量表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 客户回访数量表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetReturnvisitList(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- List<Returnvisit> returnvisits = new List<Returnvisit>();
- Returnvisit model = new Returnvisit();
- var workordewr = woBLL.GetModelList(sql + "and F_State in(10,11) and F_IsVisit =1");
- model. name ="客户回访"; int bevisit = 0, visit = 0, Overdue = 0, verysatisfied = 0, satisfied=0, commonly=0, dissatisfied = 0;int visitcont = 0, other=0;
- var workorder = woBLL.GetModelList(sql + "and F_State in(10,11)");
- visitcont = workorder.Count;
- foreach (var it in workordewr)
- {
- if (it.F_State == 10)
- bevisit++;
- if (it.F_IsOver == 1)
- Overdue++;
- if (it.F_State == 11)
- {
- visit++;
- if (it.F_VisitResult == "非常满意")
- verysatisfied++;
- if (it.F_VisitResult == "满意")
- satisfied++;
- if (it.F_VisitResult == "一般")
- commonly++;
- if (it.F_VisitResult == "不满意")
- dissatisfied++;
- if (it.F_VisitResult == "其他" || it.F_VisitResult == "")
- other++;
- }
-
- }
- model.bevisit = bevisit; model.visit = visit; model.visitcont = visitcont; model.Overdue = Overdue;
- model.satisfied = satisfied; model.dissatisfied = dissatisfied; model.verysatisfied = verysatisfied;
- model.commonly = commonly;model.other = other;
- returnvisits.Add(model);
- return Success("获取成功", returnvisits
- );
- }
- private int workercount(int i , List<Model .T_Wo_WorkOrder> workerlist, List<Model.T_Wo_QuestionManage> ConsultingNeedslist, List<Model.T_Wo_QuestionManage> Complaintlist, List<Model.T_Wo_QuestionManage> SpotChecklist)
- {
- int total = 0;
- foreach (var it in workerlist)
- {
- switch (i)
- {
- case 0:
- total++;
- break;
- case 1:
- if (it.F_DealType == "当即办理")
- total++;
- break;
- case 2:
- if (it.F_IsOver == 1&&it .F_Type !="3")
- total++;
- break;
- case 3:
- if (it.F_VisitResult == "满意" || it.F_VisitResult == "非常满意")
- total++;
- break;
- case 4:
- if (it.F_VisitResult == "不满意")
- total++;
- break;
- }
- if (i < ConsultingNeedslist.Count + 5 && i >= 5)
- {
- if (it.F_QuestionType == ConsultingNeedslist[i - 5].F_Id.ToString () )
- total++;
- }
- else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
- {
- if (it.F_QuestionType == Complaintlist[i - ConsultingNeedslist.Count - 5].F_Id.ToString())
- total++;
- }
- else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count+ SpotChecklist.Count + 5)
- {
- if (it.F_QuestionType == SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_Id.ToString())
- total++;
- }
- }
- return total;
- }
- /// <summary>
- /// 导出集团市场问题反馈汇总表
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult ExptQuestionList(string stime, string endtime, string salesBase, string channel, int type = 0)
- {
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- sql += " order by F_CreateOn desc";
- var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
- #endregion
- dt.Columns.Add("创建时间");
- dt.Columns.Add("销售基地");
- dt.Columns.Add("渠道类型");
- dt.Columns.Add("反馈类型");
- dt.Columns.Add("费用");
- dt.Columns.Add("大区名称");
- dt.Columns.Add("分公司名称");
- dt.Columns.Add("业务员");
- dt.Columns.Add("品牌");
- dt.Columns.Add("产品");
- dt.Columns.Add("超时时限");
- dt.Columns.Add("回访与否");
- dt.Columns.Add("关闭与否");
- foreach (var it in depts)
- {
- DataRow drNew = dt.NewRow();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
-
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
- if (cuModel != null)
- {
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- drNew["大区名称"] = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- drNew["分公司名称"] = pdModel1.F_DeptName;
- }
- }
- drNew["业务员"] = cuModel.F_Salesman;
- drNew["品牌"] = cuModel.F_Brands;
- drNew["渠道类型"] = cuModel.F_Channel;
- }
-
- drNew["产品"] = it.F_TS_Category;
- if (it.F_Type == "1")
- {
- drNew["反馈类型"] = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (it.F_Type == "2")
- {
- drNew["反馈类型"] = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (it.F_Type == "3")
- {
- drNew["反馈类型"] = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else
- {
- drNew["反馈类型"] = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- drNew["销售基地"] = it.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- drNew["创建时间"] = it.F_CreateOn.ToString();
- if (it .F_Type !="3")
- {
- if (TimeToOver(it.F_ID, it.F_limit) < 0)
- drNew["超时时限"] = Math.Abs(TimeToOver(it.F_ID, it.F_limit)).ToString();
- else
- drNew["超时时限"] = "0";
- }
- else
- drNew["超时时限"] = "0";
- if (it.F_State == 11 && it.F_IsVisit == 1)
- drNew["回访与否"] = "是";
- else
- drNew["回访与否"] = "否";
- if (it.F_State == 11)
- drNew["关闭与否"] = "是";
- else
- drNew["关闭与否"] = "否";
- dt .Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("集团市场问题反馈汇总表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 集团市场问题反馈汇总表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetQuestionList(string stime, string endtime, string salesBase, string channel, int type = 0, int page = 1, int limit = 10)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- #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",
- limit,
- page,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<Questions> input = modeltooip(modlelist);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- /// <summary>
- /// 导出化肥产品投诉明细表
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult ExptComplaintList(string stime, string endtime, string salesBase, string channel)
- {
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化肥产品质量问题反馈','化肥服务质量问题反馈','化肥农作物长势问题反馈'") + "') "; ;
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- sql += " order by F_CreateOn desc";
- #endregion
- var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
- dt.Columns.Add("客户姓名");
- dt.Columns.Add("客户电话");
- dt.Columns.Add("公司名称");
- dt.Columns.Add("事发地-省");
- dt.Columns.Add("事发地-市");
- dt.Columns.Add("事发地-县");
- dt.Columns.Add("事发地-乡");
- dt.Columns.Add("事发地-详细");
- dt.Columns.Add("销售基地");
- dt.Columns.Add("大区名称");
- dt.Columns.Add("业务员");
- dt.Columns.Add("问题描述");
- dt.Columns.Add("问题类别1");
- dt.Columns.Add("问题类别2");
- dt.Columns.Add("问题类别3");
- dt.Columns.Add("客户编号");
- dt.Columns.Add("物料编码");
- dt.Columns.Add("物料名称");
- dt.Columns.Add("型号");
- dt.Columns.Add("规格");
- dt.Columns.Add("一级分类");
- dt.Columns.Add("二级分类");
- dt.Columns.Add("三级分类");
- dt.Columns.Add("品牌");
- dt.Columns.Add("复合肥肥效");
- dt.Columns.Add("产品线");
- dt.Columns.Add("工艺");
- dt.Columns.Add("生产批次号");
- dt.Columns.Add("问题数量");
- dt.Columns.Add("生产基地");
- dt.Columns.Add("初审意见");
- dt.Columns.Add("超出质保期限");
- dt.Columns.Add("质量事件等级");
- dt.Columns.Add("索赔金额");
- dt.Columns.Add("责任单位");
- dt.Columns.Add("审批意见");
- dt.Columns.Add("审批不同意意见");
- dt.Columns.Add("补偿方式");
- dt.Columns.Add("补偿钱款");
- dt.Columns.Add("对应责任单位");
- dt.Columns.Add("确认实收数量");
- dt.Columns.Add("改进要求");
- dt.Columns.Add("对应审批工作流单号");
- dt.Columns.Add("处理方式");
- dt.Columns.Add("处理人");
- dt.Columns.Add("处理时间");
- dt.Columns.Add("处理内容");
- dt.Columns.Add("处理结果");
- dt.Columns.Add("未处理原因");
- dt.Columns.Add("添加时间");
- foreach (var it in depts)
- {
- DataRow drNew = dt.NewRow();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
- if (cuModel != null)
- {
- drNew["客户编号"] = cuModel.F_CustomerCode ;//
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- drNew["大区名称"] = pdModel.F_DeptName;
- }
- }
- drNew["业务员"] = cuModel.F_Salesman;//业务员
- }
-
- if (!string .IsNullOrEmpty (it.F_MaterialID))
- {
- if (valcode(it.F_MaterialID.ToString(), 11))
- {
- drNew["物料编码"] = it.F_MaterialID;//验证物料编码为11位纯数字
- Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(it.F_MaterialID.ToString());//通过物料编码获取物料信息
- if (maModel != null)
- {
- drNew["物料名称"] = maModel.F_MaterialName;//物料名称
- drNew["型号"] = maModel.F_Model;//型号
- drNew["规格"] = maModel.F_Specs;//规格
- drNew["一级分类"] = maModel.F_Level1;//一级分类
- drNew["二级分类"] = maModel.F_Level2;//二级分类
- drNew["三级分类"] = maModel.F_Level3;//三级分类
- drNew["品牌"] = maModel.F_Brand;//品牌
- drNew["复合肥肥效"] = maModel.F_MaterialEffect;//F_MaterialEffect
- drNew["产品线"] = maModel.F_Pipeline;//F_Pipeline
- drNew["工艺"] = maModel.F_Craft;//F_Craft
- }
- }
- }
-
- if (!string.IsNullOrEmpty(it.F_QuestionType))
- {
- Model.T_Wo_QuestionManage Manage = null;
- try
- {
- int b = int.Parse(it.F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
- }
- catch (Exception)
- {
- Manage = quesBLL.GetModel(it.F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
- }
- if (Manage != null)
- {
- if (Manage.F_Label == "1")
- {
- drNew["问题类别1"] = Manage.F_QuestionName;
- drNew["问题类别2"] = "";
- drNew["问题类别3"] = "";
- }
- else if (Manage.F_Label == "2")
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- drNew["问题类别1"] = Manage1.F_QuestionName;
- drNew["问题类别2"] = Manage.F_QuestionName;
- drNew["问题类别3"] = "";
- }
- else
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
- drNew["问题类别1"] = Manage2.F_QuestionName;//问题类别1
- drNew["问题类别2"] = Manage1.F_QuestionName;//问题类别2
- drNew["问题类别3"] = Manage.F_QuestionName;//问题类别3
- }
- }
- }
- drNew["客户姓名"] = it.F_CusName;//客户姓名
- drNew["客户电话"] = it.F_CusPhone;//
- drNew["公司名称"] = it.F_CompanyName;//
- drNew["事发地-省"] = it.F_IncidentProvince;//
- drNew["事发地-市"] = it.F_IncidentCity;//
- drNew["事发地-县"] = it.F_IncidentCountry;//
- drNew["事发地-乡"] = it.F_IncidentTownship;//
- drNew["事发地-详细"] = it.F_IncidentDetailed;//
- drNew["销售基地"] = it.F_SalesBase;//:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- drNew["问题描述"] = it.F_Description;//
- drNew["生产批次号"] = it.F_BatchNumber;//
- drNew["问题数量"] = it.F_TS_Quantity;//投诉-(吨)
- drNew["生产基地"] = it.F_SC_ProductBase;//市场管理科-(新乡、新疆、九江、东北、贴牌、无法确定)
- drNew["初审意见"] = it.F_SC_PreliminaryOpinion;// 市场管理科-:退货、换货、补偿、自行处理
- drNew["超出质保期限"] = it.F_SC_QualityMonth;//市场管理科-(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
- drNew["质量事件等级"] = it.F_ZL_QualityEventLevel;// 质量管理科-(未遂、一般、较大、重大)
- drNew["索赔金额"] = it.F_ZL_ClaimAmount;//质量管理科-(单位元,对应责任单位)
- drNew["责任单位"] = it.F_ZL_ResponsibleUnit;//质量管理科-(需列出,可选多个)
- drNew["审批意见"] = it.F_ZL_ApprovalOpinions;// 质量管理科-(同意、不同意,若选择不同意,增加输入框输入补充内容)
- drNew["审批不同意意见"] = it.F_ZL_ApprovalDisagree;// 质量管理科-
- drNew["补偿方式"] = it.F_ZL_CompensationMethod;//质量管理科-(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
- drNew["补偿钱款"] = it.F_ZL_CompensationMoney;// 质量管理科-
- drNew["对应责任单位"] = it.F_ZL_CResponsibleUnits;//质量管理科-(生产、研发、农化、物流、质量管理科,销售内勤)
- drNew["确认实收数量"] = it.F_ZL_Fquantity;// 质量管理科-(吨)
- drNew["改进要求"] = it.F_ZL_ImprovementRequirements;//质量管理科-
- drNew["对应审批工作流单号"] = it.F_ZL_CApprovalNo;//质量管理科-
- drNew["处理方式"] = it.F_DealType;//:当即办理、电话转接、网络转办
- drNew["处理人"] = it.F_DealBy;//
- drNew["处理时间"] = it.F_DealTime;//
- drNew["处理内容"] = it.F_DealContent;//
- if (it.F_State == 10 || it.F_State == 11)
- drNew["处理结果"] = "已处理";//处理结果
- else
- drNew["处理结果"] = "未处理";//处理结果
- drNew["未处理原因"] = it.F_DealReasons;//
- drNew["添加时间"] = it.F_CreateOn; ;//
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("化肥产品投诉明细表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 获取问题类别
- /// </summary>
- /// <returns></returns>
- public string GetComplaint(string msg)
- {
- string str = "";
- string str1 = " select F_Id from T_Wo_QuestionManage where F_QuestionName in(" + msg + ")";
- string str3 = " select F_Id from T_Wo_QuestionManage where F_ParentId in(" + str1 + ")";
- var dept = quesBLL .GetModelList("F_ParentId in(" + str3+")");
- if (dept != null)
- {
- foreach (var it in dept)
- {
-
- if (str != "")
- str += "','" + it.F_Id ;
- else
- str += it.F_Id;
-
- }
- }
- // string str4 = " select F_Id from T_Wo_QuestionManage where F_ParentId in(" + str3 + ")";
- return str;
- }
- /// <summary>
- /// 化肥产品投诉明细表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetComplaintList(string stime, string endtime, string salesBase, string channel, int page = 1, int limit = 10)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化肥产品质量问题反馈','化肥服务质量问题反馈','化肥农作物长势问题反馈'") + "') "; ;
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- #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",
- limit,
- page,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<WorkOrderComplaint> input = modelComplaint(modlelist);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- /// <summary>
- /// 导出市场投诉处理时效明细表
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult ExptPrescriptionList(string stime, string endtime, string salesBase, string channel)
- {
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- sql += " order by F_CreateOn desc";
- var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
- #endregion
- dt.Columns.Add("创建时间");
- dt.Columns.Add("销售基地");
- dt.Columns.Add("大区名称");
- dt.Columns.Add("分公司名称");
- dt.Columns.Add("产品");
- dt.Columns.Add("品牌");
- dt.Columns.Add("问题类别1");
- dt.Columns.Add("问题类别2");
- dt.Columns.Add("问题类别3");
- dt.Columns.Add("问题描述");
- dt.Columns.Add("生产基地");
- dt.Columns.Add("对应责任单位");
- foreach (var it in depts)
- {
- DataRow drNew = dt.NewRow();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
- if (cuModel != null)
- {
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- drNew["大区名称"] = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- drNew["分公司名称"] = pdModel1.F_DeptName;
- }
- }
- drNew["品牌"] = cuModel.F_Brands;//品牌
- }
-
- if (!string.IsNullOrEmpty(it.F_QuestionType))
- {
- Model.T_Wo_QuestionManage Manage = null ;
- try
- {
- int b = int.Parse(it.F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
-
- }
- catch (Exception)
- {
- Manage = quesBLL.GetModel(it.F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
- }
- if (Manage != null)
- {
- if (Manage.F_Label == "1")
- {
- drNew["问题类别1"] = Manage.F_QuestionName;
- drNew["问题类别2"] = "";
- drNew["问题类别3"] = "";
- }
- else if (Manage.F_Label == "2")
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- drNew["问题类别1"] = Manage1.F_QuestionName;
- drNew["问题类别2"] = Manage.F_QuestionName;
- drNew["问题类别3"] = "";
- }
- else
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
- drNew["问题类别1"] = Manage2.F_QuestionName;//问题类别1
- drNew["问题类别2"] = Manage1.F_QuestionName;//问题类别2
- drNew["问题类别3"] = Manage.F_QuestionName;//问题类别3
- }
- }
- }
- drNew["生产基地"] = it.F_SC_ProductBase;//生产基地
- drNew["对应责任单位"] = it.F_ZL_CResponsibleUnits;//责任科室
- drNew["问题描述"] = it.F_Description;//问题描述
- drNew["产品"] = it.F_TS_Category;//产品
- drNew["销售基地"] = it.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- drNew["创建时间"] = it.F_CreateOn.ToString();//时间
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("市场投诉处理时效明细表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 市场投诉处理时效明细表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetPrescriptionList(string stime, string endtime, string salesBase, string channel, string
- question, int page = 1, int limit = 10)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrEmpty(question))
- {
- sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'" + question + "'") + "') "; ;
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- #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",
- limit,
- page,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<Prescription> input = modelPrescription(modlelist);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- /// <summary>
- /// 导出化工产品市场投诉汇总表
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult ExptChemicalList(string stime, string endtime, string salesBase, string channel)
- {
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化工产品质量问题反馈','化工服务质量问题反馈'") + "') "; ;
- // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- sql += " order by F_CreateOn desc";
- var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
- #endregion
- dt.Columns.Add("化工产品名称");
- dt.Columns.Add("客户单位");
- dt.Columns.Add("生产日期");
- dt.Columns.Add("反馈日期");
- dt.Columns.Add("喷码");
- dt.Columns.Add("问题分类");
- dt.Columns.Add("问题描述");
- dt.Columns.Add("处理方法");
- dt.Columns.Add("责任部门");
- dt.Columns.Add("销售基地");
- dt.Columns.Add("业务员");
- foreach (var it in depts)
- {
- DataRow drNew = dt.NewRow();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
-
- if (cuModel != null)
- {
- Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- drNew["业务员"] = cuModel.F_Salesman;//业务员
- }
-
-
- drNew["化工产品名称"] = it.F_TS_Category;//产品
- drNew["客户单位"] = it.F_CompanyName;//客户单位
- if (!string.IsNullOrEmpty(it.F_BatchNumber))
- {
- var prono = it.F_BatchNumber.Substring(0, 6);
- try
- {
- var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
- // var protime = Convert.ToDateTime(pronos);
- drNew["生产日期"] = pronos;
- }
- catch
- {
- drNew["生产日期"] = "";
- }
- }
- drNew["反馈日期"] = it.F_CreateOn.ToString(); ;
- drNew["喷码"] = it.F_BatchNumber;
- Model.T_Wo_QuestionManage Manage = null;
- try
- {
- int b = int.Parse(it.F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
- if (Manage!=null )
- {
- drNew["问题分类"] = Manage.F_QuestionName ;
- }
-
- }
- catch (Exception)
- {
- drNew["问题分类"] = it.F_QuestionType;
- }
-
- drNew["问题描述"] = it.F_Description;
- drNew["处理方法"] = it.F_DealType;
- drNew["责任部门"] = it.F_ZL_CResponsibleUnits;
- drNew["销售基地"] = it.F_SalesBase;
- dt.Rows.Add(drNew);
- }
- NPOIHelper npoi = new NPOIHelper();
- if (npoi.ExportToExcel("化工产品市场投诉汇总表", dt) == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- /// <summary>
- /// 化工产品市场投诉汇总表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetChemicalList(string stime, string endtime, string salesBase, string channel, int page = 1, int limit = 10)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- sql += $" and F_Type=" + 2;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化工产品质量问题反馈','化工服务质量问题反馈'") + "') "; ;
- //sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- #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",
- limit,
- page,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<Product> input = modelProduct(modlelist);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- public class Feedback
- {
- public string name;
- public int daynumber;
- public int mounthnumber;
- public int Totalnumber;
- public string Proportion;
- }
- public class Comling
- {
- public string name;
- public int typeid;
- public int number;//数量
- public List<Complainthand> Complainthand;
- /// <summary>
- /// 效率提升率
- /// </summary>
- public string efficiency = "0%";//
- public List<worker> worker;
- }
- public class Complainthandling
- {
- public string name;
- public int typeid;
- public int number;//数量
- public List<Complainthand> Complainthand;
- /// <summary>
- /// 用时最长
- /// </summary>
- public string ongesttime="0h";//
- /// <summary>
- /// 用时最短
- /// </summary>
- public string minimumtime = "0h";//
- /// <summary>
- /// 平均用时
- /// </summary>
- public string averageTime = "0h";//
- /// <summary>
- /// 中位数
- /// </summary>
- public string median = "0h";//
- /// <summary>
- /// 超期数量
- /// </summary>
- public string Overdue="0";//
- /// <summary>
- /// 超期数量
- /// </summary>
- public string EndOverdue = "0";//
- /// <summary>
- /// 效率提升率
- /// </summary>
- public string efficiency = "0%";//
- public List<worker> worker;
- }
- public class Complainthand
- {
- public string name;
- public string total="0";
- }
- public class Channel
- {
- public string channel;//渠道
- public int Telephone;//电话
- public int WeChat;//微信
- public int Immediate;//即时办结
- public int Transfer;//即时转接
- public int Verysatisfied;//非常满意
- public int Satisfaction;//满意度
- public int Commonly;//一般
- public int Unsatisfactory;//不满意
- public int Total;
- }
- public class BigDate
- {
- public List<Template> salesBase;//反馈类型
- public List<Template> product;//产品
- public List<Template> channel;//渠道
- public List<Template> state;//工单状态
- public List<Template> satisfaction;//满意度
- public List<Template> overdue;//超期
- }
- /// <summary>
- /// 反馈类型
- /// </summary>
- public class Template
- {
- public string name;//名称
- public int number;// 数量
- public int Lastyearnumber;//去年同比
- public int Lastmonthnumber;//上月同比
- public int Lastyear;//去年同比
- public int Lastmonth;//上月同比
- }
-
- public string GetCustomerCode(int area=0,int branch=0,string channel="")
- {
- string str = "";
- string sql = "";
- if (area >0)
- {
- sql += " and F_AreaID =" + area;
- }
- if (branch>0)
- {
- sql += " and F_BranchID =" + branch;
- }
- if (channel!="")
- {
- sql += " and F_Channel= '" + channel + "'";
- }
- if (sql != "")
- {
- str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + sql;
- }
- return str;
- }
- public string GetCustomerrel(int area = 0, int branch = 0, string channel = "")
- {
- string str = "";
- string sql = "";
- if (area > 0)
- {
- sql += " and F_AreaID =" + area;
- }
- if (branch > 0)
- {
- sql += " and F_BranchID =" + branch;
- }
- if (channel != "")
- {
- sql += " and F_Channel= '" + channel + "'";
- }
- str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" +sql;
- return str;
- }
- /// <summary>
- /// 大数据一览表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetBigdataList(string stime, string endtime,string salesBase ,string product,string channel, int area=0,int branch=0, int type = 0)
- {
- #region
- if (!Refresh())
- {
- return Error("查询失败");
- }
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (string.IsNullOrEmpty(stime))
- {
- stime = DateTime.Now.Date.ToString("yyyy-MM-01");
- }
- if (string.IsNullOrEmpty(endtime))
- {
- endtime = DateTime.Now.Date.ToString("yyyy-MM-dd");
- }
- int Months = 1;
- if (!string.IsNullOrEmpty(stime)&& !string.IsNullOrEmpty(endtime))
- {
- Months = DateTime.Parse(endtime).Month - DateTime.Parse(stime).Month;
- if (DateTime.Parse(endtime).Day > DateTime.Parse(stime).Day )
- {
- Months = Months + 1;
- }
- }
- string smouth= Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).AddMonths(-Months).ToLongDateString()).ToString("yyyy-MM-dd");
- string endmouth = Convert.ToDateTime(DateTime.Parse(endtime).AddDays(1 - DateTime.Parse(endtime).Day).AddMonths(-Months).AddMonths(1).AddDays(-1).ToLongDateString()).ToString("yyyy-MM-dd");
- string syear = Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).Date.AddYears (-1).ToLongDateString()).ToString("yyyy-MM-dd");
- string endyear= Convert.ToDateTime(DateTime.Parse(endtime).AddDays(1 - DateTime.Parse(endtime).Day).Date.AddMonths(1).AddSeconds(-1).AddYears(-1).ToLongDateString()).ToString("yyyy-MM-dd");
- #endregion
- string time = $" and datediff(day,F_CreateOn,'{stime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ";
- string lastmouth = $" and datediff(day,F_CreateOn,'{smouth}')<=0 and datediff(day,F_CreateOn,'{endmouth}')>=0 ";
- string lastyear= $" and datediff(day,F_CreateOn,'{syear}')<=0 and datediff(day,F_CreateOn,'{endyear}')>=0 ";
- BigDate model = new BigDate();
- model.salesBase = new List<Template>();
- if (type >0)
- {
- sql += $"and F_Type = " + type;
- }
- if (!string.IsNullOrEmpty(salesBase))
- {
- sql += $" and F_SalesBase='" + salesBase.Trim() + "'";
- }
-
- if (area > 0 || branch > 0 || !string.IsNullOrEmpty(channel))
- {
- sql += " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, channel) + ") ";
- }
-
- if (!string.IsNullOrEmpty(product))
- {
- sql += $" and F_TS_Category='" + product.Trim() + "'";
- }
- #region 反馈类型
- for (int i=0;i <5;i++)
- {
- string sqltype = "";
- Template template = new Template() ;
- switch (i)
- {
- case 0:
- template.name = "合计";
- break;
- case 1:
- template.name = "新乡";
- break;
- case 2:
- template.name = "新疆";
- break;
- case 3:
- template.name = "九江";
- break;
- case 4:
- template.name = "东北";
- break;
- }
- if (i > 0)
- {
- sqltype = $"and F_SalesBase = '" + template.name + "'";
- }
- else
- {
- if (string.IsNullOrEmpty(salesBase))
- {
- sqltype = $"and F_SalesBase in('新乡','新疆', '九江','东北')";
- }
- }
- model.salesBase.Add(ReturenTemplate(template, sql+ sqltype, time, lastmouth, lastyear));
- }
- #endregion
- #region 产品
- var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
- model.product = new List<Template>();
- List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
- if (dicv != null)
- {
- dicval = dicvalueBll.DataTableToList(dicv);
- }
- if (dicval != null && dicval.Count > 0)
- {
- string msf = "";
- foreach (var it in dicval)
- {
- if (msf == "")
- msf += " '" + it.F_Name + "'";
- else
- msf += " ,'" + it.F_Name + "'";
- }
- Template template = new Template();
- template.name = "合计";
- if (string.IsNullOrEmpty(product))
- {
- model.product.Add(ReturenTemplate(template, sql + $"and F_TS_Category in (" + msf + ")", time, lastmouth, lastyear));
- }
- else
- {
- model.product.Add(ReturenTemplate(template, sql , time, lastmouth, lastyear));
- }
-
- foreach (var it in dicval)
- {
- Template templates = new Template();
- string mag = "";
- mag = $"and F_TS_Category = '" + it.F_Name+"'";
- templates.name = it.F_Name;
- model.product.Add(ReturenTemplate(templates, sql + mag, time, lastmouth, lastyear));
- }
- }
- #endregion
- #region 渠道类型
- var QDLX = dicvalueBll.GetList(" F_DictionaryFlag='" + "QDLX" + "' and F_State=1 ").Tables[0];
- model.channel = new List<Template>();
- List<Model.T_Sys_DictionaryValue> QDLXl = new List<Model.T_Sys_DictionaryValue>();
- if (QDLX != null)
- {
- QDLXl = dicvalueBll.DataTableToList(QDLX);
- }
- if (QDLXl != null && QDLXl.Count > 0)
- {
- Template templates = new Template();
- templates.name = "合计";
- model.channel.Add(ReturenTemplate(templates, sql , time, lastmouth, lastyear));
- foreach (var it in QDLXl)
- {
- Template template = new Template();
- string str = "";
- str = " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, it.F_Name) + ") ";
- template.name = it.F_Name;
- model.channel.Add(ReturenTemplate(template,sql + str, time, lastmouth, lastyear));
- }
- }
- #endregion
- #region 工单类型
- model.state = new List<Template>();
- for (int i = 0; i < 5; i++)
- {
- string sqlchannel = "";
-
- Template template = new Template();
- switch (i)
- {
- case 0:
- template.name = "合计";
- break;
- case 1:
- template.name = "待处理";
- sqlchannel = " and F_State in (0, 1, 2, 3, 4, 5, 6, 7, 12, 14, 16)";
- break;
- case 2:
- template.name = "已处理";
- sqlchannel = " and F_State in (10,11)";
- break;
- case 3:
- template.name = "待回访";
- sqlchannel = " and F_State in (10) and F_IsVisit=1";
- break;
- case 4:
- template.name = "已回访";
- sqlchannel = " and F_State in (11) and F_IsVisit=1 and F_DealType!='当即办理' and F_VisitBy !=''";
- break;
-
- }
- model.state.Add(ReturenTemplate(template,sql + sqlchannel, time, lastmouth, lastyear));
- }
- #endregion
- #region 满意度
- model.satisfaction = new List<Template>();
- for (int i = 0; i <5; i++)
- {
- string sqlsatisfaction = "";
- sqlsatisfaction += " and F_State in (11)";
- sqlsatisfaction += " and F_IsVisit =1";
- Template template = new Template();
- switch (i)
- {
- case 0:
- template.name += "合计";
- sqlsatisfaction += " and F_VisitResult in ('非常满意','满意','一般','不满意')";
- break;
- case 1:
- template.name = "非常满意";
- sqlsatisfaction += " and F_VisitResult ='非常满意'";
- break;
- case 2:
- template.name = "满意";
- sqlsatisfaction += " and F_VisitResult ='满意'";
- break;
- case 3:
- template.name = "一般";
- sqlsatisfaction += " and F_VisitResult ='一般'";
- break;
- case 4:
- template.name = "不满意";
- sqlsatisfaction += " and F_VisitResult ='不满意'";
- break;
-
- }
- model.satisfaction .Add(ReturenTemplate(template,sql + sqlsatisfaction, time, lastmouth, lastyear));
- #endregion
-
-
- }
- #endregion
- #region 超期工单
- model.overdue = new List<Template>();
- string sqloverdue = "";
- sqloverdue += "";
- var modlelist = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1 " + time);
- Template templatee = new Template();
- templatee.name = "合计";
- templatee.number =0;
- model.overdue.Add(templatee);
- if (modlelist.Count > 0)
- {
- foreach (var it in modlelist)
- {
- var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + "and F_WoState=1" + " order by F_ID desc");
-
- if (itemList.Count > 0)
- {
- if (itemList[0].F_NextDept > 0)
- {
- var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
- if (model.overdue.Count > 0)
- {
-
- int overdue = 0;
- foreach (var im in model.overdue)
- {
- if (im.name == deptmodel.F_DeptName)
- {
- im.number += 1;
- overdue = 1;
- }
- if (im .name =="合计")
- {
- im.number += 1;
- }
- }
- if (overdue == 0)
- {
- Template templates = new Template();
- templates.name = deptmodel.F_DeptName;
- templates.number = 1;
- model.overdue.Add(templates);
- }
- }
- else
- {
- Template templates = new Template();
- templates.name = deptmodel.F_DeptName;
- templates.number = 1;
- model.overdue.Add(templates);
- }
- }
- else
- {
- if (itemList[0].F_WoState ==10)
- {
- var deptmodel = departmentBLL.GetModel(2);
- Template templates = new Template();
- templates.name = deptmodel.F_DeptName;
- templates.number = 1;
- model.overdue.Add(templates);
- }
- }
- }
- }
- }
- if (model.overdue.Count > 0)
- {
- foreach (var it in model.overdue)
- {
- if (it .name =="合计")
- {
- var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth).Count ;
- var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear).Count ;
- it.Lastmonthnumber = lastmouthmodlel;
- it.Lastyearnumber = lastyearmodlel;
- it.Lastmonth = it.number - lastmouthmodlel;
- it.Lastyear = it.number - lastyearmodlel;
-
- }
- else
- {
- var deptmodel = departmentBLL.GetModel(it.name);
- var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth);
- int lastmouthlist = 0;
- int lastyearlist = 0;
- if (lastmouthmodlel.Count > 0)
- {
- foreach (var im in lastmouthmodlel)
- {
- var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
- if (itemList.Count > 0)
- {
- lastmouthlist++;
- }
- }
- }
- var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear);
- if (lastyearmodlel.Count > 0)
- {
- foreach (var im in lastyearmodlel)
- {
- var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
- if (itemList.Count > 0)
- {
- lastyearlist++;
- }
- }
- }
- it.Lastmonthnumber = lastmouthlist;
- it.Lastyearnumber = lastyearlist;
- it.Lastmonth= it.number - lastmouthlist;
- it.Lastyear= it.number - lastyearlist;
-
-
- }
- }
-
- }
- if (model.overdue.Count > 0)
- {
- for (int j = 0; j < model.overdue.Count - 1; j++)
- {
- for (int z = 0; z < model.overdue.Count - 1 - j; z++)
- {
- if (model.overdue[z].number < model.overdue[z + 1].number)
- {
- var temp = model.overdue[z + 1];
- model.overdue[z + 1] = model.overdue[z];
- model.overdue[z] = temp;
- }
- }
- }
- }
- #endregion
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = model,
- total = 6
- };
- return Content(obj.ToJson()); ;
- }
-
-
- private bool Refresh()
- {
- int type = 0;
- var modlelist = workOrder.GetModelList(" F_IsDelete=0 " + "and F_IsOver=0" + " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
- (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish + ")");
- if (modlelist.Count > 0)
- {
- foreach (var it in modlelist)
- {
- if (TimeforOver(it.F_ID))
- {
- type = 0;
- }
- else
- {
- type = 1;
- }
- if (type != it.F_IsOver)
- {
- it.F_IsOver = type;
- bool n = workOrder.Update(it);
- if (!n)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- /// <summary>
- /// 是否超时
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- private bool TimeforOver(int id)
- {
- var itemlasts = itembll.GetModelList(" F_WoID=" + id + " order by F_ID desc");
- string time1 = "", time2 = ""; int x = 0, y = 0;
- float time = 0;
- if (itemlasts.Count > 0)
- {
- for (int z = 0; z < itemlasts.Count; z++)
- {
- if (itemlasts[z].F_WoState >= 1)
- {
- if (itemlasts[z].F_WoState == 1)
- {
- x = z;
- time1 = itemlasts[z].F_CreateTime.ToString();
- time = float.Parse(itemlasts[z].F_LimitTime);
- break; ;
- }
- }
- }
- for (int i = 0; i < itemlasts.Count; i++)
- {
-
- if (itemlasts[i].F_WoState >= 1)
- {
- if (itemlasts[i].F_WoState == 11)
- {
- y = i;
- time2 = itemlasts[i].F_CreateTime.ToString();
- }
- }
- }
- if (time2 != "")
- {
- if (time1 != "")
- {
- if (x > y)
- {
-
- System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- else
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- }
- else
- {
- return true;
- }
- }
- else if (time1 != "")
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- if ((float)a.TotalHours > time)
- {
- return false;
- }
- }
- else
- {
- return true;
- }
- }
- else
- {
- return true;
- }
- return true;
- }
- public Template ReturenTemplate(Template template,string sql,string time,string lastmouth,string lastyear )
- {
- template.number = new BLL.T_Wo_WorkOrder().GetModelList(sql + time).Count;//
- int mounthnumber = 0, yearnumber = 0;
- mounthnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastmouth).Count;//
- yearnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastyear).Count;//
- template.Lastmonthnumber = mounthnumber;
- template.Lastyearnumber = yearnumber;
- template.Lastyear = template.number - yearnumber;
- template.Lastmonth = template.number - mounthnumber;
-
- return template;
- }
- /// <summary>
- /// 市场反馈一览表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetFeedbacklList(string stime, string endtime)
- {
- string sql = $" F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- List<Feedback> modelList = new List<Feedback>(5);
- string smonthtime = "";
- if (!string .IsNullOrEmpty (stime))
- {
- smonthtime = stime .Trim() + " 00:00:01 "; ;
- }
- else
- {
- smonthtime = DateTime.Now.Date.ToString("yyyy-MM-01 00:00:00");
- }
- if (string .IsNullOrEmpty (endtime))
- {
- endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- endtime = endtime + " 23:59:59 "; ;
- }
- string sdaytime = DateTime.Now.Date.ToString("yyyy-MM-dd 00:00:00");
-
- for (int i = 1; i <= 5; i++)
- {
- Feedback model = new Feedback();
- switch (i)
- {
- case 1:
- model.name = "咨询";
- break;
- case 2:
- model.name = "投诉";
- break;
- case 3:
- model.name = "抽检";
- break;
- case 4:
- model.name = "建议";
- break;
- case 5:
- model.name = "合计";
- break;
- }
- float a= workOrder.GetModelList(sql ).Count;
- if (i <5)
- {
-
- model .daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i ).Count;
- model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i).Count;
- model.Totalnumber = workOrder.GetModelList(sql + "and F_Type=" + i).Count;
- model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a*100);
- }
- else
- {
- model.daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " ).Count;
- model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ").Count;
- model.Totalnumber = workOrder.GetModelList(sql).Count;
- model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a * 100);
- }
-
-
- modelList.Add(model);
- }
- #endregion
-
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = modelList,
- total = 4
- };
- return Content(obj.ToJson()); ;
- }
-
- /// <summary>
- /// 渠道数量对比表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetChanelList(string stime, string endtime)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- #endregion
- List<string> channelname = new List<string>();
- channelname.Add("总经销");
- channelname.Add("二级商");
- channelname.Add("种田大户");
- channelname.Add("公司员工");
- channelname.Add("农户");
- channelname.Add("化工客户");
- channelname.Add("其他");
- int Distribution = 0, Quotient=0, Bigfarmer = 0, Companystaf = 0, Peasant = 0, Customers = 0, Other = 0;
- for (int i=0;i < channelname.Count;i++)
- {
- string msg = "'" +channelname[i] + "'";
- var modellist = woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(msg) + ")" + sql + "and F_Type in (2,3)");
- var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(msg) + ")" + sql + "and F_Type in (1,4)");
- switch (i )
- {
- case 0:
- Distribution = modellist.Count + modellis.Count;//总经销
- break;
- case 1:
- Quotient = modellist.Count + modellis.Count;//二级商
- break;
- case 2:
- Bigfarmer = modellist.Count + modellis.Count;//种田大户
- break;
- case 3:
- Companystaf = modellist.Count + modellis.Count;//公司员工
- break;
- case 4:
- Peasant = modellist.Count + modellis.Count;//农户
- break;
- case 5:
- Customers = modellist.Count + modellis.Count;//化工客户
- break;
- case 6:
- Other = modellist.Count + modellis.Count;//其他
- break;
- }
-
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows=new
- {
- Distribution,
- Quotient,
- Bigfarmer,
- Companystaf,
- Peasant,
- Customers,
- Other,
- }
- ,
- total =6
- };
- return Content(obj.ToJson()); ;
- }
- BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
- public class Brand
- {
- public string name;
- public int number;
- }
-
- /// <summary>
- /// 产品品牌对照表
- /// </summary>
- /// <param name="stime"></param>
- /// <param name="endtime"></param>
- /// <returns></returns>
- public ActionResult GetbrandList(string stime, string endtime)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- #endregion
- var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
- List<Brand> list = new List<Brand>();
- List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
- if (dicv !=null )
- {
- dicval = dicvalueBll.DataTableToList(dicv);
- }
- if (dicval !=null&& dicval.Count >0)
- {
- foreach (var it in dicval)
- {
- var modellist = woBLL.GetModelList(" F_TS_Category in ('" + it.F_Name + "')" + sql );
- Brand brand = new Brand();
- brand.name = it.F_Name;
- brand.number = modellist.Count;
- list.Add(brand);
- }
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = list
- ,
- total = list.Count ,
- };
- return Content(obj.ToJson()); ;
- }
- public class QuestionType
- {
- public string F_QuestionType;
- public int number;
- }
- public class worker
- {
- public string F_WorkOrderCode;//工单编号
- public string F_State;//工单状态
- public string overtime;//超期时间
- public double time;
- public string F_Description;//问题描述
- public string F_Responsibility;//责任科室
- public string F_SalesBase;//销售基地
- public string F_Type;//反馈类型
- }
-
- /// <summary>
- ///月份投诉处理周期表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetComplainthandlList(string salesBase,string stime ="", string endtime="", string questionName = "" ,int isEnd=0)
- {
- string sql = $" F_IsDelete=0";
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (isEnd ==1)
- sql += $" and F_State !=11";
- else if (isEnd == 2)
- sql += $" and F_State =11 ";
- string Queststr = "";
- bool k = true;
- if (questionName != "" && questionName != "0")
- {
- try
- {
- int a = int.Parse(questionName);
- }
- catch
- {
- k = false;
- }
- }
- if (questionName!=""&& questionName!="0")
- {
-
- if (k)
- {
- Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 and F_Label in(3) and F_Id='" + questionName + "'";
- }
- else
- {
- Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 and F_Label in(3) and F_QuestionName='" + questionName + "'";
- }
-
-
- }
- else
- {
- Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 AND F_Label in(3)";
- }
- int year = DateTime.Now.Year;//当前年
- int mouth = DateTime.Now.Month;//当前月
- if (stime != "")
- {
- year = DateTime.Parse(stime).Year;
- mouth = DateTime.Parse(stime).Month;
- }
- int beforeYear = 0;
- int beforeMouth = 0;
- if (mouth <= 1)//如果当前月是一月,那么年份就要减1
- {
- beforeYear = year - 1;
- beforeMouth = 12;//上个月
- }
- else
- {
- beforeYear = year;
- beforeMouth = mouth - 1;//上个月
- }
- string beforeMouthOneDay = beforeYear + "年" + beforeMouth + "月" + 1 + "日";//上个月第一天
- string beforeMouthLastDay = beforeYear + "年" + beforeMouth + "月" + DateTime.DaysInMonth(year, beforeMouth) + "日";//上个月最后一天
- string time1 = DateTime.Parse(beforeMouthOneDay).ToString("yyyy-MM-dd");
- string time2 = DateTime.Parse(beforeMouthLastDay).ToString("yyyy-MM-dd");
- sql += "and F_Type=2";
- string where= " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + time1.Trim() + " 00:00:01', 120) ";
- where += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + time2.Trim() + " 00:00:01', 120) ";
- var lastmodellist = workOrder.GetModelList(sql+ where);
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- else
- {
- // stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
- // sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- else
- {
- // endtime = DateTime.Now.ToString("yyyy-MM-dd");
- // sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
-
- var modellist = workOrder.GetModelList(sql);
- DataTable QuestionManage = DbHelperSQL.Query(Queststr).Tables[0];
- List<Model.T_Wo_QuestionManage> categorylist = quesBLL.DataTableToList(QuestionManage);
- List<Complainthandling> modeNamelList = new List<Complainthandling>(categorylist.Count);
- string category = "";
- foreach (var it in categorylist)
- {
- if (category != "")
- category += ",'" + it.F_Id+"'";
- else
- category+= "'"+it.F_Id+"'";
- }
- var categorymodellist = workOrder.GetModelList(sql+ "and F_QuestionType in ("+ category+")");
- #region
- if (questionName == "" || questionName == "0")
- {
- if (categorymodellist != null)
- {
- List<float> timehource = new List<float>();
- Complainthandling model = new Complainthandling();
- model.name = "合计";
- model.number = categorymodellist.Count;
- int Overdue = 0;
- int EndOverdue = 0;
- int efficiency = 0;
- model.worker = new List<worker>();
- int lastnumber = 0;
- foreach (var it in categorymodellist)
- {
- try
- {
- if (it.F_State == 10 || it.F_State == 11)
- {
- efficiency++;
- // System.TimeSpan id = DateTime.Parse(it.F_DealTime.ToString()) - DateTime.Parse//(it.F_CreateOn.ToString());
- // double t = id.TotalHours;
-
- }
- if (it.F_IsOver == 1&&it .F_Type !="3")
- {
- worker worker = new worker();
- worker.F_WorkOrderCode = it.F_WorkOrderCode;
- if (it.F_State == 1)
- worker.F_State = "待接单";
- else if (it.F_State == 2)
- worker.F_State = "待处理";
- else if (it.F_State == 3)
- worker.F_State = "已退回";
- else if (it.F_State == 4)
- worker.F_State = "异常退回";
- else if (it.F_State == 4)
- worker.F_State = "异常退回";
- else if (it.F_State == 11)
- worker.F_State = "已回访";
- else
- worker.F_State = "已处理";
- if (it.F_Type == "1")
- {
- worker.F_Type = "咨询";
- }
- else if (it.F_Type == "2")
- {
- worker.F_Type = "投诉";
- }
- else if (it.F_Type == "3")
- {
- worker.F_Type = "抽检";
- }
- else
- {
- worker.F_Type = "建议及其他";
- }
- worker.F_SalesBase = it.F_SalesBase;
- worker.F_Description = it.F_Description;
- string timeover = "", timeover2 = ""; int x = 0, y = 0;
- var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + " order by F_ID desc");
- if (itemList[0].F_NextDept > 0)
- {
- var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
- if (deptmodel != null)
- {
- worker.F_Responsibility = deptmodel.F_DeptName;
- }
- }
- else
- {
- if (itemList[0].F_WoState == 10)
- {
- var deptmodel = departmentBLL.GetModel(2);
- if (deptmodel != null)
- {
- worker.F_Responsibility = deptmodel.F_DeptName;
- }
- }
- }
- int limit = it.F_limit ;
- if (itemList != null)
- {
- for (int z = 0; z < itemList.Count; z++)
- {
- if (itemList[z].F_WoState >= 1)
- {
- if (itemList[z].F_WoState == 1)
- {
- x = z;
- timeover = itemList[z].F_CreateTime.ToString();
- // limit = int.Parse(itemList[z].F_LimitTime);
- break ;
- }
- }
- }
- for (int z = 0; z < itemList.Count; z++)
- {
- if (itemList[z].F_WoState >= 1)
- {
- if (itemList[z].F_WoState == 11)
- {
- y = z;
- timeover2 = itemList[z].F_CreateTime.ToString();
- // limit = int.Parse(itemList[z].F_LimitTime);
- }
- }
- if (timeover2 != "")
- {
- if (timeover != "")
- {
- if (x > y)
- {
- System.TimeSpan id = DateTime.Parse(timeover2) - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- else
- {
- System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- }
- }
- else if (timeover != "")
- {
- System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- }
- }
- if (it.F_State != 11)
- Overdue++;
- else
- EndOverdue++;
- model.worker.Add(worker);
- }
- model.Overdue = Overdue + "";
- model.EndOverdue = EndOverdue + "";
- if (lastmodellist != null)
- {
- foreach (var iv in lastmodellist)
- {
- if (iv.F_State == 10 || iv.F_State == 11)
- lastnumber++;
- }
- }
- }
- catch
- {
- }
- }
- if (lastnumber == 0)
- {
- model.efficiency = string.Format("{0:f0}% ", efficiency / 1 * 100);
- }
- else
- {
- int v = efficiency - lastnumber;
- model.efficiency = string.Format("{0:f0}% ", v / lastnumber * 100);
- }
- if (timehource.Count > 0)
- {
- timehource.Sort((a, b) => b.CompareTo(a));
- model.ongesttime = string.Format("{0:f2}", timehource[0]/24);
- model.minimumtime = string.Format("{0:f2}", timehource[timehource.Count - 1]/24);
- int n = timehource.Count / 2;
- model.median = string.Format("{0:f2}", timehource[n]/24);
- float y = 0;
- foreach (var iu in timehource)
- {
- y += iu;
- }
- model.averageTime = string.Format("{0:f2}", y / timehource.Count/24);
- }
- else
- {
- model.ongesttime = "0";
- model.minimumtime = "0";
- model.median = "0";
- model.averageTime = "0";
- }
- model.worker.Sort((a, b) => b.time.CompareTo(a.time));
- if (questionName != "")
- modeNamelList.Add(model);
- else if (model.number > 0)
- {
- modeNamelList.Add(model);
- }
- }
- }
-
- #endregion
- //var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal+ "order by F_ID desc ");
- if (questionName!="0")
- {
- if (modellist != null)
- {
- for (int i = 0; i < categorylist.Count; i++)
- {
- List<float> timehource = new List<float>();
- Complainthandling model = new Complainthandling();
- model.name = categorylist[i].F_QuestionName;
- model.typeid = categorylist[i].F_Id;
- model.number = 0;
- int Overdue = 0;
- int EndOverdue = 0;
- int efficiency = 0;
- model.worker = new List<worker>();
- int lastnumber = 0;
- foreach (var it in modellist)
- {
- try
- {
- if (int.Parse(it.F_QuestionType) == categorylist[i].F_Id)
- {
- model.number++;
- if (it.F_State == 10 || it.F_State == 11)
- {
- efficiency++;
-
- }
- if (it.F_IsOver == 1&&it .F_Type !="3")
- {
- worker worker = new worker();
- worker.F_WorkOrderCode = it.F_WorkOrderCode;
- if (it.F_State == 1)
- worker.F_State = "待接单";
- else if (it.F_State == 2)
- worker.F_State = "待处理";
- else if (it.F_State == 3)
- worker.F_State = "已退回";
- else if (it.F_State == 4)
- worker.F_State = "异常退回";
- else if (it.F_State == 4)
- worker.F_State = "异常退回";
- else if (it.F_State == 11)
- worker.F_State = "已回访";
- else
- worker.F_State = "已处理";
- if (it.F_Type == "1")
- {
- worker.F_Type = "咨询";
- }
- else if (it.F_Type == "2")
- {
- worker.F_Type = "投诉";
- }
- else if (it.F_Type == "3")
- {
- worker.F_Type = "抽检";
- }
- else
- {
- worker.F_Type = "建议及其他";
- }
- worker.F_SalesBase = it.F_SalesBase;
- worker.F_Description = it.F_Description;
- string timeover = "", timeover2 = ""; int x = 0, y = 0;
- var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + " order by F_ID desc");
- if (itemList[0].F_NextDept > 0)
- {
- var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
- if (deptmodel != null)
- {
- worker.F_Responsibility = deptmodel.F_DeptName;
- }
- }
- else
- {
- if (itemList[0].F_WoState ==10)
- {
- var deptmodel = departmentBLL.GetModel(2);
- if (deptmodel != null)
- {
- worker.F_Responsibility = deptmodel.F_DeptName;
- }
- }
- }
- int limit = it.F_limit;
- if (itemList != null)
- {
- for (int z = 0; z < itemList.Count; z++)
- {
- if (itemList[z].F_WoState >= 1)
- {
- if (itemList[z].F_WoState == 1)
- {
- x = z;
- timeover = itemList[z].F_CreateTime.ToString();
- // limit = int.Parse(itemList[z].F_LimitTime);
- break ;
- }
- }
- }
- for (int z = 0; z < itemList.Count; z++)
- {
- if (itemList[z].F_WoState >= 1)
- {
- if (itemList[z].F_WoState == 11)
- {
- y = z;
- timeover2 = itemList[z].F_CreateTime.ToString();
- // limit = int.Parse(itemList[z].F_LimitTime);
- }
- }
- if (timeover2 != "")
- {
- if (timeover != "")
- {
- if (x > y)
- {
- System.TimeSpan id = DateTime.Parse(timeover2) - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- else
- {
- System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- }
- }
- else if (timeover != "")
- {
- System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
- double a = id.TotalHours;
- worker.time = a - limit;
- timehource.Add((float)worker.time);
- if (worker.time > 24)
- {
- double t = worker.time / 24;
- double v = worker.time % 24;
- worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
- }
- else
- {
- worker.overtime = string.Format("{0:f2}h", a - limit);
- }
- }
- }
- }
- if (it.F_State != 11)
- Overdue++;
- else
- EndOverdue++;
- model.worker.Add(worker);
- }
- model.Overdue = Overdue + "";
- model.EndOverdue = EndOverdue + "";
- if (lastmodellist != null)
- {
- foreach (var iv in lastmodellist)
- {
- if (int.Parse(iv.F_QuestionType) == categorylist[i].F_Id)
- {
- if (iv.F_State == 10 || iv.F_State == 11)
- lastnumber++;
- }
- }
- }
- }
- }
- catch
- {
- }
- }
- if (lastnumber == 0)
- {
- model.efficiency = string.Format("{0:f0}% ", efficiency / 1 * 100);
- }
- else
- {
- int v = efficiency - lastnumber;
- model.efficiency = string.Format("{0:f0}% ", v / lastnumber * 100);
- }
- if (timehource.Count > 0)
- {
- timehource.Sort((a, b) => b.CompareTo(a));
- model.ongesttime = string.Format("{0:f2}", timehource[0]/24);
- model.minimumtime = string.Format("{0:f2}", timehource[timehource.Count - 1]/24);
- int n = timehource.Count / 2;
- model.median = string.Format("{0:f2}", timehource[n]/24);
- float y = 0;
- foreach (var iu in timehource)
- {
- y += iu;
- }
- model.averageTime = string.Format("{0:f2}", y / timehource.Count/24);
- }
- else
- {
- model.ongesttime = "0";
- model.minimumtime = "0";
- model.median = "0";
- model.averageTime = "0";
- }
- model.worker.Sort((a, b) => b.time.CompareTo(a.time));
- if (questionName != "")
- modeNamelList.Add(model);
- else if (model.number > 0)
- {
- modeNamelList.Add(model);
- }
- }
- }
- }
- int max = 0;
- if (modeNamelList.Count >0)
- {
- modeNamelList.Sort((a, b) => b.number.CompareTo(a.number));
- max = modeNamelList.Max(t => t.number);
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = modeNamelList,
- max,
- total = modeNamelList.Count
- };
- return Content(obj.ToJson()); ;
- }
- public class People
- {
- public string name { get; set; }
- public int age { get; set; }
- public string sex { get; set; }
- }
- /// <summary>
- /// 渠道来源数据分析表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetChannel(string channel="")
- {
- string sql = $" and F_IsDelete=0";
- sql += "and F_State=" + (int)EnumWorkOrderState.evaluate;
- DataTable dt = new DataTable();
- #region 筛选条件
-
- List<Channel> modelList = new List<Channel> ();
- List<string> channelname = new List<string>();
- if (channel != "")
- {
- channelname.Add(channel);
- }
- else
- {
- channelname.Add("总经销");
- channelname.Add("二级商");
- channelname.Add("种田大户");
- channelname.Add("公司员工");
- channelname.Add("其他公众");
- }
- for (int i = 0; i <channelname.Count ; i++)
- {
- Channel model = new Channel();
- model.channel = channelname[i ];
- string changel = "";
- if (channelname[i ]!= "其他公众")
- {
- changel ="'"+ model.channel.Trim()+"'";
- }
- else
- {
- changel = "'农户','化工客户','其他'";
- }
- string msg = "";
-
- var modellist= woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(changel) + ")" + sql+ "and F_Type in (2,3)");
- var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(changel) + ")" + sql + "and F_Type in (1,4)");
- int phone = 0, Chat = 0, diate=0, Trans=0, Satis=0, Unsatis= 0,Verysatisfied=0, Commonly=0;
- foreach (var it in modellist)
- {
- if (it .F_Source =="1")
- phone ++;
- if (it.F_Source == "2" || it.F_Source == "3")
- Chat++;
- if (it.F_DealType == "当即办理")
- diate++;
- if (it.F_DealType == "电话转接")
- Trans++;
- if ( it.F_VisitResult == "非常满意")
- Verysatisfied++;
- if (it.F_VisitResult == "满意")
- Satis++;
- if (it.F_VisitResult == "一般")
- Commonly++;
- if ( it.F_VisitResult == "不满意")
- Unsatis++;
- }
- foreach (var it in modellis)
- {
- if (it.F_Source == "1")
- phone++;
- if (it.F_Source == "2" || it.F_Source == "3")
- Chat++;
- if (it.F_DealType == "当即办理")
- diate++;
- if (it.F_DealType == "电话转接")
- Trans++;
- if (it.F_VisitResult == "非常满意")
- Verysatisfied++;
- if (it.F_VisitResult == "满意")
- Satis++;
- if (it.F_VisitResult == "一般")
- Commonly++;
- if (it.F_VisitResult == "不满意")
- Unsatis++;
- }
- model.Telephone = phone;
- model.WeChat = Chat;
- model.Immediate = diate;
- model.Transfer = Trans;
- model.Verysatisfied = Verysatisfied;
- model.Commonly = Commonly;
- model.Total = modellist.Count;
- model.Satisfaction = Satis;
- model.Unsatisfactory = Unsatis;
- modelList.Add(model);
- }
- #endregion
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = modelList,
- total = modelList.Count
- };
- return Content(obj.ToJson()); ;
- }
- /// <summary>
- /// 大数据区域表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetRegionList(string stime, string endtime, string salesBase, string channel, int type = 0, int page = 1, int limit = 10)
- {
- string sql = $" and F_IsDelete=0";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (type > 0 && type < 5)//工单类型
- sql += $" and F_Type=" + type;
- if (stime != null && stime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
- sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(channel))
- {
- sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
- }
- sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
- #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",
- limit,
- page,
- true,
- out recordCount);
- }
- List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
- if (modlelist.Count > 0)
- {
- List<Questions> input = modeltooip(modlelist);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = input,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- else
- {
- return Success("暂无工单"); ;
- }
- }
- public string GetCustomer(string msg)
- {
- string str = "";
- str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg+")";
- return str;
- }
- public string GetCustomerrel(string msg)
- {
- string str = "";
- str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg + ")";
- return str;
- }
- private string ChannelType(string msg)
- {
- string mag = "";
- DataTable dtxy = DbHelperSQL.Query(msg).Tables[0];
- mag = dtxy.Rows.Count.ToString();
- return mag;
- }
- /// <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>
- /// 根据model返回Prescription对象
- /// </summary>
- private List<Prescription> modelPrescription(List<Model.T_Wo_WorkOrder> model1)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (model1 != null && model1.Count > 0)
- {
- List<Prescription> Input = new List<Prescription>(model1.Count);
- for (int i = 0; i < model1.Count; i++)
- {
- Prescription model = new Prescription();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
-
- if (cuModel != null)
- {
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- model.AreaName = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- model.BranchName = pdModel1.F_DeptName;
- }
- }
-
- model.Brands = cuModel.F_Brands;//品牌
- }
-
-
- if (!string.IsNullOrEmpty(model1[i].F_QuestionType))
- {
- Model.T_Wo_QuestionManage Manage = null;
- try
- {
- int b = int.Parse(model1[i].F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
- }
- catch (Exception)
- {
- Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
- }
- if (Manage != null)
- {
- if (Manage.F_Label == "1")
- {
- model.QuestionTypeone = Manage.F_QuestionName;
- model.QuestionTypetwo = "";
- model.QuestionTypethree = "";
- }
- else if (Manage.F_Label == "2")
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- model.QuestionTypeone = Manage1.F_QuestionName;
- model.QuestionTypetwo = Manage.F_QuestionName;
- model.QuestionTypethree = "";
- }
- else
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
- model.QuestionTypeone = Manage2.F_QuestionName;//问题类别1
- model.QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
- model.QuestionTypethree = Manage.F_QuestionName;//问题类别3
- }
- }
- }
- model.ProductBase = model1[i].F_SC_ProductBase;//生产基地
- model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//责任科室
- model.Description = model1[i].F_Description;//问题描述
- model.Category = model1[i].F_TS_Category;//产品
- model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- model.CreatOn = model1[i].F_CreateOn.ToString();//时间
-
- Input.Add(model);
- }
- return Input;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 根据model返回Questions对象
- /// </summary>
- private List<Questions> modeltooip(List<Model.T_Wo_WorkOrder> model1)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (model1 != null && model1.Count > 0)
- {
- List<Questions> Input = new List<Questions>(model1.Count);
- for (int i = 0; i < model1.Count; i++)
- {
- Questions model = new Questions();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string .IsNullOrEmpty (model1[i].F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- var sql = $" and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'";
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 " + sql).FirstOrDefault();
- }
- if (cuModel != null)
- {
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- model.AreaName = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- model.BranchName = pdModel1.F_DeptName;
- }
- }
- model.Salesman = cuModel.F_Salesman;
- model.Brands = cuModel.F_Brands;
- model.Channel = cuModel.F_Channel;
- }
-
-
- model .Category = model1[i].F_TS_Category ;
- if (model1[i].F_Type == "1")
- {
- model.Type = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (model1[i].F_Type == "2")
- {
- model.Type = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else if (model1[i].F_Type == "3")
- {
- model.Type = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- else
- {
- model.Type = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
- }
- model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
- model.CreatOn = model1[i].F_CreateOn .ToString ();
- if (model1[i].F_Type !="3")
- {
- if (TimeToOver(model1[i].F_ID, model1[i].F_limit) < 0)
- model.Overtime = Math.Abs(TimeToOver(model1[i].F_ID, model1[i].F_limit)).ToString();
- else
- model.Overtime = "0";
- }
- else
- model.Overtime = "0";
- if (model1[i].F_State == 11 && model1[i].F_IsVisit == 1)
- model.Isvisit = "是";
- else
- model.Isvisit = "否";
- if (model1[i].F_State == 11)
- model.IsClose = "是";
- else
- model.IsClose = "否";
- Input.Add(model);
- }
- return Input;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 根据model返回WorkOrderComplaint对象
- /// </summary>
- private List<WorkOrderComplaint> modelComplaint(List<Model.T_Wo_WorkOrder> model1)
- {
- if (model1 != null && model1.Count > 0)
- {
- List<WorkOrderComplaint> Input = new List<WorkOrderComplaint>(model1.Count);
- for (int i = 0; i < model1.Count; i++)
- {
- WorkOrderComplaint model = new WorkOrderComplaint();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
- }
-
- if (cuModel != null)
- {
- model.F_CustomerID = cuModel.F_CustomerCode;//客户编码
- if (!string.IsNullOrEmpty(cuModel.F_AreaID))
- {
- Model.T_Sys_Department pdModel = new T_Sys_Department();
- try
- {
- pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
- }
- catch
- {
- pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- }
- if (pdModel != null)
- {
- model.F_AreaName = pdModel.F_DeptName;
- }
- }
- if (!string.IsNullOrEmpty(cuModel.F_BranchID))
- {
- Model.T_Sys_Department pdModel1 = new T_Sys_Department();
- try
- {
- pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
- }
- catch
- {
- pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
- }
- if (pdModel1 != null)
- {
- model.F_BranchName = pdModel1.F_DeptName;
- }
- }
- model.F_Salesman = cuModel.F_Salesman;//业务员
- }
-
- if (!string .IsNullOrEmpty (model1[i].F_MaterialID))
- {
- if (valcode(model1[i].F_MaterialID, 11))
- {
- model.F_MaterialID =model1[i].F_MaterialID;//验证物料编码为11位纯数字
- Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(model1[i].F_MaterialID);//通过物料编码获取物料信息
- 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;//F_MaterialEffect
- model.F_Pipeline = maModel.F_Pipeline;//F_Pipeline
- model.F_Craft = maModel.F_Craft;//F_Craft
- }
- }
- }
- if (!string .IsNullOrEmpty(model1[i].F_QuestionType))
- {
- Model.T_Wo_QuestionManage Manage = null;
- try
- {
- int b = int.Parse(model1[i].F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
- }
- catch (Exception)
- {
- Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
- }
- if (Manage !=null )
- {
- if (Manage .F_Label =="1")
- {
- model.F_QuestionTypeone = Manage.F_QuestionName;
- model.F_QuestionTypetwo = "";
- model.F_QuestionTypethree ="";
- }
- else if (Manage.F_Label == "2")
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int .Parse (Manage.F_ParentId.ToString () ) );//获取问题类别
- model.F_QuestionTypeone = Manage1.F_QuestionName;
- model.F_QuestionTypetwo = Manage.F_QuestionName;
- model.F_QuestionTypethree = "";
- }
- else
- {
- Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
- Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
- model.F_QuestionTypeone = Manage2.F_QuestionName;//问题类别1
- model.F_QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
- model.F_QuestionTypethree =Manage.F_QuestionName;//问题类别3
- }
- }
- }
- 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_BatchNumber = model1[i].F_BatchNumber;//生产批次号
- model.F_TS_Quantity = model1[i].F_TS_Quantity;//投诉-问题数量(吨)
- 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_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_DealType = model1[i].F_DealType;//处理方式:当即办理、电话转接、网络转办
- model.F_DealBy = model1[i].F_DealBy;//处理人
- model.F_DealTime = model1[i].F_DealTime;//处理时间
- model.F_DealContent = model1[i].F_DealContent;//处理内容
- if (model1[i].F_State ==10|| model1[i].F_State == 11)
- model.F_DealResult ="已处理";//处理结果
- else
- model.F_DealResult = "未处理";//处理结果
- model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
- model.F_CreateOn = model1[i].F_CreateOn; ;//添加时间
- Input.Add(model);
- }
- return Input;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 根据model返回WorkOrderComplaint对象
- /// </summary>
- private List<Product> modelProduct(List<Model.T_Wo_WorkOrder> model1)
- {
- if (model1 != null && model1.Count > 0)
- {
- List<Product> Input = new List<Product>(model1.Count);
- for (int i = 0; i < model1.Count; i++)
- {
- Product model = new Product();
- Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
- if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
- {
- cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
- }
- else
- {
- cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
- }
- if (cuModel != null)
- {
- Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
- model.F_Salesman = cuModel.F_Salesman;//业务员
- }
- model.Category = model1[i].F_TS_Category;//产品
- model.Company = model1[i].F_CompanyName;//客户单位
- if (!string.IsNullOrEmpty(model1[i].F_BatchNumber))
- {
- var prono = model1[i].F_BatchNumber.Substring(0, 6);
- try
- {
- var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
- // var protime = Convert.ToDateTime(pronos);
- model.ProductionTime = pronos;
- }
- catch
- {
- model.ProductionTime = "";
- }
- }
- model.CreatOn = model1[i].F_CreateOn .ToString (); ;
- model.Spurtcode = model1[i].F_BatchNumber;
- Model.T_Wo_QuestionManage Manage = null;
- try
- {
- int b = int.Parse(model1[i].F_QuestionType.Trim());
- Manage = quesBLL.GetModel(b);
- if (Manage !=null )
- {
- model.QuestionType = Manage.F_QuestionName;
- }
- }
- catch (Exception)
- {
- model.QuestionType = model1[i].F_QuestionType;
- }
-
- model.Description = model1[i].F_Description;
- model.DealType = model1[i].F_DealType;
- model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;
- model.SalesBase = model1[i].F_SalesBase;
- Input.Add(model);
- }
- return Input;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 是否超时
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- private float TimeToOver(int id,int time)
- {
- var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + "order by F_ID desc ");
- string time1 = "", time2 = ""; int x = 0, y = 0;
-
- if (itemlasts.Count > 0)
- {
- for (int z = 0; z < itemlasts.Count; z++)
- {
- if (itemlasts[z].F_WoState >= 1)
- {
- if (itemlasts[z].F_WoState == 1)
- {
- x = z;
- time1 = itemlasts[z].F_CreateTime.ToString();
- break;
- }
- }
- }
- for (int i = 0; i < itemlasts.Count; i++)
- {
- if (itemlasts[i].F_WoState >= 1)
- {
-
- if (itemlasts[i].F_WoState == 10)
- {
- y = i;
- time2 = itemlasts[i].F_CreateTime.ToString();
- }
- }
- }
- if (time2 != "")
- {
- if (time1 != "")
- {
- if (x > y)
- {
- System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
- float b = time - (float)a.TotalHours;
- return b;
- }
- else
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- float b = time - (float)a.TotalHours;
- return b;
- }
- }
- else
- {
- return 0;
- }
- }
- else if (time1 != "")
- {
- System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
- float b = time - (float)a.TotalHours;
- return b;
- }
- else
- {
- return 0;
- }
- }
- return 0;
- }
- /// <summary>
- /// 获取客户编号
- /// </summary>
- /// <returns></returns>
- public string GetCustomerID(string channel)
- {
- string str = string.Empty;
- str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_Channel='" + channel + "' " + " and isnull(F_IsDelete,'0')='0' "; ;
- return str;
- }
- /// <summary>
- /// 获得数据列表
- /// </summary>
- public List<QuestionType> DataTableToList(DataTable dt)
- {
- List<QuestionType> modelList = new List<QuestionType>();
- int rowsCount = dt.Rows.Count;
- if (rowsCount > 0)
- {
- QuestionType model;
- for (int n = 0; n < rowsCount; n++)
- {
- model = DataRowToModel(dt.Rows[n]);
- if (model != null)
- {
- modelList.Add(model);
- }
- }
- }
- return modelList;
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public QuestionType DataRowToModel(DataRow row)
- {
- QuestionType model = new QuestionType();
- if (row != null)
- {
- if (row["F_QuestionType"] != null)
- {
- model.F_QuestionType = row["F_QuestionType"].ToString();
- }
- if (row["number"] != null && row["number"].ToString() != "")
- {
- model.number = int.Parse(row["number"].ToString());
- }
- }
- return model;
- }
- private DataTable getData(string stime, string endtime, int deptid = 0)
- {
- DataTable dtNew = new DataTable();
- #region 添加表格标题
- //部门,工号,姓名,建单量,接单量,未处理量,异常量,已处理量
- dtNew.Columns.Add("部门");
- dtNew.Columns.Add("工号");
- dtNew.Columns.Add("姓名");
- dtNew.Columns.Add("建单量");
- dtNew.Columns.Add("接单量");
- dtNew.Columns.Add("未处理量");
- dtNew.Columns.Add("异常量");
- dtNew.Columns.Add("已处理量");
- #endregion
- #region 筛选条件
- string sqlwo = " isdel=0 "; string sqluser = " F_DeleteFlag=0 ";string sqldept = " F_State=1 ";
- if (stime != null && stime.Trim() != "")
- {
- sqlwo += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
- }
- if (endtime != null && endtime.Trim() != "")
- {
- sqlwo += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
- }
- if (deptid > 0)
- {
- sqluser += " and F_DeptId=" + deptid;
- sqldept += " and F_DeptId=" + deptid;
- }
- #endregion
- //获取部门
- var depts = new BLL.T_Sys_Department().GetModelList(sqldept);
- //获取人员
- var users = new BLL.T_Sys_UserAccount().GetModelList(sqluser);
- #region 获取工单量
- //--创建量,接单量,未处理量,异常量,已处理量
- //--创建量
- string sqlcreate = $" select CreateUser,COUNT(1) con from T_Wo_WorkOrder where " +sqlwo+" group by CreateUser";
- DataTable dtcreate = DbHelperSQL.Query(sqlcreate).Tables[0];
- //--接单量
- string sqljd = $"select F_NextUser, COUNT(1) con from( " +
- "select F_WoID, F_NextUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.assign + " " +
- "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
- "group by F_WoID, F_NextUser) t group by F_NextUser ";
- DataTable dtjd= DbHelperSQL.Query(sqljd).Tables[0];
- //--未处理量
- string sqlwcl = $"select F_CreateUser, COUNT(1) con from( " +
- "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState < " + (int)EnumWorkOrderState.finish + " " +
- "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
- "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
- DataTable dtwcl = DbHelperSQL.Query(sqlwcl).Tables[0];
- //--异常量:以提交异常退回的人员为准
- string sqlyc = $"select F_CreateUser, COUNT(1) con from( " +
- "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.abreback + " " +
- "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
- "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
- DataTable dtyc = DbHelperSQL.Query(sqlyc).Tables[0];
- //--已处理量:以最终处理人为准
- string sqlwj = $" select LastDealUser,COUNT(1) con from T_Wo_WorkOrder where " + sqlwo + " and State=" + (int)EnumWorkOrderState.finish + " group by LastDealUser";
- DataTable dtwj = DbHelperSQL.Query(sqlwj).Tables[0];
- #endregion
- foreach (var user in users)
- {
- DataRow drNew = dtNew.NewRow();
- //部门,
- var dept = depts.Where(d => d.F_DeptId == user.F_DeptId).FirstOrDefault();
- var deptname = dept != null ? dept.F_DeptName : "";
- //建单量,
- var createcount = "0";
- var createRows = dtcreate.Select(" CreateUser = '" + user.F_UserCode + "'");
- if (createRows.Length > 0)
- createcount = createRows[0]["con"].ToString();
- //接单量,
- var jdcount = "0";
- var jdRows = dtjd.Select(" F_NextUser = '" + user.F_UserCode + "'");
- if (jdRows.Length > 0)
- jdcount = jdRows[0]["con"].ToString();
- //未处理量,
- var wclcount = "0";
- var wclRows=dtwcl.Select(" F_CreateUser = '" + user.F_UserCode + "'");
- if (wclRows.Length > 0)
- wclcount = wclRows[0]["con"].ToString();
- //异常量,
- var yccount = "0";
- var ycRows = dtyc.Select(" F_CreateUser = '" + user.F_UserCode + "'");
- if (ycRows.Length>0)
- yccount=ycRows[0]["con"].ToString();
- //已处理量
- var wjcount = "0";
- var wjRows = dtwj.Select(" LastDealUser = '" + user.F_UserCode + "'");
- if (wjRows.Length > 0)
- wjcount= wjRows[0]["con"].ToString();
- drNew["部门"] = deptname;
- drNew["工号"] = user.F_UserCode;
- drNew["姓名"] = user.F_UserName;
- drNew["建单量"] = createcount;
- drNew["接单量"] = jdcount;
- drNew["未处理量"] = wclcount;
- drNew["异常量"] = yccount;
- drNew["已处理量"] = wjcount;
- dtNew.Rows.Add(drNew);
- }
- return dtNew;
- }
- }
-
- }
- public class DynamicModel : DynamicObject
- {
- private string propertyName;
- public string PropertyName
- {
- get { return propertyName; }
- set { propertyName = value; }
- }
- // The inner dictionary.
- Dictionary<string, object> dicProperty
- = new Dictionary<string, object>();
- public Dictionary<string, object> DicProperty
- {
- get
- {
- return dicProperty;
- }
- }
- // This property returns the number of elements
- // in the inner dictionary.
- public int Count
- {
- get
- {
- return dicProperty.Count;
- }
- }
- // If you try to get a value of a property
- // not defined in the class, this method is called.
- public override bool TryGetMember(
- GetMemberBinder binder, out object result)
- {
- // Converting the property name to lowercase
- // so that property names become case-insensitive.
- string name = binder.Name;
- // If the property name is found in a dictionary,
- // set the result parameter to the property value and return true.
- // Otherwise, return false.
- return dicProperty.TryGetValue(name, out result);
- }
- // If you try to set a value of a property that is
- // not defined in the class, this method is called.
- public override bool TrySetMember(
- SetMemberBinder binder, object value)
- {
- // Converting the property name to lowercase
- // so that property names become case-insensitive.
- if (binder.Name == "Property")
- {
- dicProperty[PropertyName] = value;
- }
- else
- {
- dicProperty[binder.Name] = value;
- }
- // You can always add a value to a dictionary,
- // so this method always returns true.
- return true;
- }
- }
|