Keine Beschreibung

WOReportController.cs 212KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using CallCenterApi.Interface.Models.Enum;
  5. using CallCenterApi.Model;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Text.RegularExpressions;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. using System.Dynamic;
  14. namespace CallCenterApi.Interface.Controllers.report
  15. {
  16. public class WOReportController : BaseController
  17. {
  18. BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
  19. BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  20. BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
  21. BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
  22. BLL.T_Wo_QuestionManage quesBLL = new BLL.T_Wo_QuestionManage();
  23. private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
  24. BLL.T_Wo_WorkOrder workOrder = new BLL.T_Wo_WorkOrder();
  25. public ActionResult GetDicValueListByFlag(string flag)
  26. {
  27. DataTable dt = new DataTable();
  28. dt = new BLL.T_Sys_DictionaryValue().GetList(" F_DictionaryFlag='" + flag + "' and F_State=1 ").Tables[0];
  29. return Success("列表加载成功", dt);
  30. }
  31. public ActionResult GetDataList(string stime, string endtime, int deptid = 0)
  32. {
  33. DataTable dtNew = new DataTable();//getData(stime, endtime, deptid);
  34. var obj = new
  35. {
  36. dtNew,
  37. totle = dtNew.Rows.Count
  38. };
  39. return Success("获取业务报表数据", obj);
  40. }
  41. public ActionResult ExptList(string stime, string endtime, int deptid = 0)
  42. {
  43. NPOIHelper npoi = new NPOIHelper();
  44. DataTable dt = new DataTable();
  45. // DataTable dt = getData(stime, endtime, deptid);
  46. if (npoi.ExportToExcel("业务报表数据", dt) == "")
  47. {
  48. return Success("导出成功");
  49. }
  50. else
  51. {
  52. return Error("导出失败");
  53. }
  54. }
  55. public class market
  56. {
  57. public string typename;
  58. public string salexinxiang;
  59. public string salejiujiang;
  60. public string salexinjiang;
  61. public string saledongbei;
  62. public string cheyong;
  63. public string total;
  64. }
  65. public class marketList
  66. {
  67. public string typename;
  68. public int salexinxinag;
  69. public int salejiujiang;
  70. public int salexinjiang;
  71. public int saledongbei;
  72. public int cheyongniaosu;
  73. public int total;
  74. public string immediate;
  75. public int overdue;
  76. public int satisfied;
  77. public int dissatisfied;
  78. }
  79. /// <summary>
  80. /// 导出反馈类型明细表
  81. /// </summary>
  82. /// <param name="stime"></param>
  83. /// <param name="endtime"></param>
  84. /// <returns></returns>
  85. public ActionResult ExitTypelist(string stime, string endtime)
  86. {
  87. DataTable dt = new DataTable();
  88. string sql = $" F_IsDelete=0";
  89. if (stime != null && stime.Trim() != "")
  90. {
  91. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  92. }
  93. if (endtime != null && endtime.Trim() != "")
  94. {
  95. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  96. }
  97. var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "XSJD" + "' and F_State=1 ").Tables[0];
  98. List<Brand> list = new List<Brand>();
  99. List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
  100. if (dicv != null)
  101. {
  102. dicval = dicvalueBll.DataTableToList(dicv);
  103. }
  104. dt.Columns.Add("反馈类型");
  105. foreach (var it in dicval)
  106. {
  107. dt.Columns.Add(it.F_Name );
  108. }
  109. dt.Columns.Add("合计");
  110. dt.Columns.Add("即时办结率");
  111. for (int i = 0; i < 8; i++)
  112. {
  113. DataRow drNew = dt.NewRow();
  114. switch (i)
  115. {
  116. case 0:
  117. drNew["反馈类型"] = "合计";
  118. break;
  119. case 1:
  120. drNew["反馈类型"] = "咨询";
  121. break;
  122. case 2:
  123. drNew["反馈类型"] = "投诉";
  124. break;
  125. case 3:
  126. drNew["反馈类型"] = "抽检";
  127. break;
  128. case 4:
  129. drNew["反馈类型"] = "建议";
  130. break;
  131. case 5:
  132. drNew["反馈类型"] = "超期数量";
  133. break;
  134. case 6:
  135. drNew["反馈类型"] = "满意数量";
  136. break;
  137. case 7:
  138. drNew["反馈类型"] = "不满意数量";
  139. break;
  140. }
  141. string nsg = "";
  142. if (i > 0&& i<5)
  143. {
  144. nsg = "and F_Type=" + i;
  145. }
  146. else if (i > 4)
  147. {
  148. if (i ==5)
  149. {
  150. nsg = " and F_IsOver=" + 1 ;
  151. }
  152. else if (i == 6)
  153. {
  154. nsg = "and F_VisitResult in('非常满意','满意')";
  155. }
  156. else if (i == 7)
  157. {
  158. nsg = "and F_VisitResult='不满意'";
  159. }
  160. }
  161. foreach (var it in dicval)
  162. {
  163. drNew[it.F_Name ] = woBLL.GetModelList(sql + "and F_SalesBase='"+ it.F_Name+"'" + nsg).Count.ToString();
  164. }
  165. drNew["合计"] = woBLL.GetModelList(sql + nsg).Count.ToString();
  166. int a = woBLL.GetModelList(sql + "and F_DealType='当即办理'" + nsg).Count;
  167. int b = woBLL.GetModelList(sql + nsg).Count;
  168. if (b > 0)
  169. {
  170. drNew["即时办结率"] = string.Format("{0:f2}%", a / b * 100);
  171. }
  172. else
  173. {
  174. drNew["即时办结率"] = string.Format("0.00%");
  175. }
  176. dt.Rows.Add(drNew);
  177. }
  178. NPOIHelper npoi = new NPOIHelper();
  179. if (npoi.ExportToExcel("反馈类型明细表", dt) == "")
  180. {
  181. return Success("导出成功");
  182. }
  183. else
  184. {
  185. return Error("导出失败");
  186. }
  187. }
  188. /// <summary>
  189. /// 反馈类型明细表
  190. /// </summary>
  191. /// <param name="stime"></param>
  192. /// <param name="endtime"></param>
  193. /// <returns></returns>
  194. public ActionResult GetTypelist(string stime, string endtime)
  195. {
  196. string sql = $" F_IsDelete=0";
  197. if (stime != null && stime.Trim() != "")
  198. {
  199. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  200. }
  201. if (endtime != null && endtime.Trim() != "")
  202. {
  203. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  204. }
  205. List<marketList> markets = new List<marketList>();
  206. for (int i = 0; i < 8; i++)
  207. {
  208. marketList brand = new marketList();
  209. switch (i)
  210. {
  211. case 0:
  212. brand.typename = "合计";
  213. break;
  214. case 1:
  215. brand.typename = "咨询";
  216. break;
  217. case 2:
  218. brand.typename = "投诉";
  219. break;
  220. case 3:
  221. brand.typename = "抽检";
  222. break;
  223. case 4:
  224. brand.typename = "建议";
  225. break;
  226. case 5:
  227. brand.typename = "超期数量";
  228. break;
  229. case 6:
  230. brand.typename = "满意数量";
  231. break;
  232. case 7:
  233. brand.typename = "不满意数量";
  234. break;
  235. }
  236. string nsg = "";
  237. if (i > 0 && i < 5)
  238. {
  239. nsg = "and F_Type=" + i;
  240. }
  241. else if (i > 4)
  242. {
  243. if (i == 5)
  244. {
  245. nsg = " and F_IsOver=" + 1;
  246. }
  247. else if (i == 6)
  248. {
  249. nsg = "and F_VisitResult in('非常满意','满意')";
  250. }
  251. else if (i == 7)
  252. {
  253. nsg = "and F_VisitResult='不满意'";
  254. }
  255. }
  256. brand.salexinxinag = woBLL.GetModelList(sql + "and F_SalesBase='新乡'" + nsg).Count;
  257. brand.salejiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'" + nsg).Count;
  258. brand.salexinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'" + nsg).Count;
  259. brand.saledongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'" + nsg).Count;
  260. brand.cheyongniaosu = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'" + nsg).Count;
  261. brand.total = woBLL.GetModelList(sql + nsg).Count;
  262. int a = woBLL.GetModelList(sql + "and F_DealType='当即办理'" + nsg).Count;
  263. int b = woBLL.GetModelList(sql + nsg).Count;
  264. if (b > 0)
  265. {
  266. brand.immediate = string.Format("{0:f2}%", a / b * 100);
  267. }
  268. else
  269. {
  270. brand.immediate = string.Format("0.00%");
  271. }
  272. markets.Add(brand);
  273. }
  274. return Success("获取成功", markets);
  275. }
  276. /// <summary>
  277. /// 导出销售基地明细表
  278. /// </summary>
  279. /// <param name="stime"></param>
  280. /// <param name="endtime"></param>
  281. /// <returns></returns>
  282. public ActionResult ExitSalesBaselist(string stime, string endtime)
  283. {
  284. DataTable dt = new DataTable();
  285. string sql = $" F_IsDelete=0";
  286. if (stime != null && stime.Trim() != "")
  287. {
  288. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  289. }
  290. if (endtime != null && endtime.Trim() != "")
  291. {
  292. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  293. }
  294. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  295. var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
  296. var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
  297. var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
  298. List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
  299. List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
  300. List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
  301. List<Model.T_Wo_WorkOrder> workerdongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'");
  302. List<Model.T_Wo_WorkOrder> workerjiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'");
  303. List<Model.T_Wo_WorkOrder> workerxinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'");
  304. List<Model.T_Wo_WorkOrder> workerxinxiang = woBLL.GetModelList(sql + "and F_SalesBase='新乡'");
  305. List<Model.T_Wo_WorkOrder> workercheyong = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'");
  306. List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
  307. dt.Columns.Add("类型");
  308. dt.Columns.Add("新乡");
  309. dt.Columns.Add("九江");
  310. dt.Columns.Add("新疆");
  311. dt.Columns.Add("东北");
  312. dt.Columns.Add("车用尿素");
  313. dt.Columns.Add("合计");
  314. for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
  315. {
  316. DataRow drNew = dt.NewRow();
  317. int saledongbei = 0;
  318. int salejiujiang = 0;
  319. int salexinjiang = 0;
  320. int salexinxiang = 0;
  321. int cheyongniaosu = 0;
  322. int total = 0;
  323. saledongbei = workercount(i, workerdongbei, ConsultingNeedslist, Complaintlist, SpotChecklist);
  324. salejiujiang = workercount(i, workerjiujiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  325. salexinjiang = workercount(i, workerxinjiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  326. salexinxiang = workercount(i, workerxinxiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  327. cheyongniaosu= workercount(i, workercheyong, ConsultingNeedslist, Complaintlist, SpotChecklist);
  328. total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
  329. market brand = new market();
  330. switch (i)
  331. {
  332. case 0:
  333. drNew["类型"] = "合计";
  334. break;
  335. case 1:
  336. drNew["类型"] = "即时办结率";
  337. break;
  338. case 2:
  339. drNew["类型"] = "超期数量";
  340. break;
  341. case 3:
  342. drNew["类型"] = "满意数量";
  343. break;
  344. case 4:
  345. drNew["类型"] = "不满意数量";
  346. break;
  347. }
  348. if (i < ConsultingNeedslist.Count + 5 && i >= 5)
  349. {
  350. drNew["类型"] = ConsultingNeedslist[i - 5].F_QuestionName;
  351. }
  352. else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
  353. {
  354. drNew["类型"] = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
  355. }
  356. else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
  357. {
  358. drNew["类型"] = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
  359. }
  360. if (i == 1)
  361. {
  362. if (total > 0)
  363. {
  364. drNew["东北"] = string.Format("{0:f2}%", saledongbei / total * 100);
  365. drNew["九江"] = string.Format("{0:f2}%", salejiujiang / total * 100);
  366. drNew["新疆"] = string.Format("{0:f2}%", salexinjiang / total * 100);
  367. drNew["新乡"] = string.Format("{0:f2}%", salexinxiang / total * 100);
  368. drNew["车用尿素"] = string.Format("{0:f2}%", cheyongniaosu / total * 100);
  369. drNew["合计"] = string.Format("{0:f2}%", 100);
  370. }
  371. else
  372. {
  373. drNew["东北"] = "0.00%";
  374. drNew["九江"] = "0.00%";
  375. drNew["新疆"] = "0.00%";
  376. drNew["新乡"] = "0.00%";
  377. drNew["车用尿素"] = "0.00%";
  378. drNew["合计"] = "0.00%";
  379. }
  380. }
  381. else
  382. {
  383. drNew["东北"] = saledongbei.ToString();
  384. drNew["九江"] = salejiujiang.ToString();
  385. drNew["新疆"] = salexinjiang.ToString();
  386. drNew["新乡"] = salexinxiang.ToString();
  387. drNew["车用尿素"] = cheyongniaosu.ToString();
  388. drNew["合计"] = total.ToString();
  389. }
  390. dt.Rows.Add(drNew);
  391. }
  392. NPOIHelper npoi = new NPOIHelper();
  393. if (npoi.ExportToExcel("销售基地明细表", dt) == "")
  394. {
  395. return Success("导出成功");
  396. }
  397. else
  398. {
  399. return Error("导出失败");
  400. }
  401. }
  402. /// <summary>
  403. /// 销售基地明细表
  404. /// </summary>
  405. /// <param name="stime"></param>
  406. /// <param name="endtime"></param>
  407. /// <returns></returns>
  408. public ActionResult GetSalesBaselist(string stime, string endtime)
  409. {
  410. string sql = $" F_IsDelete=0";
  411. if (stime != null && stime.Trim() != "")
  412. {
  413. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  414. }
  415. if (endtime != null && endtime.Trim() != "")
  416. {
  417. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  418. }
  419. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  420. var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
  421. var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
  422. var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
  423. List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
  424. List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
  425. List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
  426. List<Model.T_Wo_WorkOrder> workerdongbei = woBLL.GetModelList(sql + "and F_SalesBase='东北'");
  427. List<Model.T_Wo_WorkOrder> workerjiujiang = woBLL.GetModelList(sql + "and F_SalesBase='九江'");
  428. List<Model.T_Wo_WorkOrder> workerxinjiang = woBLL.GetModelList(sql + "and F_SalesBase='新疆'");
  429. List<Model.T_Wo_WorkOrder> workerxinxiang = woBLL.GetModelList(sql + "and F_SalesBase='新乡'");
  430. List<Model.T_Wo_WorkOrder> workerniaosu = woBLL.GetModelList(sql + "and F_SalesBase='车用尿素'");
  431. List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
  432. List<market> markets = new List<market>();
  433. for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
  434. {
  435. int saledongbei = 0;
  436. int salejiujiang = 0;
  437. int salexinjiang = 0;
  438. int salexinxiang = 0;
  439. int cheyong = 0;
  440. int total = 0;
  441. saledongbei = workercount(i, workerdongbei, ConsultingNeedslist, Complaintlist, SpotChecklist);
  442. salejiujiang = workercount(i, workerjiujiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  443. salexinjiang = workercount(i, workerxinjiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  444. salexinxiang = workercount(i, workerxinxiang, ConsultingNeedslist, Complaintlist, SpotChecklist);
  445. cheyong = workercount(i, workerniaosu, ConsultingNeedslist, Complaintlist, SpotChecklist);
  446. total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
  447. market brand = new market();
  448. switch (i)
  449. {
  450. case 0:
  451. brand.typename = "合计";
  452. break;
  453. case 1:
  454. brand.typename = "即时办结率";
  455. break;
  456. case 2:
  457. brand.typename = "超期数量";
  458. break;
  459. case 3:
  460. brand.typename = "满意数量";
  461. break;
  462. case 4:
  463. brand.typename = "不满意数量";
  464. break;
  465. }
  466. if (i < ConsultingNeedslist.Count + 5 && i >= 5)
  467. {
  468. brand.typename = ConsultingNeedslist[i - 5].F_QuestionName;
  469. }
  470. else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
  471. {
  472. brand.typename = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
  473. }
  474. else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
  475. {
  476. brand.typename = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
  477. }
  478. if (i == 1)
  479. {
  480. if (total > 0)
  481. {
  482. brand.saledongbei = string.Format("{0:f2}%", saledongbei / total * 100);
  483. brand.salejiujiang = string.Format("{0:f2}%", salejiujiang / total * 100);
  484. brand.salexinjiang = string.Format("{0:f2}%", salexinjiang / total * 100);
  485. brand.salexinxiang = string.Format("{0:f2}%", salexinxiang / total * 100);
  486. brand.cheyong = string.Format("{0:f2}%", cheyong / total * 100);
  487. brand.total = string.Format("{0:f2}%", 100);
  488. }
  489. else
  490. {
  491. brand.saledongbei = "0.00%";
  492. brand.salejiujiang = "0.00%";
  493. brand.salexinjiang = "0.00%";
  494. brand.salexinxiang = "0.00%";
  495. brand.cheyong = "0.00%";
  496. brand.total = "0.00%";
  497. }
  498. }
  499. else
  500. {
  501. brand.saledongbei = saledongbei.ToString();
  502. brand.salejiujiang = salejiujiang.ToString();
  503. brand.salexinjiang = salexinjiang.ToString();
  504. brand.salexinxiang = salexinxiang.ToString();
  505. brand.cheyong = cheyong.ToString();
  506. brand.total = total.ToString();
  507. }
  508. markets.Add(brand);
  509. }
  510. return Success("获取成功", markets);
  511. }
  512. public class Category
  513. {
  514. public string typename;
  515. public string urea;//尿素
  516. public string compound;//复合肥
  517. public string fertilizer;//水溶肥
  518. public string vehicle;//车用尿素
  519. public string melamine;//三聚氰胺
  520. public string methanol;//甲醇
  521. public string furfuryl;//糠醇
  522. public string humic;//腐植酸
  523. public string dimethyl;//二甲醚
  524. public string furfural;//糠醛
  525. public string liquid;//液氨
  526. public string other;//其他
  527. }
  528. /// <summary>
  529. /// 导出产品名称明细表
  530. /// </summary>
  531. /// <param name="stime"></param>
  532. /// <param name="endtime"></param>
  533. /// <returns></returns>
  534. public ActionResult ExitProductlist(string stime, string endtime)
  535. {
  536. DataTable dt = new DataTable();
  537. string sql = $" F_IsDelete=0";
  538. if (stime != null && stime.Trim() != "")
  539. {
  540. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  541. }
  542. if (endtime != null && endtime.Trim() != "")
  543. {
  544. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  545. }
  546. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  547. var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
  548. var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
  549. var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
  550. List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
  551. List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
  552. List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
  553. List<Model.T_Wo_WorkOrder> workerurea = woBLL.GetModelList(sql + "and F_TS_Category='尿素'");
  554. List<Model.T_Wo_WorkOrder> workercompound = woBLL.GetModelList(sql + "and F_TS_Category='复合肥'");
  555. List<Model.T_Wo_WorkOrder> workerfertilizer = woBLL.GetModelList(sql + "and F_TS_Category='水溶肥'");
  556. List<Model.T_Wo_WorkOrder> workervehicle = woBLL.GetModelList(sql + "and F_TS_Category='车用尿素'");
  557. List<Model.T_Wo_WorkOrder> workermelamine = woBLL.GetModelList(sql + "and F_TS_Category='三聚氰胺'");
  558. List<Model.T_Wo_WorkOrder> workermethanol = woBLL.GetModelList(sql + "and F_TS_Category='甲醇'");
  559. List<Model.T_Wo_WorkOrder> workerfurfuryl = woBLL.GetModelList(sql + "and F_TS_Category='糠醇'");
  560. List<Model.T_Wo_WorkOrder> workerhumic = woBLL.GetModelList(sql + "and F_TS_Category='腐植酸'");
  561. List<Model.T_Wo_WorkOrder> workerdimethyl = woBLL.GetModelList(sql + "and F_TS_Category='二甲醚'");
  562. List<Model.T_Wo_WorkOrder> workerfurfural = woBLL.GetModelList(sql + "and F_TS_Category='糠醛'");
  563. List<Model.T_Wo_WorkOrder> workerliquid = woBLL.GetModelList(sql + "and F_TS_Category='液氨'");
  564. List<Model.T_Wo_WorkOrder> workerother = woBLL.GetModelList(sql + "and F_TS_Category='其他'");
  565. List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql);
  566. dt.Columns.Add("类型");
  567. dt.Columns.Add("尿素");
  568. dt.Columns.Add("复合肥");
  569. dt.Columns.Add("水溶肥");
  570. dt.Columns.Add("车用尿素");
  571. dt.Columns.Add("三聚氰胺");
  572. dt.Columns.Add("甲醇");
  573. dt.Columns.Add("糠醇");
  574. dt.Columns.Add("腐植酸");
  575. dt.Columns.Add("二甲醚");
  576. dt.Columns.Add("糠醛");
  577. dt.Columns.Add("液氨");
  578. dt.Columns.Add("其他");
  579. for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
  580. {
  581. DataRow drNew = dt.NewRow();
  582. int urea = 0, compound = 0, fertilizer = 0, vehicle = 0, total = 0, melamine = 0, methanol = 0, furfuryl = 0
  583. , humic = 0, dimethyl = 0, furfural = 0, liquid = 0, other = 0;
  584. urea = workercount(i, workerurea, ConsultingNeedslist, Complaintlist, SpotChecklist);
  585. compound = workercount(i, workercompound, ConsultingNeedslist, Complaintlist, SpotChecklist);
  586. fertilizer = workercount(i, workerfertilizer, ConsultingNeedslist, Complaintlist, SpotChecklist);
  587. vehicle = workercount(i, workervehicle, ConsultingNeedslist, Complaintlist, SpotChecklist);
  588. melamine = workercount(i, workermelamine, ConsultingNeedslist, Complaintlist, SpotChecklist);
  589. methanol = workercount(i, workermethanol, ConsultingNeedslist, Complaintlist, SpotChecklist);
  590. furfuryl = workercount(i, workerfurfuryl, ConsultingNeedslist, Complaintlist, SpotChecklist);
  591. humic = workercount(i, workerhumic, ConsultingNeedslist, Complaintlist, SpotChecklist);
  592. dimethyl = workercount(i, workerdimethyl, ConsultingNeedslist, Complaintlist, SpotChecklist);
  593. furfural = workercount(i, workerfurfural, ConsultingNeedslist, Complaintlist, SpotChecklist);
  594. liquid = workercount(i, workerliquid, ConsultingNeedslist, Complaintlist, SpotChecklist);
  595. other = workercount(i, workerother, ConsultingNeedslist, Complaintlist, SpotChecklist);
  596. total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
  597. Category brand = new Category();
  598. switch (i)
  599. {
  600. case 0:
  601. drNew["类型"] = "合计";
  602. break;
  603. case 1:
  604. drNew["类型"] = "即时办结率";
  605. break;
  606. case 2:
  607. drNew["类型"] = "超期数量";
  608. break;
  609. case 3:
  610. drNew["类型"] = "满意数量";
  611. break;
  612. case 4:
  613. drNew["类型"] = "不满意数量";
  614. break;
  615. }
  616. if (i < ConsultingNeedslist.Count + 5 && i >= 5)
  617. {
  618. drNew["类型"] = ConsultingNeedslist[i - 5].F_QuestionName;
  619. }
  620. else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
  621. {
  622. drNew["类型"] = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
  623. }
  624. else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
  625. {
  626. drNew["类型"] = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
  627. }
  628. if (i == 1)
  629. {
  630. if (total > 0)
  631. {
  632. drNew["尿素"] = string.Format("{0:f2}%", urea / total * 100);
  633. drNew["复合肥"] = string.Format("{0:f2}%", compound / total * 100);
  634. drNew["水溶肥"] = string.Format("{0:f2}%", fertilizer / total * 100);
  635. drNew["车用尿素"] = string.Format("{0:f2}%", vehicle / total * 100);
  636. drNew["三聚氰胺"] = string.Format("{0:f2}%", melamine / total * 100);
  637. drNew["甲醇"] = string.Format("{0:f2}%", methanol / total * 100);
  638. drNew["糠醇"] = string.Format("{0:f2}%", furfuryl / total * 100);
  639. drNew["腐植酸"] = string.Format("{0:f2}%", humic / total * 100);
  640. drNew["二甲醚"] = string.Format("{0:f2}%", dimethyl / total * 100);
  641. drNew["糠醛"] =string.Format("{0:f2}%", furfural / total * 100);
  642. drNew["液氨"] = string.Format("{0:f2}%", liquid / total * 100);
  643. drNew["其他"] = string.Format("{0:f2}%", other / total * 100);
  644. }
  645. else
  646. {
  647. drNew["尿素"] = "0.00%";
  648. drNew["复合肥"] = "0.00%";
  649. drNew["水溶肥"] = "0.00%";
  650. drNew["车用尿素"] = "0.00%";
  651. drNew["三聚氰胺"] = "0.00%";
  652. drNew["甲醇"] = "0.00%";
  653. drNew["糠醇"] = "0.00%";
  654. drNew["腐植酸"] = "0.00%";
  655. drNew["二甲醚"] = "0.00%";
  656. drNew["糠醛"] = "0.00%";
  657. drNew["液氨"] = "0.00%";
  658. drNew["其他"] = "0.00%";
  659. }
  660. }
  661. else
  662. {
  663. drNew["尿素"] = urea.ToString();
  664. drNew["复合肥"] = compound.ToString();
  665. drNew["水溶肥"] = fertilizer.ToString();
  666. drNew["车用尿素"] = vehicle.ToString();
  667. drNew["三聚氰胺"] = melamine.ToString();
  668. drNew["甲醇"] = methanol.ToString();
  669. drNew["糠醇"] = furfuryl.ToString();
  670. drNew["腐植酸"] = humic.ToString();
  671. drNew["二甲醚"] = dimethyl.ToString();
  672. drNew["糠醛"] = furfural.ToString();
  673. drNew["液氨"] = liquid.ToString();
  674. drNew["其他"] = other.ToString();
  675. }
  676. dt.Rows.Add(drNew);
  677. }
  678. NPOIHelper npoi = new NPOIHelper();
  679. if (npoi.ExportToExcel("产品名称明细表", dt) == "")
  680. {
  681. return Success("导出成功");
  682. }
  683. else
  684. {
  685. return Error("导出失败");
  686. }
  687. }
  688. /// <summary>
  689. /// 产品名称明细表
  690. /// </summary>
  691. /// <param name="stime"></param>
  692. /// <param name="endtime"></param>
  693. /// <returns></returns>
  694. public ActionResult GetProductlist(string stime, string endtime)
  695. {
  696. string sql = $" F_IsDelete=0";
  697. if (stime != null && stime.Trim() != "")
  698. {
  699. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  700. }
  701. if (endtime != null && endtime.Trim() != "")
  702. {
  703. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  704. }
  705. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  706. var ConsultingNeeds = quesBLL.GetList(" F_Type = '" + EnumWOType.ConsultingNeeds.ToString() + "' and F_IsDelete=0 ").Tables[0];
  707. var Complaint = quesBLL.GetList(" F_Type = '" + EnumWOType.Complaint.ToString() + "' and F_IsDelete=0 " + "and F_Label=3").Tables[0];
  708. var SpotCheck = quesBLL.GetList(" F_Type = '" + EnumWOType.SpotCheck.ToString() + "' and F_IsDelete=0 ").Tables[0];
  709. List<Model.T_Wo_WorkOrder> workerurea = woBLL.GetModelList(sql + "and F_TS_Category='尿素'");
  710. List<Model.T_Wo_WorkOrder> workercompound = woBLL.GetModelList(sql + "and F_TS_Category='复合肥'");
  711. List<Model.T_Wo_WorkOrder> workerfertilizer = woBLL.GetModelList(sql + "and F_TS_Category='水溶肥'");
  712. List<Model.T_Wo_WorkOrder> workervehicle = woBLL.GetModelList(sql + "and F_TS_Category='车用尿素'");
  713. List<Model.T_Wo_WorkOrder> workermelamine = woBLL.GetModelList(sql + "and F_TS_Category='三聚氰胺'");
  714. List<Model.T_Wo_WorkOrder> workermethanol = woBLL.GetModelList(sql + "and F_TS_Category='甲醇'");
  715. List<Model.T_Wo_WorkOrder> workerfurfuryl = woBLL.GetModelList(sql + "and F_TS_Category='糠醇'");
  716. List<Model.T_Wo_WorkOrder> workerhumic = woBLL.GetModelList(sql + "and F_TS_Category='腐植酸'");
  717. List<Model.T_Wo_WorkOrder> workerdimethyl = woBLL.GetModelList(sql + "and F_TS_Category='二甲醚'");
  718. List<Model.T_Wo_WorkOrder> workerfurfural = woBLL.GetModelList(sql + "and F_TS_Category='糠醛'");
  719. List<Model.T_Wo_WorkOrder> workerliquid = woBLL.GetModelList(sql + "and F_TS_Category='液氨'");
  720. List<Model.T_Wo_WorkOrder> workerother = woBLL.GetModelList(sql + "and F_TS_Category='其他'");
  721. List<Model.T_Wo_WorkOrder> workertotal = woBLL.GetModelList(sql );
  722. List<Model.T_Wo_QuestionManage> ConsultingNeedslist = quesBLL.DataTableToList(ConsultingNeeds);//咨询
  723. List<Model.T_Wo_QuestionManage> Complaintlist = quesBLL.DataTableToList(Complaint);//投诉
  724. List<Model.T_Wo_QuestionManage> SpotChecklist = quesBLL.DataTableToList(SpotCheck);//抽检
  725. List<Category> markets = new List<Category>();
  726. for (int i = 0; i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5; i++)
  727. {
  728. float urea = 0, compound=0, fertilizer=0, vehicle=0, total=0, melamine=0, methanol=0, furfuryl=0
  729. , humic=0, dimethyl=0, furfural=0, liquid=0, other=0;
  730. urea = workercount(i, workerurea, ConsultingNeedslist, Complaintlist, SpotChecklist);
  731. compound = workercount(i, workercompound, ConsultingNeedslist, Complaintlist, SpotChecklist);
  732. fertilizer = workercount(i, workerfertilizer, ConsultingNeedslist, Complaintlist, SpotChecklist);
  733. vehicle = workercount(i, workervehicle, ConsultingNeedslist, Complaintlist, SpotChecklist);
  734. melamine = workercount(i, workermelamine, ConsultingNeedslist, Complaintlist, SpotChecklist);
  735. methanol = workercount(i, workermethanol, ConsultingNeedslist, Complaintlist, SpotChecklist);
  736. furfuryl = workercount(i, workerfurfuryl, ConsultingNeedslist, Complaintlist, SpotChecklist);
  737. humic = workercount(i, workerhumic, ConsultingNeedslist, Complaintlist, SpotChecklist);
  738. dimethyl = workercount(i, workerdimethyl, ConsultingNeedslist, Complaintlist, SpotChecklist);
  739. furfural = workercount(i, workerfurfural, ConsultingNeedslist, Complaintlist, SpotChecklist);
  740. liquid = workercount(i, workerliquid, ConsultingNeedslist, Complaintlist, SpotChecklist);
  741. other = workercount(i, workerother, ConsultingNeedslist, Complaintlist, SpotChecklist);
  742. total = workercount(i, workertotal, ConsultingNeedslist, Complaintlist, SpotChecklist);
  743. Category brand = new Category();
  744. switch (i)
  745. {
  746. case 0:
  747. brand.typename = "合计";
  748. break;
  749. case 1:
  750. brand.typename = "即时办结率";
  751. break;
  752. case 2:
  753. brand.typename = "超期数量";
  754. break;
  755. case 3:
  756. brand.typename = "满意数量";
  757. break;
  758. case 4:
  759. brand.typename = "不满意数量";
  760. break;
  761. }
  762. if (i < ConsultingNeedslist.Count + 5 && i >= 5)
  763. {
  764. brand.typename = ConsultingNeedslist[i - 5].F_QuestionName;
  765. }
  766. else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
  767. {
  768. brand.typename = Complaintlist[i - ConsultingNeedslist.Count - 5].F_QuestionName;
  769. }
  770. else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + SpotChecklist.Count + 5)
  771. {
  772. brand.typename = SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_QuestionName;
  773. }
  774. if (i == 1)
  775. {
  776. if (total > 0)
  777. {
  778. brand.urea = string.Format("{0:f2}%", urea / total * 100);
  779. brand.compound = string.Format("{0:f2}%", compound / total * 100);
  780. brand.fertilizer = string.Format("{0:f2}%", fertilizer / total * 100);
  781. brand.vehicle = string.Format("{0:f2}%", vehicle / total * 100);
  782. brand.melamine = string.Format("{0:f2}%", melamine / total * 100);
  783. brand.methanol = string.Format("{0:f2}%", methanol / total * 100);
  784. brand.furfuryl = string.Format("{0:f2}%", furfuryl / total * 100);
  785. brand.humic = string.Format("{0:f2}%", humic / total * 100);
  786. brand.dimethyl = string.Format("{0:f2}%", dimethyl / total * 100);
  787. brand.furfural = string.Format("{0:f2}%", furfural / total * 100);
  788. brand.liquid = string.Format("{0:f2}%", liquid / total * 100);
  789. brand.other = string.Format("{0:f2}%", other / total * 100);
  790. }
  791. else
  792. {
  793. brand.urea = "0.00%";
  794. brand.compound = "0.00%";
  795. brand.fertilizer = "0.00%";
  796. brand.vehicle = "0.00%";
  797. brand.melamine = "0.00%";
  798. brand.methanol = "0.00%";
  799. brand.furfuryl = "0.00%";
  800. brand.humic = "0.00%";
  801. brand.dimethyl = "0.00%";
  802. brand.furfural = "0.00%";
  803. brand.liquid = "0.00%";
  804. brand.other = "0.00%";
  805. }
  806. }
  807. else
  808. {
  809. brand.urea = urea.ToString();
  810. brand.compound = compound.ToString();
  811. brand.fertilizer = fertilizer.ToString();
  812. brand.vehicle = vehicle.ToString();
  813. brand.melamine = melamine.ToString();
  814. brand.methanol = methanol.ToString();
  815. brand.furfuryl = furfuryl.ToString();
  816. brand.humic = humic.ToString();
  817. brand.dimethyl = dimethyl.ToString();
  818. brand.furfural = furfural.ToString();
  819. brand.liquid = liquid.ToString();
  820. brand.other = other.ToString();
  821. }
  822. markets.Add(brand);
  823. }
  824. return Success("获取成功", markets);
  825. }
  826. public class Department
  827. {
  828. public string dapatname;
  829. public int pending;//待接单
  830. public int beprocessed;//待处理
  831. public int processed;//已处理
  832. public int Overdue;//超期
  833. public int satisfied;//满意
  834. public int dissatisfied;//不满意
  835. }
  836. public int GetDeptWorkOrderID(int deptId)
  837. {
  838. int str =0;
  839. var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + deptId);
  840. foreach (var it in user)
  841. {
  842. if (it .F_RoleId==59)
  843. {
  844. str = deptId;
  845. break;
  846. }
  847. }
  848. return str;
  849. }
  850. /// <summary>
  851. /// 导出部门工单数量表
  852. /// </summary>
  853. /// <param name="stime"></param>
  854. /// <param name="endtime"></param>
  855. /// <returns></returns>
  856. public ActionResult ExitDepartmentlist(string stime, string endtime)
  857. {
  858. DataTable dt = new DataTable();
  859. string sql = $" F_IsDelete=0";
  860. if (stime != null && stime.Trim() != "")
  861. {
  862. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  863. }
  864. if (endtime != null && endtime.Trim() != "")
  865. {
  866. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  867. }
  868. var tab = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=0");
  869. List<int> modeldeptid = new List<int>();
  870. List<string> modeldeptname = new List<string>();
  871. foreach (var it in tab)
  872. {
  873. if (GetDeptWorkOrderID(it.F_DeptId) > 0)
  874. {
  875. modeldeptid.Add(it.F_DeptId);
  876. modeldeptname.Add(it.F_DeptName);
  877. }
  878. }
  879. dt.Columns.Add("部门名称");
  880. dt.Columns.Add("待接单");
  881. dt.Columns.Add("待处理");
  882. dt.Columns.Add("已处理");
  883. dt.Columns.Add("超期数量");
  884. dt.Columns.Add("满意数量");
  885. dt.Columns.Add("不满意数量");
  886. for (int i = 0; i < modeldeptid.Count; i++)
  887. {
  888. DataRow drNew = dt.NewRow();
  889. var itemlist = itembll.GetModelList("F_NextDept=" + modeldeptid[i]);
  890. drNew["部门名称"] = modeldeptname[i];
  891. int pending = 0; int beprocessed = 0; int processed = 0; int Overdue = 0; int satisfied = 0; int dissatisfied = 0;
  892. foreach (var it in itemlist)
  893. {
  894. if (it.F_IsUsed == 0 && it.F_OptType == 1)
  895. {
  896. pending++;
  897. var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
  898. Overdue++;
  899. }
  900. if (it.F_OptType == 2 && it.F_IsUsed == 0)
  901. {
  902. beprocessed++;
  903. var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
  904. Overdue++;
  905. }
  906. }
  907. var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + modeldeptid[i]);
  908. foreach (var it in user)
  909. {
  910. if (it.F_RoleId == 59)
  911. {
  912. var workorder = woBLL.GetModelList(sql + "and F_State=10 and F_DealBy='" + it.F_UserCode + "'");
  913. processed += workorder.Count;
  914. foreach (var im in workorder)
  915. {
  916. if (im.F_IsOver == 1)
  917. Overdue++;
  918. if (im.F_VisitResult == "满意" || im.F_VisitResult == "非常满意")
  919. satisfied++;
  920. if (im.F_VisitResult == "不满意")
  921. dissatisfied++;
  922. }
  923. }
  924. }
  925. drNew["待接单"] = pending;
  926. drNew["待处理"] = beprocessed;
  927. drNew["已处理"] = processed;
  928. drNew["超期数量"] = Overdue;
  929. drNew["满意数量"] = satisfied;
  930. drNew["不满意数量"] = dissatisfied;
  931. dt.Rows.Add(drNew);
  932. }
  933. NPOIHelper npoi = new NPOIHelper();
  934. if (npoi.ExportToExcel("部门工单数量表", dt) == "")
  935. {
  936. return Success("导出成功");
  937. }
  938. else
  939. {
  940. return Error("导出失败");
  941. }
  942. }
  943. /// <summary>
  944. /// 部门工单数量表
  945. /// </summary>
  946. /// <param name="stime"></param>
  947. /// <param name="endtime"></param>
  948. /// <returns></returns>
  949. public ActionResult GetDepartmentList(string stime, string endtime)
  950. {
  951. string sql = $" F_IsDelete=0";
  952. if (stime != null && stime.Trim() != "")
  953. {
  954. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  955. }
  956. if (endtime != null && endtime.Trim() != "")
  957. {
  958. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  959. }
  960. var tab = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=0");
  961. List<int> modeldeptid = new List<int>();
  962. List<string > modeldeptname= new List<string>();
  963. foreach (var it in tab)
  964. {
  965. if (GetDeptWorkOrderID(it .F_DeptId )>0)
  966. {
  967. modeldeptid.Add(it.F_DeptId);
  968. modeldeptname.Add(it.F_DeptName);
  969. }
  970. }
  971. List<Department> Departmentlist = new List<Department>();
  972. for (int i=0;i< modeldeptid.Count;i++)
  973. {
  974. var itemlist = itembll.GetModelList("F_NextDept=" + modeldeptid[i]);
  975. Department model = new Department();
  976. model.dapatname = modeldeptname[i];
  977. int pending = 0;int beprocessed = 0;int processed = 0;int Overdue = 0;int satisfied = 0;int dissatisfied = 0;
  978. foreach (var it in itemlist)
  979. {
  980. if (it .F_IsUsed ==0&&it .F_OptType ==1)
  981. {
  982. pending++;
  983. var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID );
  984. Overdue++;
  985. }
  986. if (it .F_OptType ==2&& it.F_IsUsed == 0)
  987. {
  988. beprocessed++;
  989. var Overworkorder = woBLL.GetModelList(sql + "and F_IsOver=1 and F_ID=" + it.F_WoID);
  990. Overdue++;
  991. }
  992. }
  993. var user = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId =" + modeldeptid[i ]);
  994. foreach (var it in user)
  995. {
  996. if (it.F_RoleId == 59)
  997. {
  998. var workorder = woBLL.GetModelList(sql + "and F_State=10 and F_DealBy='" + it.F_UserCode + "'");
  999. processed += workorder.Count;
  1000. foreach (var im in workorder)
  1001. {
  1002. if (im .F_IsOver ==1)
  1003. Overdue++;
  1004. if (im.F_VisitResult == "满意" || im.F_VisitResult == "非常满意")
  1005. satisfied++;
  1006. if (im.F_VisitResult == "不满意")
  1007. dissatisfied++;
  1008. }
  1009. }
  1010. }
  1011. model.pending = pending;
  1012. model.beprocessed = beprocessed;
  1013. model.processed = processed;
  1014. model.Overdue = Overdue;
  1015. model.satisfied = satisfied;
  1016. model.dissatisfied = dissatisfied;
  1017. Departmentlist.Add(model);
  1018. }
  1019. if (Departmentlist.Count > 0)
  1020. {
  1021. for (int j = 0; j < Departmentlist.Count - 1; j++)
  1022. {
  1023. for (int z = 0; z < Departmentlist.Count - 1 - j; z++)
  1024. {
  1025. if (Departmentlist[z].processed < Departmentlist[z + 1].processed)
  1026. {
  1027. var temp = Departmentlist[z + 1];
  1028. Departmentlist[z + 1] = Departmentlist[z];
  1029. Departmentlist[z] = temp;
  1030. }
  1031. }
  1032. }
  1033. }
  1034. return Success("获取成功", Departmentlist);
  1035. }
  1036. public class Returnvisit
  1037. {
  1038. public string name;
  1039. public int bevisit;
  1040. public int visit;
  1041. public int Overdue;
  1042. public int visitcont;
  1043. public int verysatisfied;
  1044. public int satisfied;
  1045. public int commonly;
  1046. public int dissatisfied;
  1047. public int other;
  1048. }
  1049. /// <summary>
  1050. /// 导出客户回访数量表
  1051. /// </summary>
  1052. /// <param name="stime"></param>
  1053. /// <param name="endtime"></param>
  1054. /// <returns></returns>
  1055. public ActionResult ExitReturnvisitList(string stime, string endtime)
  1056. {
  1057. DataTable dt = new DataTable();
  1058. string sql = $" F_IsDelete=0";
  1059. if (stime != null && stime.Trim() != "")
  1060. {
  1061. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1062. }
  1063. if (endtime != null && endtime.Trim() != "")
  1064. {
  1065. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1066. }
  1067. dt.Columns.Add("类别");
  1068. dt.Columns.Add("待回访");
  1069. dt.Columns.Add("已回访");
  1070. dt.Columns.Add("回访总数");
  1071. dt.Columns.Add("超期数量");
  1072. dt.Columns.Add("满意数量");
  1073. dt.Columns.Add("不满意数量");
  1074. var workordewr = woBLL.GetModelList(sql + "and F_State in(10,11) and F_IsVisit =1");
  1075. string name = "客户回访"; int bevisit = 0, visit = 0, Overdue = 0, satisfied = 0, dissatisfied = 0; int visitcont = 0;
  1076. var workorder = woBLL.GetModelList(sql + "and F_State in(10,11)");
  1077. visitcont = workorder.Count;
  1078. foreach (var it in workordewr)
  1079. {
  1080. if (it.F_State == 10)
  1081. bevisit++;
  1082. if (it.F_State == 11)
  1083. visit++;
  1084. if (it.F_IsOver == 1&&it .F_Type !="3")
  1085. Overdue++;
  1086. if (it.F_VisitResult == "满意" || it.F_VisitResult == "非常满意")
  1087. satisfied++;
  1088. if (it.F_VisitResult == "不满意")
  1089. dissatisfied++;
  1090. }
  1091. var obj = new
  1092. {
  1093. name,
  1094. bevisit,
  1095. visit,
  1096. visitcont,
  1097. Overdue,
  1098. satisfied,
  1099. dissatisfied
  1100. };
  1101. DataRow drNew = dt.NewRow();
  1102. drNew["类别"] = name;
  1103. drNew["待回访"] = bevisit;
  1104. drNew["已回访"] = visit;
  1105. drNew["回访总数"] = visitcont;
  1106. drNew["超期数量"] = Overdue;
  1107. drNew["满意数量"] = satisfied;
  1108. drNew["不满意数量"] = dissatisfied;
  1109. dt.Rows.Add(drNew);
  1110. NPOIHelper npoi = new NPOIHelper();
  1111. if (npoi.ExportToExcel("客户回访数量表", dt) == "")
  1112. {
  1113. return Success("导出成功");
  1114. }
  1115. else
  1116. {
  1117. return Error("导出失败");
  1118. }
  1119. }
  1120. /// <summary>
  1121. /// 客户回访数量表
  1122. /// </summary>
  1123. /// <param name="stime"></param>
  1124. /// <param name="endtime"></param>
  1125. /// <returns></returns>
  1126. public ActionResult GetReturnvisitList(string stime, string endtime)
  1127. {
  1128. string sql = $" F_IsDelete=0";
  1129. if (stime != null && stime.Trim() != "")
  1130. {
  1131. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1132. }
  1133. if (endtime != null && endtime.Trim() != "")
  1134. {
  1135. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1136. }
  1137. List<Returnvisit> returnvisits = new List<Returnvisit>();
  1138. Returnvisit model = new Returnvisit();
  1139. var workordewr = woBLL.GetModelList(sql + "and F_State in(10,11) and F_IsVisit =1");
  1140. model. name ="客户回访"; int bevisit = 0, visit = 0, Overdue = 0, verysatisfied = 0, satisfied=0, commonly=0, dissatisfied = 0;int visitcont = 0, other=0;
  1141. var workorder = woBLL.GetModelList(sql + "and F_State in(10,11)");
  1142. visitcont = workorder.Count;
  1143. foreach (var it in workordewr)
  1144. {
  1145. if (it.F_State == 10)
  1146. bevisit++;
  1147. if (it.F_IsOver == 1)
  1148. Overdue++;
  1149. if (it.F_State == 11)
  1150. {
  1151. visit++;
  1152. if (it.F_VisitResult == "非常满意")
  1153. verysatisfied++;
  1154. if (it.F_VisitResult == "满意")
  1155. satisfied++;
  1156. if (it.F_VisitResult == "一般")
  1157. commonly++;
  1158. if (it.F_VisitResult == "不满意")
  1159. dissatisfied++;
  1160. if (it.F_VisitResult == "其他" || it.F_VisitResult == "")
  1161. other++;
  1162. }
  1163. }
  1164. model.bevisit = bevisit; model.visit = visit; model.visitcont = visitcont; model.Overdue = Overdue;
  1165. model.satisfied = satisfied; model.dissatisfied = dissatisfied; model.verysatisfied = verysatisfied;
  1166. model.commonly = commonly;model.other = other;
  1167. returnvisits.Add(model);
  1168. return Success("获取成功", returnvisits
  1169. );
  1170. }
  1171. 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)
  1172. {
  1173. int total = 0;
  1174. foreach (var it in workerlist)
  1175. {
  1176. switch (i)
  1177. {
  1178. case 0:
  1179. total++;
  1180. break;
  1181. case 1:
  1182. if (it.F_DealType == "当即办理")
  1183. total++;
  1184. break;
  1185. case 2:
  1186. if (it.F_IsOver == 1&&it .F_Type !="3")
  1187. total++;
  1188. break;
  1189. case 3:
  1190. if (it.F_VisitResult == "满意" || it.F_VisitResult == "非常满意")
  1191. total++;
  1192. break;
  1193. case 4:
  1194. if (it.F_VisitResult == "不满意")
  1195. total++;
  1196. break;
  1197. }
  1198. if (i < ConsultingNeedslist.Count + 5 && i >= 5)
  1199. {
  1200. if (it.F_QuestionType == ConsultingNeedslist[i - 5].F_Id.ToString () )
  1201. total++;
  1202. }
  1203. else if (i >= ConsultingNeedslist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count + 5)
  1204. {
  1205. if (it.F_QuestionType == Complaintlist[i - ConsultingNeedslist.Count - 5].F_Id.ToString())
  1206. total++;
  1207. }
  1208. else if (i >= ConsultingNeedslist.Count + Complaintlist.Count + 5 && i < ConsultingNeedslist.Count + Complaintlist.Count+ SpotChecklist.Count + 5)
  1209. {
  1210. if (it.F_QuestionType == SpotChecklist[i - ConsultingNeedslist.Count - Complaintlist.Count - 5].F_Id.ToString())
  1211. total++;
  1212. }
  1213. }
  1214. return total;
  1215. }
  1216. /// <summary>
  1217. /// 导出集团市场问题反馈汇总表
  1218. /// </summary>
  1219. /// <param name="ids"></param>
  1220. /// <returns></returns>
  1221. public ActionResult ExptQuestionList(string stime, string endtime, string salesBase, string channel, int type = 0)
  1222. {
  1223. string sql = $" F_IsDelete=0";
  1224. DataTable dt = new DataTable();
  1225. #region 筛选条件
  1226. if (type > 0 && type < 5)//工单类型
  1227. sql += $" and F_Type=" + type;
  1228. if (stime != null && stime.Trim() != "")
  1229. {
  1230. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1231. }
  1232. if (endtime != null && endtime.Trim() != "")
  1233. {
  1234. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1235. }
  1236. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1237. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1238. if (!string.IsNullOrWhiteSpace(channel))
  1239. {
  1240. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1241. }
  1242. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1243. sql += " order by F_CreateOn desc";
  1244. var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
  1245. #endregion
  1246. dt.Columns.Add("创建时间");
  1247. dt.Columns.Add("销售基地");
  1248. dt.Columns.Add("渠道类型");
  1249. dt.Columns.Add("反馈类型");
  1250. dt.Columns.Add("费用");
  1251. dt.Columns.Add("大区名称");
  1252. dt.Columns.Add("分公司名称");
  1253. dt.Columns.Add("业务员");
  1254. dt.Columns.Add("品牌");
  1255. dt.Columns.Add("产品");
  1256. dt.Columns.Add("超时时限");
  1257. dt.Columns.Add("回访与否");
  1258. dt.Columns.Add("关闭与否");
  1259. foreach (var it in depts)
  1260. {
  1261. DataRow drNew = dt.NewRow();
  1262. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  1263. if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
  1264. {
  1265. cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
  1266. }
  1267. else
  1268. {
  1269. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
  1270. }
  1271. if (cuModel != null)
  1272. {
  1273. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  1274. {
  1275. Model.T_Sys_Department pdModel = new T_Sys_Department();
  1276. try
  1277. {
  1278. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  1279. }
  1280. catch
  1281. {
  1282. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  1283. }
  1284. if (pdModel != null)
  1285. {
  1286. drNew["大区名称"] = pdModel.F_DeptName;
  1287. }
  1288. }
  1289. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  1290. {
  1291. Model.T_Sys_Department pdModel1 = new T_Sys_Department();
  1292. try
  1293. {
  1294. pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
  1295. }
  1296. catch
  1297. {
  1298. pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
  1299. }
  1300. if (pdModel1 != null)
  1301. {
  1302. drNew["分公司名称"] = pdModel1.F_DeptName;
  1303. }
  1304. }
  1305. drNew["业务员"] = cuModel.F_Salesman;
  1306. drNew["品牌"] = cuModel.F_Brands;
  1307. drNew["渠道类型"] = cuModel.F_Channel;
  1308. }
  1309. drNew["产品"] = it.F_TS_Category;
  1310. if (it.F_Type == "1")
  1311. {
  1312. drNew["反馈类型"] = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1313. }
  1314. else if (it.F_Type == "2")
  1315. {
  1316. drNew["反馈类型"] = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1317. }
  1318. else if (it.F_Type == "3")
  1319. {
  1320. drNew["反馈类型"] = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1321. }
  1322. else
  1323. {
  1324. drNew["反馈类型"] = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  1325. }
  1326. drNew["销售基地"] = it.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  1327. drNew["创建时间"] = it.F_CreateOn.ToString();
  1328. if (it .F_Type !="3")
  1329. {
  1330. if (TimeToOver(it.F_ID, it.F_limit) < 0)
  1331. drNew["超时时限"] = Math.Abs(TimeToOver(it.F_ID, it.F_limit)).ToString();
  1332. else
  1333. drNew["超时时限"] = "0";
  1334. }
  1335. else
  1336. drNew["超时时限"] = "0";
  1337. if (it.F_State == 11 && it.F_IsVisit == 1)
  1338. drNew["回访与否"] = "是";
  1339. else
  1340. drNew["回访与否"] = "否";
  1341. if (it.F_State == 11)
  1342. drNew["关闭与否"] = "是";
  1343. else
  1344. drNew["关闭与否"] = "否";
  1345. dt .Rows.Add(drNew);
  1346. }
  1347. NPOIHelper npoi = new NPOIHelper();
  1348. if (npoi.ExportToExcel("集团市场问题反馈汇总表", dt) == "")
  1349. {
  1350. return Success("导出成功");
  1351. }
  1352. else
  1353. {
  1354. return Error("导出失败");
  1355. }
  1356. }
  1357. /// <summary>
  1358. /// 集团市场问题反馈汇总表
  1359. /// </summary>
  1360. /// <returns></returns>
  1361. public ActionResult GetQuestionList(string stime, string endtime, string salesBase, string channel, int type = 0, int page = 1, int limit = 10)
  1362. {
  1363. string sql = $" and F_IsDelete=0";
  1364. DataTable dt = new DataTable();
  1365. #region 筛选条件
  1366. if (type > 0 && type < 5)//工单类型
  1367. sql += $" and F_Type=" + type;
  1368. if (stime != null && stime.Trim() != "")
  1369. {
  1370. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1371. }
  1372. if (endtime != null && endtime.Trim() != "")
  1373. {
  1374. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1375. }
  1376. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1377. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1378. if (!string.IsNullOrWhiteSpace(channel))
  1379. {
  1380. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1381. }
  1382. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1383. #endregion
  1384. int recordCount = 0;
  1385. if (!string.IsNullOrWhiteSpace(sql))
  1386. {
  1387. dt = BLL.PagerBLL.GetListPager(
  1388. "T_Wo_WorkOrder",
  1389. "F_ID",
  1390. "*",
  1391. sql,
  1392. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  1393. limit,
  1394. page,
  1395. true,
  1396. out recordCount);
  1397. }
  1398. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  1399. if (modlelist.Count > 0)
  1400. {
  1401. List<Questions> input = modeltooip(modlelist);
  1402. var obj = new
  1403. {
  1404. state = "success",
  1405. message = "成功",
  1406. rows = input,
  1407. total = recordCount
  1408. };
  1409. return Content(obj.ToJson()); ;
  1410. }
  1411. else
  1412. {
  1413. return Success("暂无工单"); ;
  1414. }
  1415. }
  1416. /// <summary>
  1417. /// 导出化肥产品投诉明细表
  1418. /// </summary>
  1419. /// <param name="ids"></param>
  1420. /// <returns></returns>
  1421. public ActionResult ExptComplaintList(string stime, string endtime, string salesBase, string channel)
  1422. {
  1423. string sql = $" F_IsDelete=0";
  1424. DataTable dt = new DataTable();
  1425. #region 筛选条件
  1426. sql += $" and F_Type=" + 2;
  1427. if (stime != null && stime.Trim() != "")
  1428. {
  1429. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1430. }
  1431. if (endtime != null && endtime.Trim() != "")
  1432. {
  1433. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1434. }
  1435. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1436. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1437. if (!string.IsNullOrWhiteSpace(channel))
  1438. {
  1439. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1440. }
  1441. sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化肥产品质量问题反馈','化肥服务质量问题反馈','化肥农作物长势问题反馈'") + "') "; ;
  1442. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1443. sql += " order by F_CreateOn desc";
  1444. #endregion
  1445. var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
  1446. dt.Columns.Add("客户姓名");
  1447. dt.Columns.Add("客户电话");
  1448. dt.Columns.Add("公司名称");
  1449. dt.Columns.Add("事发地-省");
  1450. dt.Columns.Add("事发地-市");
  1451. dt.Columns.Add("事发地-县");
  1452. dt.Columns.Add("事发地-乡");
  1453. dt.Columns.Add("事发地-详细");
  1454. dt.Columns.Add("销售基地");
  1455. dt.Columns.Add("大区名称");
  1456. dt.Columns.Add("业务员");
  1457. dt.Columns.Add("问题描述");
  1458. dt.Columns.Add("问题类别1");
  1459. dt.Columns.Add("问题类别2");
  1460. dt.Columns.Add("问题类别3");
  1461. dt.Columns.Add("客户编号");
  1462. dt.Columns.Add("物料编码");
  1463. dt.Columns.Add("物料名称");
  1464. dt.Columns.Add("型号");
  1465. dt.Columns.Add("规格");
  1466. dt.Columns.Add("一级分类");
  1467. dt.Columns.Add("二级分类");
  1468. dt.Columns.Add("三级分类");
  1469. dt.Columns.Add("品牌");
  1470. dt.Columns.Add("复合肥肥效");
  1471. dt.Columns.Add("产品线");
  1472. dt.Columns.Add("工艺");
  1473. dt.Columns.Add("生产批次号");
  1474. dt.Columns.Add("问题数量");
  1475. dt.Columns.Add("生产基地");
  1476. dt.Columns.Add("初审意见");
  1477. dt.Columns.Add("超出质保期限");
  1478. dt.Columns.Add("质量事件等级");
  1479. dt.Columns.Add("索赔金额");
  1480. dt.Columns.Add("责任单位");
  1481. dt.Columns.Add("审批意见");
  1482. dt.Columns.Add("审批不同意意见");
  1483. dt.Columns.Add("补偿方式");
  1484. dt.Columns.Add("补偿钱款");
  1485. dt.Columns.Add("对应责任单位");
  1486. dt.Columns.Add("确认实收数量");
  1487. dt.Columns.Add("改进要求");
  1488. dt.Columns.Add("对应审批工作流单号");
  1489. dt.Columns.Add("处理方式");
  1490. dt.Columns.Add("处理人");
  1491. dt.Columns.Add("处理时间");
  1492. dt.Columns.Add("处理内容");
  1493. dt.Columns.Add("处理结果");
  1494. dt.Columns.Add("未处理原因");
  1495. dt.Columns.Add("添加时间");
  1496. foreach (var it in depts)
  1497. {
  1498. DataRow drNew = dt.NewRow();
  1499. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  1500. if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
  1501. {
  1502. cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
  1503. }
  1504. else
  1505. {
  1506. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
  1507. }
  1508. if (cuModel != null)
  1509. {
  1510. drNew["客户编号"] = cuModel.F_CustomerCode ;//
  1511. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  1512. {
  1513. Model.T_Sys_Department pdModel = new T_Sys_Department();
  1514. try
  1515. {
  1516. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  1517. }
  1518. catch
  1519. {
  1520. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  1521. }
  1522. if (pdModel != null)
  1523. {
  1524. drNew["大区名称"] = pdModel.F_DeptName;
  1525. }
  1526. }
  1527. drNew["业务员"] = cuModel.F_Salesman;//业务员
  1528. }
  1529. if (!string .IsNullOrEmpty (it.F_MaterialID))
  1530. {
  1531. if (valcode(it.F_MaterialID.ToString(), 11))
  1532. {
  1533. drNew["物料编码"] = it.F_MaterialID;//验证物料编码为11位纯数字
  1534. Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(it.F_MaterialID.ToString());//通过物料编码获取物料信息
  1535. if (maModel != null)
  1536. {
  1537. drNew["物料名称"] = maModel.F_MaterialName;//物料名称
  1538. drNew["型号"] = maModel.F_Model;//型号
  1539. drNew["规格"] = maModel.F_Specs;//规格
  1540. drNew["一级分类"] = maModel.F_Level1;//一级分类
  1541. drNew["二级分类"] = maModel.F_Level2;//二级分类
  1542. drNew["三级分类"] = maModel.F_Level3;//三级分类
  1543. drNew["品牌"] = maModel.F_Brand;//品牌
  1544. drNew["复合肥肥效"] = maModel.F_MaterialEffect;//F_MaterialEffect
  1545. drNew["产品线"] = maModel.F_Pipeline;//F_Pipeline
  1546. drNew["工艺"] = maModel.F_Craft;//F_Craft
  1547. }
  1548. }
  1549. }
  1550. if (!string.IsNullOrEmpty(it.F_QuestionType))
  1551. {
  1552. Model.T_Wo_QuestionManage Manage = null;
  1553. try
  1554. {
  1555. int b = int.Parse(it.F_QuestionType.Trim());
  1556. Manage = quesBLL.GetModel(b);
  1557. }
  1558. catch (Exception)
  1559. {
  1560. Manage = quesBLL.GetModel(it.F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  1561. }
  1562. if (Manage != null)
  1563. {
  1564. if (Manage.F_Label == "1")
  1565. {
  1566. drNew["问题类别1"] = Manage.F_QuestionName;
  1567. drNew["问题类别2"] = "";
  1568. drNew["问题类别3"] = "";
  1569. }
  1570. else if (Manage.F_Label == "2")
  1571. {
  1572. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  1573. drNew["问题类别1"] = Manage1.F_QuestionName;
  1574. drNew["问题类别2"] = Manage.F_QuestionName;
  1575. drNew["问题类别3"] = "";
  1576. }
  1577. else
  1578. {
  1579. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  1580. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  1581. drNew["问题类别1"] = Manage2.F_QuestionName;//问题类别1
  1582. drNew["问题类别2"] = Manage1.F_QuestionName;//问题类别2
  1583. drNew["问题类别3"] = Manage.F_QuestionName;//问题类别3
  1584. }
  1585. }
  1586. }
  1587. drNew["客户姓名"] = it.F_CusName;//客户姓名
  1588. drNew["客户电话"] = it.F_CusPhone;//
  1589. drNew["公司名称"] = it.F_CompanyName;//
  1590. drNew["事发地-省"] = it.F_IncidentProvince;//
  1591. drNew["事发地-市"] = it.F_IncidentCity;//
  1592. drNew["事发地-县"] = it.F_IncidentCountry;//
  1593. drNew["事发地-乡"] = it.F_IncidentTownship;//
  1594. drNew["事发地-详细"] = it.F_IncidentDetailed;//
  1595. drNew["销售基地"] = it.F_SalesBase;//:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  1596. drNew["问题描述"] = it.F_Description;//
  1597. drNew["生产批次号"] = it.F_BatchNumber;//
  1598. drNew["问题数量"] = it.F_TS_Quantity;//投诉-(吨)
  1599. drNew["生产基地"] = it.F_SC_ProductBase;//市场管理科-(新乡、新疆、九江、东北、贴牌、无法确定)
  1600. drNew["初审意见"] = it.F_SC_PreliminaryOpinion;// 市场管理科-:退货、换货、补偿、自行处理
  1601. drNew["超出质保期限"] = it.F_SC_QualityMonth;//市场管理科-(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
  1602. drNew["质量事件等级"] = it.F_ZL_QualityEventLevel;// 质量管理科-(未遂、一般、较大、重大)
  1603. drNew["索赔金额"] = it.F_ZL_ClaimAmount;//质量管理科-(单位元,对应责任单位)
  1604. drNew["责任单位"] = it.F_ZL_ResponsibleUnit;//质量管理科-(需列出,可选多个)
  1605. drNew["审批意见"] = it.F_ZL_ApprovalOpinions;// 质量管理科-(同意、不同意,若选择不同意,增加输入框输入补充内容)
  1606. drNew["审批不同意意见"] = it.F_ZL_ApprovalDisagree;// 质量管理科-
  1607. drNew["补偿方式"] = it.F_ZL_CompensationMethod;//质量管理科-(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  1608. drNew["补偿钱款"] = it.F_ZL_CompensationMoney;// 质量管理科-
  1609. drNew["对应责任单位"] = it.F_ZL_CResponsibleUnits;//质量管理科-(生产、研发、农化、物流、质量管理科,销售内勤)
  1610. drNew["确认实收数量"] = it.F_ZL_Fquantity;// 质量管理科-(吨)
  1611. drNew["改进要求"] = it.F_ZL_ImprovementRequirements;//质量管理科-
  1612. drNew["对应审批工作流单号"] = it.F_ZL_CApprovalNo;//质量管理科-
  1613. drNew["处理方式"] = it.F_DealType;//:当即办理、电话转接、网络转办
  1614. drNew["处理人"] = it.F_DealBy;//
  1615. drNew["处理时间"] = it.F_DealTime;//
  1616. drNew["处理内容"] = it.F_DealContent;//
  1617. if (it.F_State == 10 || it.F_State == 11)
  1618. drNew["处理结果"] = "已处理";//处理结果
  1619. else
  1620. drNew["处理结果"] = "未处理";//处理结果
  1621. drNew["未处理原因"] = it.F_DealReasons;//
  1622. drNew["添加时间"] = it.F_CreateOn; ;//
  1623. dt.Rows.Add(drNew);
  1624. }
  1625. NPOIHelper npoi = new NPOIHelper();
  1626. if (npoi.ExportToExcel("化肥产品投诉明细表", dt) == "")
  1627. {
  1628. return Success("导出成功");
  1629. }
  1630. else
  1631. {
  1632. return Error("导出失败");
  1633. }
  1634. }
  1635. /// <summary>
  1636. /// 获取问题类别
  1637. /// </summary>
  1638. /// <returns></returns>
  1639. public string GetComplaint(string msg)
  1640. {
  1641. string str = "";
  1642. string str1 = " select F_Id from T_Wo_QuestionManage where F_QuestionName in(" + msg + ")";
  1643. string str3 = " select F_Id from T_Wo_QuestionManage where F_ParentId in(" + str1 + ")";
  1644. var dept = quesBLL .GetModelList("F_ParentId in(" + str3+")");
  1645. if (dept != null)
  1646. {
  1647. foreach (var it in dept)
  1648. {
  1649. if (str != "")
  1650. str += "','" + it.F_Id ;
  1651. else
  1652. str += it.F_Id;
  1653. }
  1654. }
  1655. // string str4 = " select F_Id from T_Wo_QuestionManage where F_ParentId in(" + str3 + ")";
  1656. return str;
  1657. }
  1658. /// <summary>
  1659. /// 化肥产品投诉明细表
  1660. /// </summary>
  1661. /// <returns></returns>
  1662. public ActionResult GetComplaintList(string stime, string endtime, string salesBase, string channel, int page = 1, int limit = 10)
  1663. {
  1664. string sql = $" and F_IsDelete=0";
  1665. DataTable dt = new DataTable();
  1666. #region 筛选条件
  1667. sql += $" and F_Type=" + 2;
  1668. if (stime != null && stime.Trim() != "")
  1669. {
  1670. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1671. }
  1672. if (endtime != null && endtime.Trim() != "")
  1673. {
  1674. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1675. }
  1676. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1677. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1678. if (!string.IsNullOrWhiteSpace(channel))
  1679. {
  1680. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1681. }
  1682. sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化肥产品质量问题反馈','化肥服务质量问题反馈','化肥农作物长势问题反馈'") + "') "; ;
  1683. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1684. #endregion
  1685. int recordCount = 0;
  1686. if (!string.IsNullOrWhiteSpace(sql))
  1687. {
  1688. dt = BLL.PagerBLL.GetListPager(
  1689. "T_Wo_WorkOrder",
  1690. "F_ID",
  1691. "*",
  1692. sql,
  1693. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  1694. limit,
  1695. page,
  1696. true,
  1697. out recordCount);
  1698. }
  1699. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  1700. if (modlelist.Count > 0)
  1701. {
  1702. List<WorkOrderComplaint> input = modelComplaint(modlelist);
  1703. var obj = new
  1704. {
  1705. state = "success",
  1706. message = "成功",
  1707. rows = input,
  1708. total = recordCount
  1709. };
  1710. return Content(obj.ToJson()); ;
  1711. }
  1712. else
  1713. {
  1714. return Success("暂无工单"); ;
  1715. }
  1716. }
  1717. /// <summary>
  1718. /// 导出市场投诉处理时效明细表
  1719. /// </summary>
  1720. /// <param name="ids"></param>
  1721. /// <returns></returns>
  1722. public ActionResult ExptPrescriptionList(string stime, string endtime, string salesBase, string channel)
  1723. {
  1724. string sql = $" F_IsDelete=0";
  1725. DataTable dt = new DataTable();
  1726. #region 筛选条件
  1727. sql += $" and F_Type=" + 2;
  1728. if (stime != null && stime.Trim() != "")
  1729. {
  1730. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1731. }
  1732. if (endtime != null && endtime.Trim() != "")
  1733. {
  1734. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1735. }
  1736. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1737. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1738. if (!string.IsNullOrWhiteSpace(channel))
  1739. {
  1740. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1741. }
  1742. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1743. sql += " order by F_CreateOn desc";
  1744. var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
  1745. #endregion
  1746. dt.Columns.Add("创建时间");
  1747. dt.Columns.Add("销售基地");
  1748. dt.Columns.Add("大区名称");
  1749. dt.Columns.Add("分公司名称");
  1750. dt.Columns.Add("产品");
  1751. dt.Columns.Add("品牌");
  1752. dt.Columns.Add("问题类别1");
  1753. dt.Columns.Add("问题类别2");
  1754. dt.Columns.Add("问题类别3");
  1755. dt.Columns.Add("问题描述");
  1756. dt.Columns.Add("生产基地");
  1757. dt.Columns.Add("对应责任单位");
  1758. foreach (var it in depts)
  1759. {
  1760. DataRow drNew = dt.NewRow();
  1761. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  1762. if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
  1763. {
  1764. cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
  1765. }
  1766. else
  1767. {
  1768. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
  1769. }
  1770. if (cuModel != null)
  1771. {
  1772. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  1773. {
  1774. Model.T_Sys_Department pdModel = new T_Sys_Department();
  1775. try
  1776. {
  1777. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  1778. }
  1779. catch
  1780. {
  1781. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  1782. }
  1783. if (pdModel != null)
  1784. {
  1785. drNew["大区名称"] = pdModel.F_DeptName;
  1786. }
  1787. }
  1788. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  1789. {
  1790. Model.T_Sys_Department pdModel1 = new T_Sys_Department();
  1791. try
  1792. {
  1793. pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
  1794. }
  1795. catch
  1796. {
  1797. pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
  1798. }
  1799. if (pdModel1 != null)
  1800. {
  1801. drNew["分公司名称"] = pdModel1.F_DeptName;
  1802. }
  1803. }
  1804. drNew["品牌"] = cuModel.F_Brands;//品牌
  1805. }
  1806. if (!string.IsNullOrEmpty(it.F_QuestionType))
  1807. {
  1808. Model.T_Wo_QuestionManage Manage = null ;
  1809. try
  1810. {
  1811. int b = int.Parse(it.F_QuestionType.Trim());
  1812. Manage = quesBLL.GetModel(b);
  1813. }
  1814. catch (Exception)
  1815. {
  1816. Manage = quesBLL.GetModel(it.F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  1817. }
  1818. if (Manage != null)
  1819. {
  1820. if (Manage.F_Label == "1")
  1821. {
  1822. drNew["问题类别1"] = Manage.F_QuestionName;
  1823. drNew["问题类别2"] = "";
  1824. drNew["问题类别3"] = "";
  1825. }
  1826. else if (Manage.F_Label == "2")
  1827. {
  1828. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  1829. drNew["问题类别1"] = Manage1.F_QuestionName;
  1830. drNew["问题类别2"] = Manage.F_QuestionName;
  1831. drNew["问题类别3"] = "";
  1832. }
  1833. else
  1834. {
  1835. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  1836. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  1837. drNew["问题类别1"] = Manage2.F_QuestionName;//问题类别1
  1838. drNew["问题类别2"] = Manage1.F_QuestionName;//问题类别2
  1839. drNew["问题类别3"] = Manage.F_QuestionName;//问题类别3
  1840. }
  1841. }
  1842. }
  1843. drNew["生产基地"] = it.F_SC_ProductBase;//生产基地
  1844. drNew["对应责任单位"] = it.F_ZL_CResponsibleUnits;//责任科室
  1845. drNew["问题描述"] = it.F_Description;//问题描述
  1846. drNew["产品"] = it.F_TS_Category;//产品
  1847. drNew["销售基地"] = it.F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  1848. drNew["创建时间"] = it.F_CreateOn.ToString();//时间
  1849. dt.Rows.Add(drNew);
  1850. }
  1851. NPOIHelper npoi = new NPOIHelper();
  1852. if (npoi.ExportToExcel("市场投诉处理时效明细表", dt) == "")
  1853. {
  1854. return Success("导出成功");
  1855. }
  1856. else
  1857. {
  1858. return Error("导出失败");
  1859. }
  1860. }
  1861. /// <summary>
  1862. /// 市场投诉处理时效明细表
  1863. /// </summary>
  1864. /// <returns></returns>
  1865. public ActionResult GetPrescriptionList(string stime, string endtime, string salesBase, string channel, string
  1866. question, int page = 1, int limit = 10)
  1867. {
  1868. string sql = $" and F_IsDelete=0";
  1869. DataTable dt = new DataTable();
  1870. #region 筛选条件
  1871. sql += $" and F_Type=" + 2;
  1872. if (stime != null && stime.Trim() != "")
  1873. {
  1874. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1875. }
  1876. if (endtime != null && endtime.Trim() != "")
  1877. {
  1878. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1879. }
  1880. if (!string.IsNullOrEmpty(question))
  1881. {
  1882. sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'" + question + "'") + "') "; ;
  1883. }
  1884. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1885. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1886. if (!string.IsNullOrWhiteSpace(channel))
  1887. {
  1888. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1889. }
  1890. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1891. #endregion
  1892. int recordCount = 0;
  1893. if (!string.IsNullOrWhiteSpace(sql))
  1894. {
  1895. dt = BLL.PagerBLL.GetListPager(
  1896. "T_Wo_WorkOrder",
  1897. "F_ID",
  1898. "*",
  1899. sql,
  1900. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  1901. limit,
  1902. page,
  1903. true,
  1904. out recordCount);
  1905. }
  1906. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  1907. if (modlelist.Count > 0)
  1908. {
  1909. List<Prescription> input = modelPrescription(modlelist);
  1910. var obj = new
  1911. {
  1912. state = "success",
  1913. message = "成功",
  1914. rows = input,
  1915. total = recordCount
  1916. };
  1917. return Content(obj.ToJson()); ;
  1918. }
  1919. else
  1920. {
  1921. return Success("暂无工单"); ;
  1922. }
  1923. }
  1924. /// <summary>
  1925. /// 导出化工产品市场投诉汇总表
  1926. /// </summary>
  1927. /// <param name="ids"></param>
  1928. /// <returns></returns>
  1929. public ActionResult ExptChemicalList(string stime, string endtime, string salesBase, string channel)
  1930. {
  1931. string sql = $" F_IsDelete=0";
  1932. DataTable dt = new DataTable();
  1933. #region 筛选条件
  1934. sql += $" and F_Type=" + 2;
  1935. if (stime != null && stime.Trim() != "")
  1936. {
  1937. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  1938. }
  1939. if (endtime != null && endtime.Trim() != "")
  1940. {
  1941. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  1942. }
  1943. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  1944. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  1945. if (!string.IsNullOrWhiteSpace(channel))
  1946. {
  1947. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  1948. }
  1949. sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化工产品质量问题反馈','化工服务质量问题反馈'") + "') "; ;
  1950. // sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  1951. sql += " order by F_CreateOn desc";
  1952. var depts = new BLL.T_Wo_WorkOrder().GetModelList(sql);
  1953. #endregion
  1954. dt.Columns.Add("化工产品名称");
  1955. dt.Columns.Add("客户单位");
  1956. dt.Columns.Add("生产日期");
  1957. dt.Columns.Add("反馈日期");
  1958. dt.Columns.Add("喷码");
  1959. dt.Columns.Add("问题分类");
  1960. dt.Columns.Add("问题描述");
  1961. dt.Columns.Add("处理方法");
  1962. dt.Columns.Add("责任部门");
  1963. dt.Columns.Add("销售基地");
  1964. dt.Columns.Add("业务员");
  1965. foreach (var it in depts)
  1966. {
  1967. DataRow drNew = dt.NewRow();
  1968. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  1969. if (!string.IsNullOrEmpty(it.F_CustomerID))//验证客户编码为10位纯数字
  1970. {
  1971. cuModel = cusbll.GetModel(it.F_CustomerID);//通过客户编号获取客户资料
  1972. }
  1973. else
  1974. {
  1975. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + it.F_CusPhone.Trim() + "'").FirstOrDefault();
  1976. }
  1977. if (cuModel != null)
  1978. {
  1979. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  1980. drNew["业务员"] = cuModel.F_Salesman;//业务员
  1981. }
  1982. drNew["化工产品名称"] = it.F_TS_Category;//产品
  1983. drNew["客户单位"] = it.F_CompanyName;//客户单位
  1984. if (!string.IsNullOrEmpty(it.F_BatchNumber))
  1985. {
  1986. var prono = it.F_BatchNumber.Substring(0, 6);
  1987. try
  1988. {
  1989. var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
  1990. // var protime = Convert.ToDateTime(pronos);
  1991. drNew["生产日期"] = pronos;
  1992. }
  1993. catch
  1994. {
  1995. drNew["生产日期"] = "";
  1996. }
  1997. }
  1998. drNew["反馈日期"] = it.F_CreateOn.ToString(); ;
  1999. drNew["喷码"] = it.F_BatchNumber;
  2000. Model.T_Wo_QuestionManage Manage = null;
  2001. try
  2002. {
  2003. int b = int.Parse(it.F_QuestionType.Trim());
  2004. Manage = quesBLL.GetModel(b);
  2005. if (Manage!=null )
  2006. {
  2007. drNew["问题分类"] = Manage.F_QuestionName ;
  2008. }
  2009. }
  2010. catch (Exception)
  2011. {
  2012. drNew["问题分类"] = it.F_QuestionType;
  2013. }
  2014. drNew["问题描述"] = it.F_Description;
  2015. drNew["处理方法"] = it.F_DealType;
  2016. drNew["责任部门"] = it.F_ZL_CResponsibleUnits;
  2017. drNew["销售基地"] = it.F_SalesBase;
  2018. dt.Rows.Add(drNew);
  2019. }
  2020. NPOIHelper npoi = new NPOIHelper();
  2021. if (npoi.ExportToExcel("化工产品市场投诉汇总表", dt) == "")
  2022. {
  2023. return Success("导出成功");
  2024. }
  2025. else
  2026. {
  2027. return Error("导出失败");
  2028. }
  2029. }
  2030. /// <summary>
  2031. /// 化工产品市场投诉汇总表
  2032. /// </summary>
  2033. /// <returns></returns>
  2034. public ActionResult GetChemicalList(string stime, string endtime, string salesBase, string channel, int page = 1, int limit = 10)
  2035. {
  2036. string sql = $" and F_IsDelete=0";
  2037. DataTable dt = new DataTable();
  2038. #region 筛选条件
  2039. sql += $" and F_Type=" + 2;
  2040. if (stime != null && stime.Trim() != "")
  2041. {
  2042. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  2043. }
  2044. if (endtime != null && endtime.Trim() != "")
  2045. {
  2046. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  2047. }
  2048. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  2049. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  2050. if (!string.IsNullOrWhiteSpace(channel))
  2051. {
  2052. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  2053. }
  2054. sql += $" and T_Wo_WorkOrder.F_QuestionType in ( '" + GetComplaint("'化工产品质量问题反馈','化工服务质量问题反馈'") + "') "; ;
  2055. //sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  2056. #endregion
  2057. int recordCount = 0;
  2058. if (!string.IsNullOrWhiteSpace(sql))
  2059. {
  2060. dt = BLL.PagerBLL.GetListPager(
  2061. "T_Wo_WorkOrder",
  2062. "F_ID",
  2063. "*",
  2064. sql,
  2065. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  2066. limit,
  2067. page,
  2068. true,
  2069. out recordCount);
  2070. }
  2071. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  2072. if (modlelist.Count > 0)
  2073. {
  2074. List<Product> input = modelProduct(modlelist);
  2075. var obj = new
  2076. {
  2077. state = "success",
  2078. message = "成功",
  2079. rows = input,
  2080. total = recordCount
  2081. };
  2082. return Content(obj.ToJson()); ;
  2083. }
  2084. else
  2085. {
  2086. return Success("暂无工单"); ;
  2087. }
  2088. }
  2089. public class Feedback
  2090. {
  2091. public string name;
  2092. public int daynumber;
  2093. public int mounthnumber;
  2094. public int Totalnumber;
  2095. public string Proportion;
  2096. }
  2097. public class Comling
  2098. {
  2099. public string name;
  2100. public int typeid;
  2101. public int number;//数量
  2102. public List<Complainthand> Complainthand;
  2103. /// <summary>
  2104. /// 效率提升率
  2105. /// </summary>
  2106. public string efficiency = "0%";//
  2107. public List<worker> worker;
  2108. }
  2109. public class Complainthandling
  2110. {
  2111. public string name;
  2112. public int typeid;
  2113. public int number;//数量
  2114. public List<Complainthand> Complainthand;
  2115. /// <summary>
  2116. /// 用时最长
  2117. /// </summary>
  2118. public string ongesttime="0h";//
  2119. /// <summary>
  2120. /// 用时最短
  2121. /// </summary>
  2122. public string minimumtime = "0h";//
  2123. /// <summary>
  2124. /// 平均用时
  2125. /// </summary>
  2126. public string averageTime = "0h";//
  2127. /// <summary>
  2128. /// 中位数
  2129. /// </summary>
  2130. public string median = "0h";//
  2131. /// <summary>
  2132. /// 超期数量
  2133. /// </summary>
  2134. public string Overdue="0";//
  2135. /// <summary>
  2136. /// 超期数量
  2137. /// </summary>
  2138. public string EndOverdue = "0";//
  2139. /// <summary>
  2140. /// 效率提升率
  2141. /// </summary>
  2142. public string efficiency = "0%";//
  2143. public List<worker> worker;
  2144. }
  2145. public class Complainthand
  2146. {
  2147. public string name;
  2148. public string total="0";
  2149. }
  2150. public class Channel
  2151. {
  2152. public string channel;//渠道
  2153. public int Telephone;//电话
  2154. public int WeChat;//微信
  2155. public int Immediate;//即时办结
  2156. public int Transfer;//即时转接
  2157. public int Verysatisfied;//非常满意
  2158. public int Satisfaction;//满意度
  2159. public int Commonly;//一般
  2160. public int Unsatisfactory;//不满意
  2161. public int Total;
  2162. }
  2163. public class BigDate
  2164. {
  2165. public List<Template> salesBase;//反馈类型
  2166. public List<Template> product;//产品
  2167. public List<Template> channel;//渠道
  2168. public List<Template> state;//工单状态
  2169. public List<Template> satisfaction;//满意度
  2170. public List<Template> overdue;//超期
  2171. }
  2172. /// <summary>
  2173. /// 反馈类型
  2174. /// </summary>
  2175. public class Template
  2176. {
  2177. public string name;//名称
  2178. public int number;// 数量
  2179. public int Lastyearnumber;//去年同比
  2180. public int Lastmonthnumber;//上月同比
  2181. public int Lastyear;//去年同比
  2182. public int Lastmonth;//上月同比
  2183. }
  2184. public string GetCustomerCode(int area=0,int branch=0,string channel="")
  2185. {
  2186. string str = "";
  2187. string sql = "";
  2188. if (area >0)
  2189. {
  2190. sql += " and F_AreaID =" + area;
  2191. }
  2192. if (branch>0)
  2193. {
  2194. sql += " and F_BranchID =" + branch;
  2195. }
  2196. if (channel!="")
  2197. {
  2198. sql += " and F_Channel= '" + channel + "'";
  2199. }
  2200. if (sql != "")
  2201. {
  2202. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + sql;
  2203. }
  2204. return str;
  2205. }
  2206. public string GetCustomerrel(int area = 0, int branch = 0, string channel = "")
  2207. {
  2208. string str = "";
  2209. string sql = "";
  2210. if (area > 0)
  2211. {
  2212. sql += " and F_AreaID =" + area;
  2213. }
  2214. if (branch > 0)
  2215. {
  2216. sql += " and F_BranchID =" + branch;
  2217. }
  2218. if (channel != "")
  2219. {
  2220. sql += " and F_Channel= '" + channel + "'";
  2221. }
  2222. str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" +sql;
  2223. return str;
  2224. }
  2225. /// <summary>
  2226. /// 大数据一览表
  2227. /// </summary>
  2228. /// <returns></returns>
  2229. public ActionResult GetBigdataList(string stime, string endtime,string salesBase ,string product,string channel, int area=0,int branch=0, int type = 0)
  2230. {
  2231. #region
  2232. if (!Refresh())
  2233. {
  2234. return Error("查询失败");
  2235. }
  2236. string sql = $" F_IsDelete=0";
  2237. DataTable dt = new DataTable();
  2238. #region 筛选条件
  2239. if (string.IsNullOrEmpty(stime))
  2240. {
  2241. stime = DateTime.Now.Date.ToString("yyyy-MM-01");
  2242. }
  2243. if (string.IsNullOrEmpty(endtime))
  2244. {
  2245. endtime = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2246. }
  2247. int Months = 1;
  2248. if (!string.IsNullOrEmpty(stime)&& !string.IsNullOrEmpty(endtime))
  2249. {
  2250. Months = DateTime.Parse(endtime).Month - DateTime.Parse(stime).Month;
  2251. if (DateTime.Parse(endtime).Day > DateTime.Parse(stime).Day )
  2252. {
  2253. Months = Months + 1;
  2254. }
  2255. }
  2256. string smouth= Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).AddMonths(-Months).ToLongDateString()).ToString("yyyy-MM-dd");
  2257. string endmouth = Convert.ToDateTime(DateTime.Parse(endtime).AddDays(1 - DateTime.Parse(endtime).Day).AddMonths(-Months).AddMonths(1).AddDays(-1).ToLongDateString()).ToString("yyyy-MM-dd");
  2258. string syear = Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).Date.AddYears (-1).ToLongDateString()).ToString("yyyy-MM-dd");
  2259. 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");
  2260. #endregion
  2261. string time = $" and datediff(day,F_CreateOn,'{stime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ";
  2262. string lastmouth = $" and datediff(day,F_CreateOn,'{smouth}')<=0 and datediff(day,F_CreateOn,'{endmouth}')>=0 ";
  2263. string lastyear= $" and datediff(day,F_CreateOn,'{syear}')<=0 and datediff(day,F_CreateOn,'{endyear}')>=0 ";
  2264. BigDate model = new BigDate();
  2265. model.salesBase = new List<Template>();
  2266. if (type >0)
  2267. {
  2268. sql += $"and F_Type = " + type;
  2269. }
  2270. if (!string.IsNullOrEmpty(salesBase))
  2271. {
  2272. sql += $" and F_SalesBase='" + salesBase.Trim() + "'";
  2273. }
  2274. if (area > 0 || branch > 0 || !string.IsNullOrEmpty(channel))
  2275. {
  2276. sql += " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, channel) + ") ";
  2277. }
  2278. if (!string.IsNullOrEmpty(product))
  2279. {
  2280. sql += $" and F_TS_Category='" + product.Trim() + "'";
  2281. }
  2282. #region 反馈类型
  2283. for (int i=0;i <5;i++)
  2284. {
  2285. string sqltype = "";
  2286. Template template = new Template() ;
  2287. switch (i)
  2288. {
  2289. case 0:
  2290. template.name = "合计";
  2291. break;
  2292. case 1:
  2293. template.name = "新乡";
  2294. break;
  2295. case 2:
  2296. template.name = "新疆";
  2297. break;
  2298. case 3:
  2299. template.name = "九江";
  2300. break;
  2301. case 4:
  2302. template.name = "东北";
  2303. break;
  2304. }
  2305. if (i > 0)
  2306. {
  2307. sqltype = $"and F_SalesBase = '" + template.name + "'";
  2308. }
  2309. else
  2310. {
  2311. if (string.IsNullOrEmpty(salesBase))
  2312. {
  2313. sqltype = $"and F_SalesBase in('新乡','新疆', '九江','东北')";
  2314. }
  2315. }
  2316. model.salesBase.Add(ReturenTemplate(template, sql+ sqltype, time, lastmouth, lastyear));
  2317. }
  2318. #endregion
  2319. #region 产品
  2320. var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
  2321. model.product = new List<Template>();
  2322. List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
  2323. if (dicv != null)
  2324. {
  2325. dicval = dicvalueBll.DataTableToList(dicv);
  2326. }
  2327. if (dicval != null && dicval.Count > 0)
  2328. {
  2329. string msf = "";
  2330. foreach (var it in dicval)
  2331. {
  2332. if (msf == "")
  2333. msf += " '" + it.F_Name + "'";
  2334. else
  2335. msf += " ,'" + it.F_Name + "'";
  2336. }
  2337. Template template = new Template();
  2338. template.name = "合计";
  2339. if (string.IsNullOrEmpty(product))
  2340. {
  2341. model.product.Add(ReturenTemplate(template, sql + $"and F_TS_Category in (" + msf + ")", time, lastmouth, lastyear));
  2342. }
  2343. else
  2344. {
  2345. model.product.Add(ReturenTemplate(template, sql , time, lastmouth, lastyear));
  2346. }
  2347. foreach (var it in dicval)
  2348. {
  2349. Template templates = new Template();
  2350. string mag = "";
  2351. mag = $"and F_TS_Category = '" + it.F_Name+"'";
  2352. templates.name = it.F_Name;
  2353. model.product.Add(ReturenTemplate(templates, sql + mag, time, lastmouth, lastyear));
  2354. }
  2355. }
  2356. #endregion
  2357. #region 渠道类型
  2358. var QDLX = dicvalueBll.GetList(" F_DictionaryFlag='" + "QDLX" + "' and F_State=1 ").Tables[0];
  2359. model.channel = new List<Template>();
  2360. List<Model.T_Sys_DictionaryValue> QDLXl = new List<Model.T_Sys_DictionaryValue>();
  2361. if (QDLX != null)
  2362. {
  2363. QDLXl = dicvalueBll.DataTableToList(QDLX);
  2364. }
  2365. if (QDLXl != null && QDLXl.Count > 0)
  2366. {
  2367. Template templates = new Template();
  2368. templates.name = "合计";
  2369. model.channel.Add(ReturenTemplate(templates, sql , time, lastmouth, lastyear));
  2370. foreach (var it in QDLXl)
  2371. {
  2372. Template template = new Template();
  2373. string str = "";
  2374. str = " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, it.F_Name) + ") ";
  2375. template.name = it.F_Name;
  2376. model.channel.Add(ReturenTemplate(template,sql + str, time, lastmouth, lastyear));
  2377. }
  2378. }
  2379. #endregion
  2380. #region 工单类型
  2381. model.state = new List<Template>();
  2382. for (int i = 0; i < 5; i++)
  2383. {
  2384. string sqlchannel = "";
  2385. Template template = new Template();
  2386. switch (i)
  2387. {
  2388. case 0:
  2389. template.name = "合计";
  2390. break;
  2391. case 1:
  2392. template.name = "待处理";
  2393. sqlchannel = " and F_State in (0, 1, 2, 3, 4, 5, 6, 7, 12, 14, 16)";
  2394. break;
  2395. case 2:
  2396. template.name = "已处理";
  2397. sqlchannel = " and F_State in (10,11)";
  2398. break;
  2399. case 3:
  2400. template.name = "待回访";
  2401. sqlchannel = " and F_State in (10) and F_IsVisit=1";
  2402. break;
  2403. case 4:
  2404. template.name = "已回访";
  2405. sqlchannel = " and F_State in (11) and F_IsVisit=1 and F_DealType!='当即办理' and F_VisitBy !=''";
  2406. break;
  2407. }
  2408. model.state.Add(ReturenTemplate(template,sql + sqlchannel, time, lastmouth, lastyear));
  2409. }
  2410. #endregion
  2411. #region 满意度
  2412. model.satisfaction = new List<Template>();
  2413. for (int i = 0; i <5; i++)
  2414. {
  2415. string sqlsatisfaction = "";
  2416. sqlsatisfaction += " and F_State in (11)";
  2417. sqlsatisfaction += " and F_IsVisit =1";
  2418. Template template = new Template();
  2419. switch (i)
  2420. {
  2421. case 0:
  2422. template.name += "合计";
  2423. sqlsatisfaction += " and F_VisitResult in ('非常满意','满意','一般','不满意')";
  2424. break;
  2425. case 1:
  2426. template.name = "非常满意";
  2427. sqlsatisfaction += " and F_VisitResult ='非常满意'";
  2428. break;
  2429. case 2:
  2430. template.name = "满意";
  2431. sqlsatisfaction += " and F_VisitResult ='满意'";
  2432. break;
  2433. case 3:
  2434. template.name = "一般";
  2435. sqlsatisfaction += " and F_VisitResult ='一般'";
  2436. break;
  2437. case 4:
  2438. template.name = "不满意";
  2439. sqlsatisfaction += " and F_VisitResult ='不满意'";
  2440. break;
  2441. }
  2442. model.satisfaction .Add(ReturenTemplate(template,sql + sqlsatisfaction, time, lastmouth, lastyear));
  2443. #endregion
  2444. }
  2445. #endregion
  2446. #region 超期工单
  2447. model.overdue = new List<Template>();
  2448. string sqloverdue = "";
  2449. sqloverdue += "";
  2450. var modlelist = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1 " + time);
  2451. Template templatee = new Template();
  2452. templatee.name = "合计";
  2453. templatee.number =0;
  2454. model.overdue.Add(templatee);
  2455. if (modlelist.Count > 0)
  2456. {
  2457. foreach (var it in modlelist)
  2458. {
  2459. var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + "and F_WoState=1" + " order by F_ID desc");
  2460. if (itemList.Count > 0)
  2461. {
  2462. if (itemList[0].F_NextDept > 0)
  2463. {
  2464. var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
  2465. if (model.overdue.Count > 0)
  2466. {
  2467. int overdue = 0;
  2468. foreach (var im in model.overdue)
  2469. {
  2470. if (im.name == deptmodel.F_DeptName)
  2471. {
  2472. im.number += 1;
  2473. overdue = 1;
  2474. }
  2475. if (im .name =="合计")
  2476. {
  2477. im.number += 1;
  2478. }
  2479. }
  2480. if (overdue == 0)
  2481. {
  2482. Template templates = new Template();
  2483. templates.name = deptmodel.F_DeptName;
  2484. templates.number = 1;
  2485. model.overdue.Add(templates);
  2486. }
  2487. }
  2488. else
  2489. {
  2490. Template templates = new Template();
  2491. templates.name = deptmodel.F_DeptName;
  2492. templates.number = 1;
  2493. model.overdue.Add(templates);
  2494. }
  2495. }
  2496. else
  2497. {
  2498. if (itemList[0].F_WoState ==10)
  2499. {
  2500. var deptmodel = departmentBLL.GetModel(2);
  2501. Template templates = new Template();
  2502. templates.name = deptmodel.F_DeptName;
  2503. templates.number = 1;
  2504. model.overdue.Add(templates);
  2505. }
  2506. }
  2507. }
  2508. }
  2509. }
  2510. if (model.overdue.Count > 0)
  2511. {
  2512. foreach (var it in model.overdue)
  2513. {
  2514. if (it .name =="合计")
  2515. {
  2516. var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth).Count ;
  2517. var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear).Count ;
  2518. it.Lastmonthnumber = lastmouthmodlel;
  2519. it.Lastyearnumber = lastyearmodlel;
  2520. it.Lastmonth = it.number - lastmouthmodlel;
  2521. it.Lastyear = it.number - lastyearmodlel;
  2522. }
  2523. else
  2524. {
  2525. var deptmodel = departmentBLL.GetModel(it.name);
  2526. var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth);
  2527. int lastmouthlist = 0;
  2528. int lastyearlist = 0;
  2529. if (lastmouthmodlel.Count > 0)
  2530. {
  2531. foreach (var im in lastmouthmodlel)
  2532. {
  2533. var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
  2534. if (itemList.Count > 0)
  2535. {
  2536. lastmouthlist++;
  2537. }
  2538. }
  2539. }
  2540. var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear);
  2541. if (lastyearmodlel.Count > 0)
  2542. {
  2543. foreach (var im in lastyearmodlel)
  2544. {
  2545. var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
  2546. if (itemList.Count > 0)
  2547. {
  2548. lastyearlist++;
  2549. }
  2550. }
  2551. }
  2552. it.Lastmonthnumber = lastmouthlist;
  2553. it.Lastyearnumber = lastyearlist;
  2554. it.Lastmonth= it.number - lastmouthlist;
  2555. it.Lastyear= it.number - lastyearlist;
  2556. }
  2557. }
  2558. }
  2559. if (model.overdue.Count > 0)
  2560. {
  2561. for (int j = 0; j < model.overdue.Count - 1; j++)
  2562. {
  2563. for (int z = 0; z < model.overdue.Count - 1 - j; z++)
  2564. {
  2565. if (model.overdue[z].number < model.overdue[z + 1].number)
  2566. {
  2567. var temp = model.overdue[z + 1];
  2568. model.overdue[z + 1] = model.overdue[z];
  2569. model.overdue[z] = temp;
  2570. }
  2571. }
  2572. }
  2573. }
  2574. #endregion
  2575. var obj = new
  2576. {
  2577. state = "success",
  2578. message = "成功",
  2579. rows = model,
  2580. total = 6
  2581. };
  2582. return Content(obj.ToJson()); ;
  2583. }
  2584. private bool Refresh()
  2585. {
  2586. int type = 0;
  2587. var modlelist = workOrder.GetModelList(" F_IsDelete=0 " + "and F_IsOver=0" + " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
  2588. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + "," + (int)EnumWorkOrderState.finish + ")");
  2589. if (modlelist.Count > 0)
  2590. {
  2591. foreach (var it in modlelist)
  2592. {
  2593. if (TimeforOver(it.F_ID))
  2594. {
  2595. type = 0;
  2596. }
  2597. else
  2598. {
  2599. type = 1;
  2600. }
  2601. if (type != it.F_IsOver)
  2602. {
  2603. it.F_IsOver = type;
  2604. bool n = workOrder.Update(it);
  2605. if (!n)
  2606. {
  2607. return false;
  2608. }
  2609. }
  2610. }
  2611. }
  2612. return true;
  2613. }
  2614. /// <summary>
  2615. /// 是否超时
  2616. /// </summary>
  2617. /// <param name="id"></param>
  2618. /// <returns></returns>
  2619. private bool TimeforOver(int id)
  2620. {
  2621. var itemlasts = itembll.GetModelList(" F_WoID=" + id + " order by F_ID desc");
  2622. string time1 = "", time2 = ""; int x = 0, y = 0;
  2623. float time = 0;
  2624. if (itemlasts.Count > 0)
  2625. {
  2626. for (int z = 0; z < itemlasts.Count; z++)
  2627. {
  2628. if (itemlasts[z].F_WoState >= 1)
  2629. {
  2630. if (itemlasts[z].F_WoState == 1)
  2631. {
  2632. x = z;
  2633. time1 = itemlasts[z].F_CreateTime.ToString();
  2634. time = float.Parse(itemlasts[z].F_LimitTime);
  2635. break; ;
  2636. }
  2637. }
  2638. }
  2639. for (int i = 0; i < itemlasts.Count; i++)
  2640. {
  2641. if (itemlasts[i].F_WoState >= 1)
  2642. {
  2643. if (itemlasts[i].F_WoState == 11)
  2644. {
  2645. y = i;
  2646. time2 = itemlasts[i].F_CreateTime.ToString();
  2647. }
  2648. }
  2649. }
  2650. if (time2 != "")
  2651. {
  2652. if (time1 != "")
  2653. {
  2654. if (x > y)
  2655. {
  2656. System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
  2657. if ((float)a.TotalHours > time)
  2658. {
  2659. return false;
  2660. }
  2661. }
  2662. else
  2663. {
  2664. System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
  2665. if ((float)a.TotalHours > time)
  2666. {
  2667. return false;
  2668. }
  2669. }
  2670. }
  2671. else
  2672. {
  2673. return true;
  2674. }
  2675. }
  2676. else if (time1 != "")
  2677. {
  2678. System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
  2679. if ((float)a.TotalHours > time)
  2680. {
  2681. return false;
  2682. }
  2683. }
  2684. else
  2685. {
  2686. return true;
  2687. }
  2688. }
  2689. else
  2690. {
  2691. return true;
  2692. }
  2693. return true;
  2694. }
  2695. public Template ReturenTemplate(Template template,string sql,string time,string lastmouth,string lastyear )
  2696. {
  2697. template.number = new BLL.T_Wo_WorkOrder().GetModelList(sql + time).Count;//
  2698. int mounthnumber = 0, yearnumber = 0;
  2699. mounthnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastmouth).Count;//
  2700. yearnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastyear).Count;//
  2701. template.Lastmonthnumber = mounthnumber;
  2702. template.Lastyearnumber = yearnumber;
  2703. template.Lastyear = template.number - yearnumber;
  2704. template.Lastmonth = template.number - mounthnumber;
  2705. return template;
  2706. }
  2707. /// <summary>
  2708. /// 市场反馈一览表
  2709. /// </summary>
  2710. /// <returns></returns>
  2711. public ActionResult GetFeedbacklList(string stime, string endtime)
  2712. {
  2713. string sql = $" F_IsDelete=0";
  2714. DataTable dt = new DataTable();
  2715. #region 筛选条件
  2716. List<Feedback> modelList = new List<Feedback>(5);
  2717. string smonthtime = "";
  2718. if (!string .IsNullOrEmpty (stime))
  2719. {
  2720. smonthtime = stime .Trim() + " 00:00:01 "; ;
  2721. }
  2722. else
  2723. {
  2724. smonthtime = DateTime.Now.Date.ToString("yyyy-MM-01 00:00:00");
  2725. }
  2726. if (string .IsNullOrEmpty (endtime))
  2727. {
  2728. endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2729. }
  2730. else
  2731. {
  2732. endtime = endtime + " 23:59:59 "; ;
  2733. }
  2734. string sdaytime = DateTime.Now.Date.ToString("yyyy-MM-dd 00:00:00");
  2735. for (int i = 1; i <= 5; i++)
  2736. {
  2737. Feedback model = new Feedback();
  2738. switch (i)
  2739. {
  2740. case 1:
  2741. model.name = "咨询";
  2742. break;
  2743. case 2:
  2744. model.name = "投诉";
  2745. break;
  2746. case 3:
  2747. model.name = "抽检";
  2748. break;
  2749. case 4:
  2750. model.name = "建议";
  2751. break;
  2752. case 5:
  2753. model.name = "合计";
  2754. break;
  2755. }
  2756. float a= workOrder.GetModelList(sql ).Count;
  2757. if (i <5)
  2758. {
  2759. model .daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i ).Count;
  2760. model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i).Count;
  2761. model.Totalnumber = workOrder.GetModelList(sql + "and F_Type=" + i).Count;
  2762. model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a*100);
  2763. }
  2764. else
  2765. {
  2766. model.daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " ).Count;
  2767. model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ").Count;
  2768. model.Totalnumber = workOrder.GetModelList(sql).Count;
  2769. model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a * 100);
  2770. }
  2771. modelList.Add(model);
  2772. }
  2773. #endregion
  2774. var obj = new
  2775. {
  2776. state = "success",
  2777. message = "成功",
  2778. rows = modelList,
  2779. total = 4
  2780. };
  2781. return Content(obj.ToJson()); ;
  2782. }
  2783. /// <summary>
  2784. /// 渠道数量对比表
  2785. /// </summary>
  2786. /// <param name="stime"></param>
  2787. /// <param name="endtime"></param>
  2788. /// <returns></returns>
  2789. public ActionResult GetChanelList(string stime, string endtime)
  2790. {
  2791. string sql = $" and F_IsDelete=0";
  2792. DataTable dt = new DataTable();
  2793. #region 筛选条件
  2794. if (stime != null && stime.Trim() != "")
  2795. {
  2796. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  2797. }
  2798. if (endtime != null && endtime.Trim() != "")
  2799. {
  2800. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  2801. }
  2802. #endregion
  2803. List<string> channelname = new List<string>();
  2804. channelname.Add("总经销");
  2805. channelname.Add("二级商");
  2806. channelname.Add("种田大户");
  2807. channelname.Add("公司员工");
  2808. channelname.Add("农户");
  2809. channelname.Add("化工客户");
  2810. channelname.Add("其他");
  2811. int Distribution = 0, Quotient=0, Bigfarmer = 0, Companystaf = 0, Peasant = 0, Customers = 0, Other = 0;
  2812. for (int i=0;i < channelname.Count;i++)
  2813. {
  2814. string msg = "'" +channelname[i] + "'";
  2815. var modellist = woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(msg) + ")" + sql + "and F_Type in (2,3)");
  2816. var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(msg) + ")" + sql + "and F_Type in (1,4)");
  2817. switch (i )
  2818. {
  2819. case 0:
  2820. Distribution = modellist.Count + modellis.Count;//总经销
  2821. break;
  2822. case 1:
  2823. Quotient = modellist.Count + modellis.Count;//二级商
  2824. break;
  2825. case 2:
  2826. Bigfarmer = modellist.Count + modellis.Count;//种田大户
  2827. break;
  2828. case 3:
  2829. Companystaf = modellist.Count + modellis.Count;//公司员工
  2830. break;
  2831. case 4:
  2832. Peasant = modellist.Count + modellis.Count;//农户
  2833. break;
  2834. case 5:
  2835. Customers = modellist.Count + modellis.Count;//化工客户
  2836. break;
  2837. case 6:
  2838. Other = modellist.Count + modellis.Count;//其他
  2839. break;
  2840. }
  2841. }
  2842. var obj = new
  2843. {
  2844. state = "success",
  2845. message = "成功",
  2846. rows=new
  2847. {
  2848. Distribution,
  2849. Quotient,
  2850. Bigfarmer,
  2851. Companystaf,
  2852. Peasant,
  2853. Customers,
  2854. Other,
  2855. }
  2856. ,
  2857. total =6
  2858. };
  2859. return Content(obj.ToJson()); ;
  2860. }
  2861. BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
  2862. public class Brand
  2863. {
  2864. public string name;
  2865. public int number;
  2866. }
  2867. /// <summary>
  2868. /// 产品品牌对照表
  2869. /// </summary>
  2870. /// <param name="stime"></param>
  2871. /// <param name="endtime"></param>
  2872. /// <returns></returns>
  2873. public ActionResult GetbrandList(string stime, string endtime)
  2874. {
  2875. string sql = $" and F_IsDelete=0";
  2876. DataTable dt = new DataTable();
  2877. #region 筛选条件
  2878. if (stime != null && stime.Trim() != "")
  2879. {
  2880. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  2881. }
  2882. if (endtime != null && endtime.Trim() != "")
  2883. {
  2884. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  2885. }
  2886. #endregion
  2887. var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
  2888. List<Brand> list = new List<Brand>();
  2889. List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
  2890. if (dicv !=null )
  2891. {
  2892. dicval = dicvalueBll.DataTableToList(dicv);
  2893. }
  2894. if (dicval !=null&& dicval.Count >0)
  2895. {
  2896. foreach (var it in dicval)
  2897. {
  2898. var modellist = woBLL.GetModelList(" F_TS_Category in ('" + it.F_Name + "')" + sql );
  2899. Brand brand = new Brand();
  2900. brand.name = it.F_Name;
  2901. brand.number = modellist.Count;
  2902. list.Add(brand);
  2903. }
  2904. }
  2905. var obj = new
  2906. {
  2907. state = "success",
  2908. message = "成功",
  2909. rows = list
  2910. ,
  2911. total = list.Count ,
  2912. };
  2913. return Content(obj.ToJson()); ;
  2914. }
  2915. public class QuestionType
  2916. {
  2917. public string F_QuestionType;
  2918. public int number;
  2919. }
  2920. public class worker
  2921. {
  2922. public string F_WorkOrderCode;//工单编号
  2923. public string F_State;//工单状态
  2924. public string overtime;//超期时间
  2925. public double time;
  2926. public string F_Description;//问题描述
  2927. public string F_Responsibility;//责任科室
  2928. public string F_SalesBase;//销售基地
  2929. public string F_Type;//反馈类型
  2930. }
  2931. /// <summary>
  2932. ///月份投诉处理周期表
  2933. /// </summary>
  2934. /// <returns></returns>
  2935. public ActionResult GetComplainthandlList(string salesBase,string stime ="", string endtime="", string questionName = "" ,int isEnd=0)
  2936. {
  2937. string sql = $" F_IsDelete=0";
  2938. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  2939. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  2940. if (isEnd ==1)
  2941. sql += $" and F_State !=11";
  2942. else if (isEnd == 2)
  2943. sql += $" and F_State =11 ";
  2944. string Queststr = "";
  2945. bool k = true;
  2946. if (questionName != "" && questionName != "0")
  2947. {
  2948. try
  2949. {
  2950. int a = int.Parse(questionName);
  2951. }
  2952. catch
  2953. {
  2954. k = false;
  2955. }
  2956. }
  2957. if (questionName!=""&& questionName!="0")
  2958. {
  2959. if (k)
  2960. {
  2961. Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 and F_Label in(3) and F_Id='" + questionName + "'";
  2962. }
  2963. else
  2964. {
  2965. Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 and F_Label in(3) and F_QuestionName='" + questionName + "'";
  2966. }
  2967. }
  2968. else
  2969. {
  2970. Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 AND F_Label in(3)";
  2971. }
  2972. int year = DateTime.Now.Year;//当前年
  2973. int mouth = DateTime.Now.Month;//当前月
  2974. if (stime != "")
  2975. {
  2976. year = DateTime.Parse(stime).Year;
  2977. mouth = DateTime.Parse(stime).Month;
  2978. }
  2979. int beforeYear = 0;
  2980. int beforeMouth = 0;
  2981. if (mouth <= 1)//如果当前月是一月,那么年份就要减1
  2982. {
  2983. beforeYear = year - 1;
  2984. beforeMouth = 12;//上个月
  2985. }
  2986. else
  2987. {
  2988. beforeYear = year;
  2989. beforeMouth = mouth - 1;//上个月
  2990. }
  2991. string beforeMouthOneDay = beforeYear + "年" + beforeMouth + "月" + 1 + "日";//上个月第一天
  2992. string beforeMouthLastDay = beforeYear + "年" + beforeMouth + "月" + DateTime.DaysInMonth(year, beforeMouth) + "日";//上个月最后一天
  2993. string time1 = DateTime.Parse(beforeMouthOneDay).ToString("yyyy-MM-dd");
  2994. string time2 = DateTime.Parse(beforeMouthLastDay).ToString("yyyy-MM-dd");
  2995. sql += "and F_Type=2";
  2996. string where= " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + time1.Trim() + " 00:00:01', 120) ";
  2997. where += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + time2.Trim() + " 00:00:01', 120) ";
  2998. var lastmodellist = workOrder.GetModelList(sql+ where);
  2999. if (stime != null && stime.Trim() != "")
  3000. {
  3001. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  3002. }
  3003. else
  3004. {
  3005. // stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
  3006. // sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  3007. }
  3008. if (endtime != null && endtime.Trim() != "")
  3009. {
  3010. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  3011. }
  3012. else
  3013. {
  3014. // endtime = DateTime.Now.ToString("yyyy-MM-dd");
  3015. // sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  3016. }
  3017. var modellist = workOrder.GetModelList(sql);
  3018. DataTable QuestionManage = DbHelperSQL.Query(Queststr).Tables[0];
  3019. List<Model.T_Wo_QuestionManage> categorylist = quesBLL.DataTableToList(QuestionManage);
  3020. List<Complainthandling> modeNamelList = new List<Complainthandling>(categorylist.Count);
  3021. string category = "";
  3022. foreach (var it in categorylist)
  3023. {
  3024. if (category != "")
  3025. category += ",'" + it.F_Id+"'";
  3026. else
  3027. category+= "'"+it.F_Id+"'";
  3028. }
  3029. var categorymodellist = workOrder.GetModelList(sql+ "and F_QuestionType in ("+ category+")");
  3030. #region
  3031. if (questionName == "" || questionName == "0")
  3032. {
  3033. if (categorymodellist != null)
  3034. {
  3035. List<float> timehource = new List<float>();
  3036. Complainthandling model = new Complainthandling();
  3037. model.name = "合计";
  3038. model.number = categorymodellist.Count;
  3039. int Overdue = 0;
  3040. int EndOverdue = 0;
  3041. int efficiency = 0;
  3042. model.worker = new List<worker>();
  3043. int lastnumber = 0;
  3044. foreach (var it in categorymodellist)
  3045. {
  3046. try
  3047. {
  3048. if (it.F_State == 10 || it.F_State == 11)
  3049. {
  3050. efficiency++;
  3051. // System.TimeSpan id = DateTime.Parse(it.F_DealTime.ToString()) - DateTime.Parse//(it.F_CreateOn.ToString());
  3052. // double t = id.TotalHours;
  3053. }
  3054. if (it.F_IsOver == 1&&it .F_Type !="3")
  3055. {
  3056. worker worker = new worker();
  3057. worker.F_WorkOrderCode = it.F_WorkOrderCode;
  3058. if (it.F_State == 1)
  3059. worker.F_State = "待接单";
  3060. else if (it.F_State == 2)
  3061. worker.F_State = "待处理";
  3062. else if (it.F_State == 3)
  3063. worker.F_State = "已退回";
  3064. else if (it.F_State == 4)
  3065. worker.F_State = "异常退回";
  3066. else if (it.F_State == 4)
  3067. worker.F_State = "异常退回";
  3068. else if (it.F_State == 11)
  3069. worker.F_State = "已回访";
  3070. else
  3071. worker.F_State = "已处理";
  3072. if (it.F_Type == "1")
  3073. {
  3074. worker.F_Type = "咨询";
  3075. }
  3076. else if (it.F_Type == "2")
  3077. {
  3078. worker.F_Type = "投诉";
  3079. }
  3080. else if (it.F_Type == "3")
  3081. {
  3082. worker.F_Type = "抽检";
  3083. }
  3084. else
  3085. {
  3086. worker.F_Type = "建议及其他";
  3087. }
  3088. worker.F_SalesBase = it.F_SalesBase;
  3089. worker.F_Description = it.F_Description;
  3090. string timeover = "", timeover2 = ""; int x = 0, y = 0;
  3091. var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + " order by F_ID desc");
  3092. if (itemList[0].F_NextDept > 0)
  3093. {
  3094. var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
  3095. if (deptmodel != null)
  3096. {
  3097. worker.F_Responsibility = deptmodel.F_DeptName;
  3098. }
  3099. }
  3100. else
  3101. {
  3102. if (itemList[0].F_WoState == 10)
  3103. {
  3104. var deptmodel = departmentBLL.GetModel(2);
  3105. if (deptmodel != null)
  3106. {
  3107. worker.F_Responsibility = deptmodel.F_DeptName;
  3108. }
  3109. }
  3110. }
  3111. int limit = it.F_limit ;
  3112. if (itemList != null)
  3113. {
  3114. for (int z = 0; z < itemList.Count; z++)
  3115. {
  3116. if (itemList[z].F_WoState >= 1)
  3117. {
  3118. if (itemList[z].F_WoState == 1)
  3119. {
  3120. x = z;
  3121. timeover = itemList[z].F_CreateTime.ToString();
  3122. // limit = int.Parse(itemList[z].F_LimitTime);
  3123. break ;
  3124. }
  3125. }
  3126. }
  3127. for (int z = 0; z < itemList.Count; z++)
  3128. {
  3129. if (itemList[z].F_WoState >= 1)
  3130. {
  3131. if (itemList[z].F_WoState == 11)
  3132. {
  3133. y = z;
  3134. timeover2 = itemList[z].F_CreateTime.ToString();
  3135. // limit = int.Parse(itemList[z].F_LimitTime);
  3136. }
  3137. }
  3138. if (timeover2 != "")
  3139. {
  3140. if (timeover != "")
  3141. {
  3142. if (x > y)
  3143. {
  3144. System.TimeSpan id = DateTime.Parse(timeover2) - DateTime.Parse(timeover);
  3145. double a = id.TotalHours;
  3146. worker.time = a - limit;
  3147. timehource.Add((float)worker.time);
  3148. if (worker.time > 24)
  3149. {
  3150. double t = worker.time / 24;
  3151. double v = worker.time % 24;
  3152. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3153. }
  3154. else
  3155. {
  3156. worker.overtime = string.Format("{0:f2}h", a - limit);
  3157. }
  3158. }
  3159. else
  3160. {
  3161. System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
  3162. double a = id.TotalHours;
  3163. worker.time = a - limit;
  3164. timehource.Add((float)worker.time);
  3165. if (worker.time > 24)
  3166. {
  3167. double t = worker.time / 24;
  3168. double v = worker.time % 24;
  3169. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3170. }
  3171. else
  3172. {
  3173. worker.overtime = string.Format("{0:f2}h", a - limit);
  3174. }
  3175. }
  3176. }
  3177. }
  3178. else if (timeover != "")
  3179. {
  3180. System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
  3181. double a = id.TotalHours;
  3182. worker.time = a - limit;
  3183. timehource.Add((float)worker.time);
  3184. if (worker.time > 24)
  3185. {
  3186. double t = worker.time / 24;
  3187. double v = worker.time % 24;
  3188. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3189. }
  3190. else
  3191. {
  3192. worker.overtime = string.Format("{0:f2}h", a - limit);
  3193. }
  3194. }
  3195. }
  3196. }
  3197. if (it.F_State != 11)
  3198. Overdue++;
  3199. else
  3200. EndOverdue++;
  3201. model.worker.Add(worker);
  3202. }
  3203. model.Overdue = Overdue + "";
  3204. model.EndOverdue = EndOverdue + "";
  3205. if (lastmodellist != null)
  3206. {
  3207. foreach (var iv in lastmodellist)
  3208. {
  3209. if (iv.F_State == 10 || iv.F_State == 11)
  3210. lastnumber++;
  3211. }
  3212. }
  3213. }
  3214. catch
  3215. {
  3216. }
  3217. }
  3218. if (lastnumber == 0)
  3219. {
  3220. model.efficiency = string.Format("{0:f0}% ", efficiency / 1 * 100);
  3221. }
  3222. else
  3223. {
  3224. int v = efficiency - lastnumber;
  3225. model.efficiency = string.Format("{0:f0}% ", v / lastnumber * 100);
  3226. }
  3227. if (timehource.Count > 0)
  3228. {
  3229. timehource.Sort((a, b) => b.CompareTo(a));
  3230. model.ongesttime = string.Format("{0:f2}", timehource[0]/24);
  3231. model.minimumtime = string.Format("{0:f2}", timehource[timehource.Count - 1]/24);
  3232. int n = timehource.Count / 2;
  3233. model.median = string.Format("{0:f2}", timehource[n]/24);
  3234. float y = 0;
  3235. foreach (var iu in timehource)
  3236. {
  3237. y += iu;
  3238. }
  3239. model.averageTime = string.Format("{0:f2}", y / timehource.Count/24);
  3240. }
  3241. else
  3242. {
  3243. model.ongesttime = "0";
  3244. model.minimumtime = "0";
  3245. model.median = "0";
  3246. model.averageTime = "0";
  3247. }
  3248. model.worker.Sort((a, b) => b.time.CompareTo(a.time));
  3249. if (questionName != "")
  3250. modeNamelList.Add(model);
  3251. else if (model.number > 0)
  3252. {
  3253. modeNamelList.Add(model);
  3254. }
  3255. }
  3256. }
  3257. #endregion
  3258. //var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal+ "order by F_ID desc ");
  3259. if (questionName!="0")
  3260. {
  3261. if (modellist != null)
  3262. {
  3263. for (int i = 0; i < categorylist.Count; i++)
  3264. {
  3265. List<float> timehource = new List<float>();
  3266. Complainthandling model = new Complainthandling();
  3267. model.name = categorylist[i].F_QuestionName;
  3268. model.typeid = categorylist[i].F_Id;
  3269. model.number = 0;
  3270. int Overdue = 0;
  3271. int EndOverdue = 0;
  3272. int efficiency = 0;
  3273. model.worker = new List<worker>();
  3274. int lastnumber = 0;
  3275. foreach (var it in modellist)
  3276. {
  3277. try
  3278. {
  3279. if (int.Parse(it.F_QuestionType) == categorylist[i].F_Id)
  3280. {
  3281. model.number++;
  3282. if (it.F_State == 10 || it.F_State == 11)
  3283. {
  3284. efficiency++;
  3285. }
  3286. if (it.F_IsOver == 1&&it .F_Type !="3")
  3287. {
  3288. worker worker = new worker();
  3289. worker.F_WorkOrderCode = it.F_WorkOrderCode;
  3290. if (it.F_State == 1)
  3291. worker.F_State = "待接单";
  3292. else if (it.F_State == 2)
  3293. worker.F_State = "待处理";
  3294. else if (it.F_State == 3)
  3295. worker.F_State = "已退回";
  3296. else if (it.F_State == 4)
  3297. worker.F_State = "异常退回";
  3298. else if (it.F_State == 4)
  3299. worker.F_State = "异常退回";
  3300. else if (it.F_State == 11)
  3301. worker.F_State = "已回访";
  3302. else
  3303. worker.F_State = "已处理";
  3304. if (it.F_Type == "1")
  3305. {
  3306. worker.F_Type = "咨询";
  3307. }
  3308. else if (it.F_Type == "2")
  3309. {
  3310. worker.F_Type = "投诉";
  3311. }
  3312. else if (it.F_Type == "3")
  3313. {
  3314. worker.F_Type = "抽检";
  3315. }
  3316. else
  3317. {
  3318. worker.F_Type = "建议及其他";
  3319. }
  3320. worker.F_SalesBase = it.F_SalesBase;
  3321. worker.F_Description = it.F_Description;
  3322. string timeover = "", timeover2 = ""; int x = 0, y = 0;
  3323. var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + " order by F_ID desc");
  3324. if (itemList[0].F_NextDept > 0)
  3325. {
  3326. var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
  3327. if (deptmodel != null)
  3328. {
  3329. worker.F_Responsibility = deptmodel.F_DeptName;
  3330. }
  3331. }
  3332. else
  3333. {
  3334. if (itemList[0].F_WoState ==10)
  3335. {
  3336. var deptmodel = departmentBLL.GetModel(2);
  3337. if (deptmodel != null)
  3338. {
  3339. worker.F_Responsibility = deptmodel.F_DeptName;
  3340. }
  3341. }
  3342. }
  3343. int limit = it.F_limit;
  3344. if (itemList != null)
  3345. {
  3346. for (int z = 0; z < itemList.Count; z++)
  3347. {
  3348. if (itemList[z].F_WoState >= 1)
  3349. {
  3350. if (itemList[z].F_WoState == 1)
  3351. {
  3352. x = z;
  3353. timeover = itemList[z].F_CreateTime.ToString();
  3354. // limit = int.Parse(itemList[z].F_LimitTime);
  3355. break ;
  3356. }
  3357. }
  3358. }
  3359. for (int z = 0; z < itemList.Count; z++)
  3360. {
  3361. if (itemList[z].F_WoState >= 1)
  3362. {
  3363. if (itemList[z].F_WoState == 11)
  3364. {
  3365. y = z;
  3366. timeover2 = itemList[z].F_CreateTime.ToString();
  3367. // limit = int.Parse(itemList[z].F_LimitTime);
  3368. }
  3369. }
  3370. if (timeover2 != "")
  3371. {
  3372. if (timeover != "")
  3373. {
  3374. if (x > y)
  3375. {
  3376. System.TimeSpan id = DateTime.Parse(timeover2) - DateTime.Parse(timeover);
  3377. double a = id.TotalHours;
  3378. worker.time = a - limit;
  3379. timehource.Add((float)worker.time);
  3380. if (worker.time > 24)
  3381. {
  3382. double t = worker.time / 24;
  3383. double v = worker.time % 24;
  3384. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3385. }
  3386. else
  3387. {
  3388. worker.overtime = string.Format("{0:f2}h", a - limit);
  3389. }
  3390. }
  3391. else
  3392. {
  3393. System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
  3394. double a = id.TotalHours;
  3395. worker.time = a - limit;
  3396. timehource.Add((float)worker.time);
  3397. if (worker.time > 24)
  3398. {
  3399. double t = worker.time / 24;
  3400. double v = worker.time % 24;
  3401. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3402. }
  3403. else
  3404. {
  3405. worker.overtime = string.Format("{0:f2}h", a - limit);
  3406. }
  3407. }
  3408. }
  3409. }
  3410. else if (timeover != "")
  3411. {
  3412. System.TimeSpan id = DateTime.Now - DateTime.Parse(timeover);
  3413. double a = id.TotalHours;
  3414. worker.time = a - limit;
  3415. timehource.Add((float)worker.time);
  3416. if (worker.time > 24)
  3417. {
  3418. double t = worker.time / 24;
  3419. double v = worker.time % 24;
  3420. worker.overtime = string.Format("{0:f0}天{1:f2}h", t, v);
  3421. }
  3422. else
  3423. {
  3424. worker.overtime = string.Format("{0:f2}h", a - limit);
  3425. }
  3426. }
  3427. }
  3428. }
  3429. if (it.F_State != 11)
  3430. Overdue++;
  3431. else
  3432. EndOverdue++;
  3433. model.worker.Add(worker);
  3434. }
  3435. model.Overdue = Overdue + "";
  3436. model.EndOverdue = EndOverdue + "";
  3437. if (lastmodellist != null)
  3438. {
  3439. foreach (var iv in lastmodellist)
  3440. {
  3441. if (int.Parse(iv.F_QuestionType) == categorylist[i].F_Id)
  3442. {
  3443. if (iv.F_State == 10 || iv.F_State == 11)
  3444. lastnumber++;
  3445. }
  3446. }
  3447. }
  3448. }
  3449. }
  3450. catch
  3451. {
  3452. }
  3453. }
  3454. if (lastnumber == 0)
  3455. {
  3456. model.efficiency = string.Format("{0:f0}% ", efficiency / 1 * 100);
  3457. }
  3458. else
  3459. {
  3460. int v = efficiency - lastnumber;
  3461. model.efficiency = string.Format("{0:f0}% ", v / lastnumber * 100);
  3462. }
  3463. if (timehource.Count > 0)
  3464. {
  3465. timehource.Sort((a, b) => b.CompareTo(a));
  3466. model.ongesttime = string.Format("{0:f2}", timehource[0]/24);
  3467. model.minimumtime = string.Format("{0:f2}", timehource[timehource.Count - 1]/24);
  3468. int n = timehource.Count / 2;
  3469. model.median = string.Format("{0:f2}", timehource[n]/24);
  3470. float y = 0;
  3471. foreach (var iu in timehource)
  3472. {
  3473. y += iu;
  3474. }
  3475. model.averageTime = string.Format("{0:f2}", y / timehource.Count/24);
  3476. }
  3477. else
  3478. {
  3479. model.ongesttime = "0";
  3480. model.minimumtime = "0";
  3481. model.median = "0";
  3482. model.averageTime = "0";
  3483. }
  3484. model.worker.Sort((a, b) => b.time.CompareTo(a.time));
  3485. if (questionName != "")
  3486. modeNamelList.Add(model);
  3487. else if (model.number > 0)
  3488. {
  3489. modeNamelList.Add(model);
  3490. }
  3491. }
  3492. }
  3493. }
  3494. int max = 0;
  3495. if (modeNamelList.Count >0)
  3496. {
  3497. modeNamelList.Sort((a, b) => b.number.CompareTo(a.number));
  3498. max = modeNamelList.Max(t => t.number);
  3499. }
  3500. var obj = new
  3501. {
  3502. state = "success",
  3503. message = "成功",
  3504. rows = modeNamelList,
  3505. max,
  3506. total = modeNamelList.Count
  3507. };
  3508. return Content(obj.ToJson()); ;
  3509. }
  3510. public class People
  3511. {
  3512. public string name { get; set; }
  3513. public int age { get; set; }
  3514. public string sex { get; set; }
  3515. }
  3516. /// <summary>
  3517. /// 渠道来源数据分析表
  3518. /// </summary>
  3519. /// <returns></returns>
  3520. public ActionResult GetChannel(string channel="")
  3521. {
  3522. string sql = $" and F_IsDelete=0";
  3523. sql += "and F_State=" + (int)EnumWorkOrderState.evaluate;
  3524. DataTable dt = new DataTable();
  3525. #region 筛选条件
  3526. List<Channel> modelList = new List<Channel> ();
  3527. List<string> channelname = new List<string>();
  3528. if (channel != "")
  3529. {
  3530. channelname.Add(channel);
  3531. }
  3532. else
  3533. {
  3534. channelname.Add("总经销");
  3535. channelname.Add("二级商");
  3536. channelname.Add("种田大户");
  3537. channelname.Add("公司员工");
  3538. channelname.Add("其他公众");
  3539. }
  3540. for (int i = 0; i <channelname.Count ; i++)
  3541. {
  3542. Channel model = new Channel();
  3543. model.channel = channelname[i ];
  3544. string changel = "";
  3545. if (channelname[i ]!= "其他公众")
  3546. {
  3547. changel ="'"+ model.channel.Trim()+"'";
  3548. }
  3549. else
  3550. {
  3551. changel = "'农户','化工客户','其他'";
  3552. }
  3553. string msg = "";
  3554. var modellist= woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(changel) + ")" + sql+ "and F_Type in (2,3)");
  3555. var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(changel) + ")" + sql + "and F_Type in (1,4)");
  3556. int phone = 0, Chat = 0, diate=0, Trans=0, Satis=0, Unsatis= 0,Verysatisfied=0, Commonly=0;
  3557. foreach (var it in modellist)
  3558. {
  3559. if (it .F_Source =="1")
  3560. phone ++;
  3561. if (it.F_Source == "2" || it.F_Source == "3")
  3562. Chat++;
  3563. if (it.F_DealType == "当即办理")
  3564. diate++;
  3565. if (it.F_DealType == "电话转接")
  3566. Trans++;
  3567. if ( it.F_VisitResult == "非常满意")
  3568. Verysatisfied++;
  3569. if (it.F_VisitResult == "满意")
  3570. Satis++;
  3571. if (it.F_VisitResult == "一般")
  3572. Commonly++;
  3573. if ( it.F_VisitResult == "不满意")
  3574. Unsatis++;
  3575. }
  3576. foreach (var it in modellis)
  3577. {
  3578. if (it.F_Source == "1")
  3579. phone++;
  3580. if (it.F_Source == "2" || it.F_Source == "3")
  3581. Chat++;
  3582. if (it.F_DealType == "当即办理")
  3583. diate++;
  3584. if (it.F_DealType == "电话转接")
  3585. Trans++;
  3586. if (it.F_VisitResult == "非常满意")
  3587. Verysatisfied++;
  3588. if (it.F_VisitResult == "满意")
  3589. Satis++;
  3590. if (it.F_VisitResult == "一般")
  3591. Commonly++;
  3592. if (it.F_VisitResult == "不满意")
  3593. Unsatis++;
  3594. }
  3595. model.Telephone = phone;
  3596. model.WeChat = Chat;
  3597. model.Immediate = diate;
  3598. model.Transfer = Trans;
  3599. model.Verysatisfied = Verysatisfied;
  3600. model.Commonly = Commonly;
  3601. model.Total = modellist.Count;
  3602. model.Satisfaction = Satis;
  3603. model.Unsatisfactory = Unsatis;
  3604. modelList.Add(model);
  3605. }
  3606. #endregion
  3607. var obj = new
  3608. {
  3609. state = "success",
  3610. message = "成功",
  3611. rows = modelList,
  3612. total = modelList.Count
  3613. };
  3614. return Content(obj.ToJson()); ;
  3615. }
  3616. /// <summary>
  3617. /// 大数据区域表
  3618. /// </summary>
  3619. /// <returns></returns>
  3620. public ActionResult GetRegionList(string stime, string endtime, string salesBase, string channel, int type = 0, int page = 1, int limit = 10)
  3621. {
  3622. string sql = $" and F_IsDelete=0";
  3623. DataTable dt = new DataTable();
  3624. #region 筛选条件
  3625. if (type > 0 && type < 5)//工单类型
  3626. sql += $" and F_Type=" + type;
  3627. if (stime != null && stime.Trim() != "")
  3628. {
  3629. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  3630. }
  3631. if (endtime != null && endtime.Trim() != "")
  3632. {
  3633. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  3634. }
  3635. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  3636. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  3637. if (!string.IsNullOrWhiteSpace(channel))
  3638. {
  3639. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  3640. }
  3641. sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  3642. #endregion
  3643. int recordCount = 0;
  3644. if (!string.IsNullOrWhiteSpace(sql))
  3645. {
  3646. dt = BLL.PagerBLL.GetListPager(
  3647. "T_Wo_WorkOrder",
  3648. "F_ID",
  3649. "*",
  3650. sql,
  3651. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  3652. limit,
  3653. page,
  3654. true,
  3655. out recordCount);
  3656. }
  3657. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  3658. if (modlelist.Count > 0)
  3659. {
  3660. List<Questions> input = modeltooip(modlelist);
  3661. var obj = new
  3662. {
  3663. state = "success",
  3664. message = "成功",
  3665. rows = input,
  3666. total = recordCount
  3667. };
  3668. return Content(obj.ToJson()); ;
  3669. }
  3670. else
  3671. {
  3672. return Success("暂无工单"); ;
  3673. }
  3674. }
  3675. public string GetCustomer(string msg)
  3676. {
  3677. string str = "";
  3678. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg+")";
  3679. return str;
  3680. }
  3681. public string GetCustomerrel(string msg)
  3682. {
  3683. string str = "";
  3684. str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg + ")";
  3685. return str;
  3686. }
  3687. private string ChannelType(string msg)
  3688. {
  3689. string mag = "";
  3690. DataTable dtxy = DbHelperSQL.Query(msg).Tables[0];
  3691. mag = dtxy.Rows.Count.ToString();
  3692. return mag;
  3693. }
  3694. /// <summary>
  3695. /// 验证物料编码为10位纯数字
  3696. /// </summary>
  3697. private bool valcode(string code, int number)
  3698. {
  3699. var res = false;
  3700. //11位数字
  3701. if (code.Length == number && Regex.IsMatch(code, @"^\d{" + number + "}$"))
  3702. res = true;
  3703. return res;
  3704. }
  3705. /// <summary>
  3706. /// 根据model返回Prescription对象
  3707. /// </summary>
  3708. private List<Prescription> modelPrescription(List<Model.T_Wo_WorkOrder> model1)
  3709. {
  3710. int userId = CurrentUser.UserData.F_UserId;
  3711. if (model1 != null && model1.Count > 0)
  3712. {
  3713. List<Prescription> Input = new List<Prescription>(model1.Count);
  3714. for (int i = 0; i < model1.Count; i++)
  3715. {
  3716. Prescription model = new Prescription();
  3717. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  3718. if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
  3719. {
  3720. cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3721. }
  3722. else
  3723. {
  3724. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
  3725. }
  3726. if (cuModel != null)
  3727. {
  3728. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  3729. {
  3730. Model.T_Sys_Department pdModel = new T_Sys_Department();
  3731. try
  3732. {
  3733. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  3734. }
  3735. catch
  3736. {
  3737. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3738. }
  3739. if (pdModel != null)
  3740. {
  3741. model.AreaName = pdModel.F_DeptName;
  3742. }
  3743. }
  3744. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  3745. {
  3746. Model.T_Sys_Department pdModel1 = new T_Sys_Department();
  3747. try
  3748. {
  3749. pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
  3750. }
  3751. catch
  3752. {
  3753. pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
  3754. }
  3755. if (pdModel1 != null)
  3756. {
  3757. model.BranchName = pdModel1.F_DeptName;
  3758. }
  3759. }
  3760. model.Brands = cuModel.F_Brands;//品牌
  3761. }
  3762. if (!string.IsNullOrEmpty(model1[i].F_QuestionType))
  3763. {
  3764. Model.T_Wo_QuestionManage Manage = null;
  3765. try
  3766. {
  3767. int b = int.Parse(model1[i].F_QuestionType.Trim());
  3768. Manage = quesBLL.GetModel(b);
  3769. }
  3770. catch (Exception)
  3771. {
  3772. Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  3773. }
  3774. if (Manage != null)
  3775. {
  3776. if (Manage.F_Label == "1")
  3777. {
  3778. model.QuestionTypeone = Manage.F_QuestionName;
  3779. model.QuestionTypetwo = "";
  3780. model.QuestionTypethree = "";
  3781. }
  3782. else if (Manage.F_Label == "2")
  3783. {
  3784. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  3785. model.QuestionTypeone = Manage1.F_QuestionName;
  3786. model.QuestionTypetwo = Manage.F_QuestionName;
  3787. model.QuestionTypethree = "";
  3788. }
  3789. else
  3790. {
  3791. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  3792. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  3793. model.QuestionTypeone = Manage2.F_QuestionName;//问题类别1
  3794. model.QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
  3795. model.QuestionTypethree = Manage.F_QuestionName;//问题类别3
  3796. }
  3797. }
  3798. }
  3799. model.ProductBase = model1[i].F_SC_ProductBase;//生产基地
  3800. model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//责任科室
  3801. model.Description = model1[i].F_Description;//问题描述
  3802. model.Category = model1[i].F_TS_Category;//产品
  3803. model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  3804. model.CreatOn = model1[i].F_CreateOn.ToString();//时间
  3805. Input.Add(model);
  3806. }
  3807. return Input;
  3808. }
  3809. else
  3810. {
  3811. return null;
  3812. }
  3813. }
  3814. /// <summary>
  3815. /// 根据model返回Questions对象
  3816. /// </summary>
  3817. private List<Questions> modeltooip(List<Model.T_Wo_WorkOrder> model1)
  3818. {
  3819. int userId = CurrentUser.UserData.F_UserId;
  3820. if (model1 != null && model1.Count > 0)
  3821. {
  3822. List<Questions> Input = new List<Questions>(model1.Count);
  3823. for (int i = 0; i < model1.Count; i++)
  3824. {
  3825. Questions model = new Questions();
  3826. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  3827. if (!string .IsNullOrEmpty (model1[i].F_CustomerID))//验证客户编码为10位纯数字
  3828. {
  3829. cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3830. }
  3831. else
  3832. {
  3833. var sql = $" and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'";
  3834. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 " + sql).FirstOrDefault();
  3835. }
  3836. if (cuModel != null)
  3837. {
  3838. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  3839. {
  3840. Model.T_Sys_Department pdModel = new T_Sys_Department();
  3841. try
  3842. {
  3843. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  3844. }
  3845. catch
  3846. {
  3847. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3848. }
  3849. if (pdModel != null)
  3850. {
  3851. model.AreaName = pdModel.F_DeptName;
  3852. }
  3853. }
  3854. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  3855. {
  3856. Model.T_Sys_Department pdModel1 = new T_Sys_Department();
  3857. try
  3858. {
  3859. pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
  3860. }
  3861. catch
  3862. {
  3863. pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
  3864. }
  3865. if (pdModel1 != null)
  3866. {
  3867. model.BranchName = pdModel1.F_DeptName;
  3868. }
  3869. }
  3870. model.Salesman = cuModel.F_Salesman;
  3871. model.Brands = cuModel.F_Brands;
  3872. model.Channel = cuModel.F_Channel;
  3873. }
  3874. model .Category = model1[i].F_TS_Category ;
  3875. if (model1[i].F_Type == "1")
  3876. {
  3877. model.Type = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3878. }
  3879. else if (model1[i].F_Type == "2")
  3880. {
  3881. model.Type = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3882. }
  3883. else if (model1[i].F_Type == "3")
  3884. {
  3885. model.Type = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3886. }
  3887. else
  3888. {
  3889. model.Type = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3890. }
  3891. model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  3892. model.CreatOn = model1[i].F_CreateOn .ToString ();
  3893. if (model1[i].F_Type !="3")
  3894. {
  3895. if (TimeToOver(model1[i].F_ID, model1[i].F_limit) < 0)
  3896. model.Overtime = Math.Abs(TimeToOver(model1[i].F_ID, model1[i].F_limit)).ToString();
  3897. else
  3898. model.Overtime = "0";
  3899. }
  3900. else
  3901. model.Overtime = "0";
  3902. if (model1[i].F_State == 11 && model1[i].F_IsVisit == 1)
  3903. model.Isvisit = "是";
  3904. else
  3905. model.Isvisit = "否";
  3906. if (model1[i].F_State == 11)
  3907. model.IsClose = "是";
  3908. else
  3909. model.IsClose = "否";
  3910. Input.Add(model);
  3911. }
  3912. return Input;
  3913. }
  3914. else
  3915. {
  3916. return null;
  3917. }
  3918. }
  3919. /// <summary>
  3920. /// 根据model返回WorkOrderComplaint对象
  3921. /// </summary>
  3922. private List<WorkOrderComplaint> modelComplaint(List<Model.T_Wo_WorkOrder> model1)
  3923. {
  3924. if (model1 != null && model1.Count > 0)
  3925. {
  3926. List<WorkOrderComplaint> Input = new List<WorkOrderComplaint>(model1.Count);
  3927. for (int i = 0; i < model1.Count; i++)
  3928. {
  3929. WorkOrderComplaint model = new WorkOrderComplaint();
  3930. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  3931. if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
  3932. {
  3933. cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3934. }
  3935. else
  3936. {
  3937. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
  3938. }
  3939. if (cuModel != null)
  3940. {
  3941. model.F_CustomerID = cuModel.F_CustomerCode;//客户编码
  3942. if (!string.IsNullOrEmpty(cuModel.F_AreaID))
  3943. {
  3944. Model.T_Sys_Department pdModel = new T_Sys_Department();
  3945. try
  3946. {
  3947. pdModel = departmentBLL.GetModel(int.Parse(cuModel.F_AreaID));//通过公司id获取部门
  3948. }
  3949. catch
  3950. {
  3951. pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3952. }
  3953. if (pdModel != null)
  3954. {
  3955. model.F_AreaName = pdModel.F_DeptName;
  3956. }
  3957. }
  3958. if (!string.IsNullOrEmpty(cuModel.F_BranchID))
  3959. {
  3960. Model.T_Sys_Department pdModel1 = new T_Sys_Department();
  3961. try
  3962. {
  3963. pdModel1 = departmentBLL.GetModel(int.Parse(cuModel.F_BranchID));//通过公司id获取部门
  3964. }
  3965. catch
  3966. {
  3967. pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);//通过公司id获取部门
  3968. }
  3969. if (pdModel1 != null)
  3970. {
  3971. model.F_BranchName = pdModel1.F_DeptName;
  3972. }
  3973. }
  3974. model.F_Salesman = cuModel.F_Salesman;//业务员
  3975. }
  3976. if (!string .IsNullOrEmpty (model1[i].F_MaterialID))
  3977. {
  3978. if (valcode(model1[i].F_MaterialID, 11))
  3979. {
  3980. model.F_MaterialID =model1[i].F_MaterialID;//验证物料编码为11位纯数字
  3981. Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(model1[i].F_MaterialID);//通过物料编码获取物料信息
  3982. if (maModel != null)
  3983. {
  3984. model.F_MaterialName = maModel.F_MaterialName;//物料名称
  3985. model.F_Model = maModel.F_Model;//型号
  3986. model.F_Specs = maModel.F_Specs;//规格
  3987. model.F_Level1 = maModel.F_Level1;//一级分类
  3988. model.F_Level2 = maModel.F_Level2;//二级分类
  3989. model.F_Level3 = maModel.F_Level3;//三级分类
  3990. model.F_Brand = maModel.F_Brand;//品牌
  3991. model.F_MaterialEffect = maModel.F_MaterialEffect;//F_MaterialEffect
  3992. model.F_Pipeline = maModel.F_Pipeline;//F_Pipeline
  3993. model.F_Craft = maModel.F_Craft;//F_Craft
  3994. }
  3995. }
  3996. }
  3997. if (!string .IsNullOrEmpty(model1[i].F_QuestionType))
  3998. {
  3999. Model.T_Wo_QuestionManage Manage = null;
  4000. try
  4001. {
  4002. int b = int.Parse(model1[i].F_QuestionType.Trim());
  4003. Manage = quesBLL.GetModel(b);
  4004. }
  4005. catch (Exception)
  4006. {
  4007. Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  4008. }
  4009. if (Manage !=null )
  4010. {
  4011. if (Manage .F_Label =="1")
  4012. {
  4013. model.F_QuestionTypeone = Manage.F_QuestionName;
  4014. model.F_QuestionTypetwo = "";
  4015. model.F_QuestionTypethree ="";
  4016. }
  4017. else if (Manage.F_Label == "2")
  4018. {
  4019. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int .Parse (Manage.F_ParentId.ToString () ) );//获取问题类别
  4020. model.F_QuestionTypeone = Manage1.F_QuestionName;
  4021. model.F_QuestionTypetwo = Manage.F_QuestionName;
  4022. model.F_QuestionTypethree = "";
  4023. }
  4024. else
  4025. {
  4026. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  4027. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  4028. model.F_QuestionTypeone = Manage2.F_QuestionName;//问题类别1
  4029. model.F_QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
  4030. model.F_QuestionTypethree =Manage.F_QuestionName;//问题类别3
  4031. }
  4032. }
  4033. }
  4034. model.F_CusName = model1[i].F_CusName;//客户姓名
  4035. model.F_CusPhone = model1[i].F_CusPhone;//客户电话
  4036. model.F_CompanyName = model1[i].F_CompanyName;//公司名称
  4037. model.F_IncidentProvince = model1[i].F_IncidentProvince;//事发地-省
  4038. model.F_IncidentCity = model1[i].F_IncidentCity;//事发地-市
  4039. model.F_IncidentCountry = model1[i].F_IncidentCountry;//事发地-县
  4040. model.F_IncidentTownship = model1[i].F_IncidentTownship;//事发地-乡
  4041. model.F_IncidentDetailed = model1[i].F_IncidentDetailed;//事发地-详细
  4042. model.F_SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  4043. model.F_Description = model1[i].F_Description;//问题描述
  4044. model.F_BatchNumber = model1[i].F_BatchNumber;//生产批次号
  4045. model.F_TS_Quantity = model1[i].F_TS_Quantity;//投诉-问题数量(吨)
  4046. model.F_SC_ProductBase = model1[i].F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
  4047. model.F_SC_PreliminaryOpinion = model1[i].F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
  4048. model.F_SC_QualityMonth = model1[i].F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
  4049. model.F_ZL_QualityEventLevel = model1[i].F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
  4050. model.F_ZL_ClaimAmount = model1[i].F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
  4051. model.F_ZL_ResponsibleUnit = model1[i].F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
  4052. model.F_ZL_ApprovalOpinions = model1[i].F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  4053. model.F_ZL_ApprovalDisagree = model1[i].F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
  4054. model.F_ZL_CompensationMethod = model1[i].F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  4055. model.F_ZL_CompensationMoney = model1[i].F_ZL_CompensationMoney;// 质量管理科-补偿钱款
  4056. model.F_ZL_CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  4057. model.F_ZL_Fquantity = model1[i].F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
  4058. model.F_ZL_ImprovementRequirements = model1[i].F_ZL_ImprovementRequirements;//质量管理科-改进要求
  4059. model.F_ZL_CApprovalNo = model1[i].F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
  4060. model.F_DealType = model1[i].F_DealType;//处理方式:当即办理、电话转接、网络转办
  4061. model.F_DealBy = model1[i].F_DealBy;//处理人
  4062. model.F_DealTime = model1[i].F_DealTime;//处理时间
  4063. model.F_DealContent = model1[i].F_DealContent;//处理内容
  4064. if (model1[i].F_State ==10|| model1[i].F_State == 11)
  4065. model.F_DealResult ="已处理";//处理结果
  4066. else
  4067. model.F_DealResult = "未处理";//处理结果
  4068. model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
  4069. model.F_CreateOn = model1[i].F_CreateOn; ;//添加时间
  4070. Input.Add(model);
  4071. }
  4072. return Input;
  4073. }
  4074. else
  4075. {
  4076. return null;
  4077. }
  4078. }
  4079. /// <summary>
  4080. /// 根据model返回WorkOrderComplaint对象
  4081. /// </summary>
  4082. private List<Product> modelProduct(List<Model.T_Wo_WorkOrder> model1)
  4083. {
  4084. if (model1 != null && model1.Count > 0)
  4085. {
  4086. List<Product> Input = new List<Product>(model1.Count);
  4087. for (int i = 0; i < model1.Count; i++)
  4088. {
  4089. Product model = new Product();
  4090. Model.T_Cus_CustomerBaseNew cuModel = new Model.T_Cus_CustomerBaseNew();
  4091. if (!string.IsNullOrEmpty(model1[i].F_CustomerID))//验证客户编码为10位纯数字
  4092. {
  4093. cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  4094. }
  4095. else
  4096. {
  4097. cuModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_IsDelete = 0 and F_LegalPhone ='" + model1[i].F_CusPhone.Trim() + "'").FirstOrDefault();
  4098. }
  4099. if (cuModel != null)
  4100. {
  4101. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  4102. model.F_Salesman = cuModel.F_Salesman;//业务员
  4103. }
  4104. model.Category = model1[i].F_TS_Category;//产品
  4105. model.Company = model1[i].F_CompanyName;//客户单位
  4106. if (!string.IsNullOrEmpty(model1[i].F_BatchNumber))
  4107. {
  4108. var prono = model1[i].F_BatchNumber.Substring(0, 6);
  4109. try
  4110. {
  4111. var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
  4112. // var protime = Convert.ToDateTime(pronos);
  4113. model.ProductionTime = pronos;
  4114. }
  4115. catch
  4116. {
  4117. model.ProductionTime = "";
  4118. }
  4119. }
  4120. model.CreatOn = model1[i].F_CreateOn .ToString (); ;
  4121. model.Spurtcode = model1[i].F_BatchNumber;
  4122. Model.T_Wo_QuestionManage Manage = null;
  4123. try
  4124. {
  4125. int b = int.Parse(model1[i].F_QuestionType.Trim());
  4126. Manage = quesBLL.GetModel(b);
  4127. if (Manage !=null )
  4128. {
  4129. model.QuestionType = Manage.F_QuestionName;
  4130. }
  4131. }
  4132. catch (Exception)
  4133. {
  4134. model.QuestionType = model1[i].F_QuestionType;
  4135. }
  4136. model.Description = model1[i].F_Description;
  4137. model.DealType = model1[i].F_DealType;
  4138. model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;
  4139. model.SalesBase = model1[i].F_SalesBase;
  4140. Input.Add(model);
  4141. }
  4142. return Input;
  4143. }
  4144. else
  4145. {
  4146. return null;
  4147. }
  4148. }
  4149. /// <summary>
  4150. /// 是否超时
  4151. /// </summary>
  4152. /// <param name="id"></param>
  4153. /// <returns></returns>
  4154. private float TimeToOver(int id,int time)
  4155. {
  4156. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + "order by F_ID desc ");
  4157. string time1 = "", time2 = ""; int x = 0, y = 0;
  4158. if (itemlasts.Count > 0)
  4159. {
  4160. for (int z = 0; z < itemlasts.Count; z++)
  4161. {
  4162. if (itemlasts[z].F_WoState >= 1)
  4163. {
  4164. if (itemlasts[z].F_WoState == 1)
  4165. {
  4166. x = z;
  4167. time1 = itemlasts[z].F_CreateTime.ToString();
  4168. break;
  4169. }
  4170. }
  4171. }
  4172. for (int i = 0; i < itemlasts.Count; i++)
  4173. {
  4174. if (itemlasts[i].F_WoState >= 1)
  4175. {
  4176. if (itemlasts[i].F_WoState == 10)
  4177. {
  4178. y = i;
  4179. time2 = itemlasts[i].F_CreateTime.ToString();
  4180. }
  4181. }
  4182. }
  4183. if (time2 != "")
  4184. {
  4185. if (time1 != "")
  4186. {
  4187. if (x > y)
  4188. {
  4189. System.TimeSpan a = DateTime.Parse(time2) - DateTime.Parse(time1);
  4190. float b = time - (float)a.TotalHours;
  4191. return b;
  4192. }
  4193. else
  4194. {
  4195. System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
  4196. float b = time - (float)a.TotalHours;
  4197. return b;
  4198. }
  4199. }
  4200. else
  4201. {
  4202. return 0;
  4203. }
  4204. }
  4205. else if (time1 != "")
  4206. {
  4207. System.TimeSpan a = DateTime.Now - DateTime.Parse(time1);
  4208. float b = time - (float)a.TotalHours;
  4209. return b;
  4210. }
  4211. else
  4212. {
  4213. return 0;
  4214. }
  4215. }
  4216. return 0;
  4217. }
  4218. /// <summary>
  4219. /// 获取客户编号
  4220. /// </summary>
  4221. /// <returns></returns>
  4222. public string GetCustomerID(string channel)
  4223. {
  4224. string str = string.Empty;
  4225. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_Channel='" + channel + "' " + " and isnull(F_IsDelete,'0')='0' "; ;
  4226. return str;
  4227. }
  4228. /// <summary>
  4229. /// 获得数据列表
  4230. /// </summary>
  4231. public List<QuestionType> DataTableToList(DataTable dt)
  4232. {
  4233. List<QuestionType> modelList = new List<QuestionType>();
  4234. int rowsCount = dt.Rows.Count;
  4235. if (rowsCount > 0)
  4236. {
  4237. QuestionType model;
  4238. for (int n = 0; n < rowsCount; n++)
  4239. {
  4240. model = DataRowToModel(dt.Rows[n]);
  4241. if (model != null)
  4242. {
  4243. modelList.Add(model);
  4244. }
  4245. }
  4246. }
  4247. return modelList;
  4248. }
  4249. /// <summary>
  4250. /// 得到一个对象实体
  4251. /// </summary>
  4252. public QuestionType DataRowToModel(DataRow row)
  4253. {
  4254. QuestionType model = new QuestionType();
  4255. if (row != null)
  4256. {
  4257. if (row["F_QuestionType"] != null)
  4258. {
  4259. model.F_QuestionType = row["F_QuestionType"].ToString();
  4260. }
  4261. if (row["number"] != null && row["number"].ToString() != "")
  4262. {
  4263. model.number = int.Parse(row["number"].ToString());
  4264. }
  4265. }
  4266. return model;
  4267. }
  4268. private DataTable getData(string stime, string endtime, int deptid = 0)
  4269. {
  4270. DataTable dtNew = new DataTable();
  4271. #region 添加表格标题
  4272. //部门,工号,姓名,建单量,接单量,未处理量,异常量,已处理量
  4273. dtNew.Columns.Add("部门");
  4274. dtNew.Columns.Add("工号");
  4275. dtNew.Columns.Add("姓名");
  4276. dtNew.Columns.Add("建单量");
  4277. dtNew.Columns.Add("接单量");
  4278. dtNew.Columns.Add("未处理量");
  4279. dtNew.Columns.Add("异常量");
  4280. dtNew.Columns.Add("已处理量");
  4281. #endregion
  4282. #region 筛选条件
  4283. string sqlwo = " isdel=0 "; string sqluser = " F_DeleteFlag=0 ";string sqldept = " F_State=1 ";
  4284. if (stime != null && stime.Trim() != "")
  4285. {
  4286. sqlwo += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  4287. }
  4288. if (endtime != null && endtime.Trim() != "")
  4289. {
  4290. sqlwo += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  4291. }
  4292. if (deptid > 0)
  4293. {
  4294. sqluser += " and F_DeptId=" + deptid;
  4295. sqldept += " and F_DeptId=" + deptid;
  4296. }
  4297. #endregion
  4298. //获取部门
  4299. var depts = new BLL.T_Sys_Department().GetModelList(sqldept);
  4300. //获取人员
  4301. var users = new BLL.T_Sys_UserAccount().GetModelList(sqluser);
  4302. #region 获取工单量
  4303. //--创建量,接单量,未处理量,异常量,已处理量
  4304. //--创建量
  4305. string sqlcreate = $" select CreateUser,COUNT(1) con from T_Wo_WorkOrder where " +sqlwo+" group by CreateUser";
  4306. DataTable dtcreate = DbHelperSQL.Query(sqlcreate).Tables[0];
  4307. //--接单量
  4308. string sqljd = $"select F_NextUser, COUNT(1) con from( " +
  4309. "select F_WoID, F_NextUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.assign + " " +
  4310. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  4311. "group by F_WoID, F_NextUser) t group by F_NextUser ";
  4312. DataTable dtjd= DbHelperSQL.Query(sqljd).Tables[0];
  4313. //--未处理量
  4314. string sqlwcl = $"select F_CreateUser, COUNT(1) con from( " +
  4315. "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState < " + (int)EnumWorkOrderState.finish + " " +
  4316. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  4317. "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
  4318. DataTable dtwcl = DbHelperSQL.Query(sqlwcl).Tables[0];
  4319. //--异常量:以提交异常退回的人员为准
  4320. string sqlyc = $"select F_CreateUser, COUNT(1) con from( " +
  4321. "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.abreback + " " +
  4322. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  4323. "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
  4324. DataTable dtyc = DbHelperSQL.Query(sqlyc).Tables[0];
  4325. //--已处理量:以最终处理人为准
  4326. string sqlwj = $" select LastDealUser,COUNT(1) con from T_Wo_WorkOrder where " + sqlwo + " and State=" + (int)EnumWorkOrderState.finish + " group by LastDealUser";
  4327. DataTable dtwj = DbHelperSQL.Query(sqlwj).Tables[0];
  4328. #endregion
  4329. foreach (var user in users)
  4330. {
  4331. DataRow drNew = dtNew.NewRow();
  4332. //部门,
  4333. var dept = depts.Where(d => d.F_DeptId == user.F_DeptId).FirstOrDefault();
  4334. var deptname = dept != null ? dept.F_DeptName : "";
  4335. //建单量,
  4336. var createcount = "0";
  4337. var createRows = dtcreate.Select(" CreateUser = '" + user.F_UserCode + "'");
  4338. if (createRows.Length > 0)
  4339. createcount = createRows[0]["con"].ToString();
  4340. //接单量,
  4341. var jdcount = "0";
  4342. var jdRows = dtjd.Select(" F_NextUser = '" + user.F_UserCode + "'");
  4343. if (jdRows.Length > 0)
  4344. jdcount = jdRows[0]["con"].ToString();
  4345. //未处理量,
  4346. var wclcount = "0";
  4347. var wclRows=dtwcl.Select(" F_CreateUser = '" + user.F_UserCode + "'");
  4348. if (wclRows.Length > 0)
  4349. wclcount = wclRows[0]["con"].ToString();
  4350. //异常量,
  4351. var yccount = "0";
  4352. var ycRows = dtyc.Select(" F_CreateUser = '" + user.F_UserCode + "'");
  4353. if (ycRows.Length>0)
  4354. yccount=ycRows[0]["con"].ToString();
  4355. //已处理量
  4356. var wjcount = "0";
  4357. var wjRows = dtwj.Select(" LastDealUser = '" + user.F_UserCode + "'");
  4358. if (wjRows.Length > 0)
  4359. wjcount= wjRows[0]["con"].ToString();
  4360. drNew["部门"] = deptname;
  4361. drNew["工号"] = user.F_UserCode;
  4362. drNew["姓名"] = user.F_UserName;
  4363. drNew["建单量"] = createcount;
  4364. drNew["接单量"] = jdcount;
  4365. drNew["未处理量"] = wclcount;
  4366. drNew["异常量"] = yccount;
  4367. drNew["已处理量"] = wjcount;
  4368. dtNew.Rows.Add(drNew);
  4369. }
  4370. return dtNew;
  4371. }
  4372. }
  4373. }
  4374. public class DynamicModel : DynamicObject
  4375. {
  4376. private string propertyName;
  4377. public string PropertyName
  4378. {
  4379. get { return propertyName; }
  4380. set { propertyName = value; }
  4381. }
  4382. // The inner dictionary.
  4383. Dictionary<string, object> dicProperty
  4384. = new Dictionary<string, object>();
  4385. public Dictionary<string, object> DicProperty
  4386. {
  4387. get
  4388. {
  4389. return dicProperty;
  4390. }
  4391. }
  4392. // This property returns the number of elements
  4393. // in the inner dictionary.
  4394. public int Count
  4395. {
  4396. get
  4397. {
  4398. return dicProperty.Count;
  4399. }
  4400. }
  4401. // If you try to get a value of a property
  4402. // not defined in the class, this method is called.
  4403. public override bool TryGetMember(
  4404. GetMemberBinder binder, out object result)
  4405. {
  4406. // Converting the property name to lowercase
  4407. // so that property names become case-insensitive.
  4408. string name = binder.Name;
  4409. // If the property name is found in a dictionary,
  4410. // set the result parameter to the property value and return true.
  4411. // Otherwise, return false.
  4412. return dicProperty.TryGetValue(name, out result);
  4413. }
  4414. // If you try to set a value of a property that is
  4415. // not defined in the class, this method is called.
  4416. public override bool TrySetMember(
  4417. SetMemberBinder binder, object value)
  4418. {
  4419. // Converting the property name to lowercase
  4420. // so that property names become case-insensitive.
  4421. if (binder.Name == "Property")
  4422. {
  4423. dicProperty[PropertyName] = value;
  4424. }
  4425. else
  4426. {
  4427. dicProperty[binder.Name] = value;
  4428. }
  4429. // You can always add a value to a dictionary,
  4430. // so this method always returns true.
  4431. return true;
  4432. }
  4433. }