No Description

WOReportController.cs 185KB

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