No Description

WOReportController.cs 176KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922
  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;//用时最长
  1999. public string minimumtime;//用时最短
  2000. public string averageTime;//平均用时
  2001. public string median;//中位数
  2002. public string Overdue;//超期数量
  2003. public string efficiency;//效率提升率
  2004. }
  2005. public class Channel
  2006. {
  2007. public string channel;//渠道
  2008. public int Telephone;//电话
  2009. public int WeChat;//微信
  2010. public int Immediate;//即时办结
  2011. public int Transfer;//即时转接
  2012. public int Verysatisfied;//非常满意
  2013. public int Satisfaction;//满意度
  2014. public int Commonly;//一般
  2015. public int Unsatisfactory;//不满意
  2016. public int Total;
  2017. }
  2018. public class BigDate
  2019. {
  2020. public List<Template> salesBase;//反馈类型
  2021. public List<Template> product;//产品
  2022. public List<Template> channel;//渠道
  2023. public List<Template> state;//工单状态
  2024. public List<Template> satisfaction;//满意度
  2025. public List<Template> overdue;//超期
  2026. }
  2027. /// <summary>
  2028. /// 反馈类型
  2029. /// </summary>
  2030. public class Template
  2031. {
  2032. public string name;//名称
  2033. public int number;// 数量
  2034. public int Lastyearnumber;//去年同比
  2035. public int Lastmonthnumber;//上月同比
  2036. public int Lastyear;//去年同比
  2037. public int Lastmonth;//上月同比
  2038. }
  2039. public string GetCustomerCode(int area=0,int branch=0,string channel="")
  2040. {
  2041. string str = "";
  2042. string sql = "";
  2043. if (area >0)
  2044. {
  2045. sql += " and F_AreaID =" + area;
  2046. }
  2047. if (branch>0)
  2048. {
  2049. sql += " and F_BranchID =" + branch;
  2050. }
  2051. if (channel!="")
  2052. {
  2053. sql += " and F_Channel= '" + channel + "'";
  2054. }
  2055. if (sql != "")
  2056. {
  2057. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + sql;
  2058. }
  2059. return str;
  2060. }
  2061. public string GetCustomerrel(int area = 0, int branch = 0, string channel = "")
  2062. {
  2063. string str = "";
  2064. string sql = "";
  2065. if (area > 0)
  2066. {
  2067. sql += " and F_AreaID =" + area;
  2068. }
  2069. if (branch > 0)
  2070. {
  2071. sql += " and F_BranchID =" + branch;
  2072. }
  2073. if (channel != "")
  2074. {
  2075. sql += " and F_Channel= '" + channel + "'";
  2076. }
  2077. str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" +sql;
  2078. return str;
  2079. }
  2080. /// <summary>
  2081. /// 大数据一览表
  2082. /// </summary>
  2083. /// <returns></returns>
  2084. public ActionResult GetBigdataList(string stime, string endtime,string salesBase ,string product,string channel, int area=0,int branch=0, int type = 0)
  2085. {
  2086. #region
  2087. if (!Refresh())
  2088. {
  2089. return Error("查询失败");
  2090. }
  2091. string sql = $" F_IsDelete=0";
  2092. DataTable dt = new DataTable();
  2093. #region 筛选条件
  2094. if (string.IsNullOrEmpty(stime))
  2095. {
  2096. stime = DateTime.Now.Date.ToString("yyyy-MM-01");
  2097. }
  2098. if (string.IsNullOrEmpty(endtime))
  2099. {
  2100. endtime = DateTime.Now.Date.ToString("yyyy-MM-dd");
  2101. }
  2102. int Months = 1;
  2103. if (!string.IsNullOrEmpty(stime)&& !string.IsNullOrEmpty(endtime))
  2104. {
  2105. Months = DateTime.Parse(endtime).Month - DateTime.Parse(stime).Month;
  2106. if (DateTime.Parse(endtime).Day > DateTime.Parse(stime).Day )
  2107. {
  2108. Months = Months + 1;
  2109. }
  2110. }
  2111. string smouth= Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).AddMonths(-Months).ToLongDateString()).ToString("yyyy-MM-dd");
  2112. string endmouth = Convert.ToDateTime(DateTime.Parse(endtime).AddDays(1 - DateTime.Parse(endtime).Day).AddMonths(-Months).ToLongDateString()).ToString("yyyy-MM-dd");
  2113. string syear = Convert.ToDateTime(DateTime.Parse(stime).AddDays(1 - DateTime.Parse(stime).Day).Date.AddYears (-1).ToLongDateString()).ToString("yyyy-MM-dd");
  2114. 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");
  2115. #endregion
  2116. string time = $" and datediff(day,F_CreateOn,'{stime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ";
  2117. string lastmouth = $" and datediff(day,F_CreateOn,'{smouth}')<=0 and datediff(day,F_CreateOn,'{endmouth}')>=0 ";
  2118. string lastyear= $" and datediff(day,F_CreateOn,'{syear}')<=0 and datediff(day,F_CreateOn,'{endyear}')>=0 ";
  2119. BigDate model = new BigDate();
  2120. model.salesBase = new List<Template>();
  2121. string strType = "";
  2122. if (type >0)
  2123. {
  2124. sql += $"and F_Type = " + type;
  2125. }
  2126. if (!string.IsNullOrEmpty(salesBase))
  2127. {
  2128. strType = $" and F_SalesBase='" + salesBase.Trim() + "'";
  2129. }
  2130. string strChannel = "";
  2131. if (area > 0 || branch > 0 || !string.IsNullOrEmpty(channel))
  2132. {
  2133. strChannel= " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, channel) + ") ";
  2134. }
  2135. string strCategory = "";
  2136. if (!string.IsNullOrEmpty(product))
  2137. {
  2138. strCategory = $" and F_TS_Category='" + product.Trim() + "'";
  2139. }
  2140. #region 反馈类型
  2141. for (int i=0;i <5;i++)
  2142. {
  2143. string sqltype = "";
  2144. Template template = new Template() ;
  2145. switch (i)
  2146. {
  2147. case 0:
  2148. template.name = "合计";
  2149. break;
  2150. case 1:
  2151. template.name = "新乡";
  2152. break;
  2153. case 2:
  2154. template.name = "新疆";
  2155. break;
  2156. case 3:
  2157. template.name = "九江";
  2158. break;
  2159. case 4:
  2160. template.name = "东北";
  2161. break;
  2162. }
  2163. if (i>0 )
  2164. {
  2165. sqltype = $"and F_SalesBase = '"+ template.name + "'" ;
  2166. }
  2167. else
  2168. {
  2169. sqltype = $"and F_SalesBase in ('新乡','新疆','九江','东北')";
  2170. }
  2171. model.salesBase .Add(ReturenTemplate(template,sql + sqltype+ strChannel+ strCategory, time , lastmouth, lastyear));
  2172. }
  2173. #endregion
  2174. #region 产品
  2175. var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
  2176. model.product = new List<Template>();
  2177. List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
  2178. if (dicv != null)
  2179. {
  2180. dicval = dicvalueBll.DataTableToList(dicv);
  2181. }
  2182. if (dicval != null && dicval.Count > 0)
  2183. {
  2184. string msf = "";
  2185. foreach (var it in dicval)
  2186. {
  2187. if (msf == "")
  2188. msf += " '" + it.F_Name + "'";
  2189. else
  2190. msf += " ,'" + it.F_Name + "'";
  2191. }
  2192. Template template = new Template();
  2193. template.name = "合计";
  2194. model.product.Add(ReturenTemplate(template, sql + strChannel + $"and F_TS_Category in (" + msf + ")" + strType, time, lastmouth, lastyear));
  2195. foreach (var it in dicval)
  2196. {
  2197. Template templates = new Template();
  2198. string mag = "";
  2199. mag = $"and F_TS_Category = '" + it.F_Name+"'";
  2200. templates.name = it.F_Name;
  2201. model.product.Add(ReturenTemplate(templates, sql + strChannel + strType + mag, time, lastmouth, lastyear));
  2202. }
  2203. }
  2204. #endregion
  2205. #region 渠道类型
  2206. var QDLX = dicvalueBll.GetList(" F_DictionaryFlag='" + "QDLX" + "' and F_State=1 ").Tables[0];
  2207. model.channel = new List<Template>();
  2208. List<Model.T_Sys_DictionaryValue> QDLXl = new List<Model.T_Sys_DictionaryValue>();
  2209. if (QDLX != null)
  2210. {
  2211. QDLXl = dicvalueBll.DataTableToList(QDLX);
  2212. }
  2213. if (QDLXl != null && QDLXl.Count > 0)
  2214. {
  2215. Template templates = new Template();
  2216. templates.name = "合计";
  2217. model.channel.Add(ReturenTemplate(templates, sql + strCategory + strType , time, lastmouth, lastyear));
  2218. foreach (var it in QDLXl)
  2219. {
  2220. Template template = new Template();
  2221. string str = "";
  2222. str = " and T_Wo_WorkOrder.F_CusPhone in ( " + GetCustomerrel(area, branch, it.F_Name) + ") ";
  2223. template.name = it.F_Name;
  2224. model.channel.Add(ReturenTemplate(template,sql+strCategory + strType + str, time, lastmouth, lastyear));
  2225. }
  2226. }
  2227. #endregion
  2228. #region 工单类型
  2229. model.state = new List<Template>();
  2230. for (int i = 0; i < 5; i++)
  2231. {
  2232. string sqlchannel = "";
  2233. Template template = new Template();
  2234. switch (i)
  2235. {
  2236. case 0:
  2237. template.name = "合计";
  2238. break;
  2239. case 1:
  2240. template.name = "待处理";
  2241. sqlchannel = " and F_State in (0, 1, 2, 3, 4, 5, 6, 7, 12, 14, 16)";
  2242. break;
  2243. case 2:
  2244. template.name = "已处理";
  2245. sqlchannel = " and F_State in (10,11)";
  2246. break;
  2247. case 3:
  2248. template.name = "待回访";
  2249. sqlchannel = " and F_State in (10)";
  2250. break;
  2251. case 4:
  2252. template.name = "已回访";
  2253. sqlchannel = " and F_State in (11)";
  2254. break;
  2255. }
  2256. model.state.Add(ReturenTemplate(template,sql + sqlchannel+strChannel + strCategory + strType, time, lastmouth, lastyear));
  2257. }
  2258. #endregion
  2259. #region 满意度
  2260. model.satisfaction = new List<Template>();
  2261. for (int i = 0; i <5; i++)
  2262. {
  2263. string sqlsatisfaction = "";
  2264. sqlsatisfaction += " and F_State in (11)";
  2265. sqlsatisfaction += " and F_IsVisit =1";
  2266. Template template = new Template();
  2267. switch (i)
  2268. {
  2269. case 0:
  2270. template.name += "合计";
  2271. break;
  2272. case 1:
  2273. template.name = "非常满意";
  2274. sqlsatisfaction += " and F_VisitResult ='非常满意'";
  2275. break;
  2276. case 2:
  2277. template.name = "满意";
  2278. sqlsatisfaction += " and F_VisitResult ='满意'";
  2279. break;
  2280. case 3:
  2281. template.name = "一般";
  2282. sqlsatisfaction += " and F_VisitResult ='一般'";
  2283. break;
  2284. case 4:
  2285. template.name = "不满意";
  2286. sqlsatisfaction += " and F_VisitResult ='不满意'";
  2287. break;
  2288. }
  2289. model.satisfaction .Add(ReturenTemplate(template,sql + sqlsatisfaction + strChannel + strCategory + strType, time, lastmouth, lastyear));
  2290. #endregion
  2291. }
  2292. #endregion
  2293. #region 超期工单
  2294. model.overdue = new List<Template>();
  2295. string sqloverdue = "";
  2296. sqloverdue += strChannel + strCategory + strType;
  2297. var modlelist = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + time);
  2298. Template templatee = new Template();
  2299. templatee.name = "合计";
  2300. templatee.number =0;
  2301. model.overdue.Add(templatee);
  2302. if (modlelist.Count > 0)
  2303. {
  2304. foreach (var it in modlelist)
  2305. {
  2306. var itemList = itembll.GetModelList(" F_WoID=" + it.F_ID + "and F_WoState=1" + " order by F_ID desc");
  2307. if (itemList.Count > 0)
  2308. {
  2309. if (itemList[0].F_NextDept > 0)
  2310. {
  2311. var deptmodel = departmentBLL.GetModel(int.Parse(itemList[0].F_NextDept.ToString()));
  2312. if (model.overdue.Count > 0)
  2313. {
  2314. int overdue = 0;
  2315. foreach (var im in model.overdue)
  2316. {
  2317. if (im.name == deptmodel.F_DeptName)
  2318. {
  2319. im.number += 1;
  2320. overdue = 1;
  2321. }
  2322. if (im .name =="合计")
  2323. {
  2324. im.number += 1;
  2325. }
  2326. }
  2327. if (overdue == 0)
  2328. {
  2329. Template templates = new Template();
  2330. templates.name = deptmodel.F_DeptName;
  2331. templates.number = 1;
  2332. model.overdue.Add(templates);
  2333. }
  2334. }
  2335. else
  2336. {
  2337. Template templates = new Template();
  2338. templates.name = deptmodel.F_DeptName;
  2339. templates.number = 1;
  2340. model.overdue.Add(templates);
  2341. }
  2342. }
  2343. }
  2344. }
  2345. }
  2346. if (model.overdue.Count > 0)
  2347. {
  2348. foreach (var it in model.overdue)
  2349. {
  2350. if (it .name =="合计")
  2351. {
  2352. var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth).Count ;
  2353. var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear).Count ;
  2354. it.Lastmonthnumber = lastmouthmodlel;
  2355. it.Lastyearnumber = lastyearmodlel;
  2356. it.Lastmonth = it.number - lastmouthmodlel;
  2357. it.Lastyear = it.number - lastyearmodlel;
  2358. }
  2359. else
  2360. {
  2361. var deptmodel = departmentBLL.GetModel(it.name);
  2362. var lastmouthmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastmouth);
  2363. int lastmouthlist = 0;
  2364. int lastyearlist = 0;
  2365. if (lastmouthmodlel.Count > 0)
  2366. {
  2367. foreach (var im in lastmouthmodlel)
  2368. {
  2369. var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
  2370. if (itemList.Count > 0)
  2371. {
  2372. lastmouthlist++;
  2373. }
  2374. }
  2375. }
  2376. var lastyearmodlel = workOrder.GetModelList(sql + sqloverdue + "and F_IsOver=1" + lastyear);
  2377. if (lastyearmodlel.Count > 0)
  2378. {
  2379. foreach (var im in lastyearmodlel)
  2380. {
  2381. var itemList = itembll.GetModelList(" F_WoID=" + im.F_ID + "and F_WoState=1" + "and F_NextDept=" + deptmodel.F_DeptId + " order by F_ID desc");
  2382. if (itemList.Count > 0)
  2383. {
  2384. lastyearlist++;
  2385. }
  2386. }
  2387. }
  2388. it.Lastmonthnumber = lastmouthlist;
  2389. it.Lastyearnumber = lastyearlist;
  2390. it.Lastmonth = it.number - lastmouthlist;
  2391. it.Lastyear = it.number - lastyearlist;
  2392. }
  2393. }
  2394. }
  2395. if (model.overdue.Count > 0)
  2396. {
  2397. for (int j = 0; j < model.overdue.Count - 1; j++)
  2398. {
  2399. for (int z = 0; z < model.overdue.Count - 1 - j; z++)
  2400. {
  2401. if (model.overdue[z].number < model.overdue[z + 1].number)
  2402. {
  2403. var temp = model.overdue[z + 1];
  2404. model.overdue[z + 1] = model.overdue[z];
  2405. model.overdue[z] = temp;
  2406. }
  2407. }
  2408. }
  2409. }
  2410. #endregion
  2411. var obj = new
  2412. {
  2413. state = "success",
  2414. message = "成功",
  2415. rows = model,
  2416. total = 6
  2417. };
  2418. return Content(obj.ToJson()); ;
  2419. }
  2420. private bool Refresh()
  2421. {
  2422. int type = 0;
  2423. var modlelist = workOrder.GetModelList(" F_IsDelete=0" + "and F_IsOver=0" + " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," +
  2424. (int)EnumWorkOrderState.assign + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ")");
  2425. if (modlelist.Count > 0)
  2426. {
  2427. foreach (var it in modlelist)
  2428. {
  2429. if (TimeforOver(it.F_ID))
  2430. {
  2431. type = 0;
  2432. }
  2433. else
  2434. {
  2435. type = 1;
  2436. }
  2437. if (type != it.F_IsOver)
  2438. {
  2439. it.F_IsOver = type;
  2440. bool n = workOrder.Update(it);
  2441. if (!n)
  2442. {
  2443. return false;
  2444. }
  2445. }
  2446. }
  2447. }
  2448. return true;
  2449. }
  2450. /// <summary>
  2451. /// 是否超时
  2452. /// </summary>
  2453. /// <param name="id"></param>
  2454. /// <returns></returns>
  2455. private bool TimeforOver(int id)
  2456. {
  2457. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + " ");
  2458. string time1 = "", time2 = ""; int x = 0, y = 0;
  2459. float time = 0;
  2460. if (itemlasts.Count > 0)
  2461. {
  2462. for (int i = 0; i < itemlasts.Count; i++)
  2463. {
  2464. if (itemlasts[i].F_WoState >= 1)
  2465. {
  2466. if (itemlasts[i].F_WoState == 1)
  2467. {
  2468. x = i;
  2469. time1 = itemlasts[i].F_CreateTime.ToString();
  2470. time = float.Parse(itemlasts[i].F_LimitTime);
  2471. }
  2472. if (itemlasts[i].F_WoState == 10)
  2473. {
  2474. y = i;
  2475. time2 = itemlasts[i].F_CreateTime.ToString();
  2476. }
  2477. }
  2478. }
  2479. if (time2 != "")
  2480. {
  2481. if (time1 != "")
  2482. {
  2483. if (x > y)
  2484. {
  2485. int a = (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours;
  2486. if (a > time)
  2487. {
  2488. return false;
  2489. }
  2490. }
  2491. else
  2492. {
  2493. int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  2494. if (a > time)
  2495. {
  2496. return false;
  2497. }
  2498. }
  2499. }
  2500. else
  2501. {
  2502. return true;
  2503. }
  2504. }
  2505. else if (time1 != "")
  2506. {
  2507. int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  2508. if (a > time)
  2509. {
  2510. return false;
  2511. }
  2512. }
  2513. else
  2514. {
  2515. return true;
  2516. }
  2517. }
  2518. else
  2519. {
  2520. return true;
  2521. }
  2522. return true;
  2523. }
  2524. public Template ReturenTemplate(Template template,string sql,string time,string lastmouth,string lastyear )
  2525. {
  2526. template.number = new BLL.T_Wo_WorkOrder().GetModelList(sql + time).Count;//
  2527. int mounthnumber = 0, yearnumber = 0;
  2528. mounthnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastmouth).Count;//
  2529. yearnumber = new BLL.T_Wo_WorkOrder().GetModelList(sql + lastyear).Count;//
  2530. template.Lastmonthnumber = mounthnumber;
  2531. template.Lastyearnumber = yearnumber;
  2532. template.Lastmonth = template.number - mounthnumber;
  2533. template.Lastyear = template.number - yearnumber;
  2534. return template;
  2535. }
  2536. /// <summary>
  2537. /// 市场反馈一览表
  2538. /// </summary>
  2539. /// <returns></returns>
  2540. public ActionResult GetFeedbacklList()
  2541. {
  2542. string sql = $" F_IsDelete=0";
  2543. DataTable dt = new DataTable();
  2544. #region 筛选条件
  2545. List<Feedback> modelList = new List<Feedback>(5);
  2546. string smonthtime = DateTime.Now.Date.ToString("yyyy-MM-01 00:00:00");
  2547. string sdaytime = DateTime.Now.Date.ToString("yyyy-MM-dd 00:00:00");
  2548. string endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2549. for (int i = 1; i <= 5; i++)
  2550. {
  2551. Feedback model = new Feedback();
  2552. switch (i)
  2553. {
  2554. case 1:
  2555. model.name = "咨询";
  2556. break;
  2557. case 2:
  2558. model.name = "投诉";
  2559. break;
  2560. case 3:
  2561. model.name = "抽检";
  2562. break;
  2563. case 4:
  2564. model.name = "建议";
  2565. break;
  2566. case 5:
  2567. model.name = "合计";
  2568. break;
  2569. }
  2570. float a= workOrder.GetModelList(sql ).Count;
  2571. if (i <5)
  2572. {
  2573. model .daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i ).Count;
  2574. model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " + "and F_Type=" + i).Count;
  2575. model.Totalnumber = workOrder.GetModelList(sql + "and F_Type=" + i).Count;
  2576. model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a*100);
  2577. }
  2578. else
  2579. {
  2580. model.daynumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{sdaytime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 " ).Count;
  2581. model.mounthnumber = workOrder.GetModelList(sql + $" and datediff(day,F_CreateOn,'{smonthtime}')<=0 and datediff(day,F_CreateOn,'{endtime}')>=0 ").Count;
  2582. model.Totalnumber = workOrder.GetModelList(sql).Count;
  2583. model.Proportion = string.Format("{0:f2}%", model.Totalnumber / a * 100);
  2584. }
  2585. modelList.Add(model);
  2586. }
  2587. #endregion
  2588. var obj = new
  2589. {
  2590. state = "success",
  2591. message = "成功",
  2592. rows = modelList,
  2593. total = 4
  2594. };
  2595. return Content(obj.ToJson()); ;
  2596. }
  2597. /// <summary>
  2598. /// 渠道数量对比表
  2599. /// </summary>
  2600. /// <param name="stime"></param>
  2601. /// <param name="endtime"></param>
  2602. /// <returns></returns>
  2603. public ActionResult GetChanelList(string stime, string endtime)
  2604. {
  2605. string sql = $" and F_IsDelete=0";
  2606. DataTable dt = new DataTable();
  2607. #region 筛选条件
  2608. if (stime != null && stime.Trim() != "")
  2609. {
  2610. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  2611. }
  2612. if (endtime != null && endtime.Trim() != "")
  2613. {
  2614. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  2615. }
  2616. #endregion
  2617. List<string> channelname = new List<string>();
  2618. channelname.Add("总经销");
  2619. channelname.Add("二级商");
  2620. channelname.Add("种田大户");
  2621. channelname.Add("公司员工");
  2622. channelname.Add("农户");
  2623. channelname.Add("化工客户");
  2624. channelname.Add("其他");
  2625. int Distribution = 0, Quotient=0, Bigfarmer = 0, Companystaf = 0, Peasant = 0, Customers = 0, Other = 0;
  2626. for (int i=0;i < channelname.Count;i++)
  2627. {
  2628. string msg = "'" +channelname[i] + "'";
  2629. var modellist = woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(msg) + ")" + sql + "and F_Type in (2,3)");
  2630. var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(msg) + ")" + sql + "and F_Type in (1,4)");
  2631. switch (i )
  2632. {
  2633. case 0:
  2634. Distribution = modellist.Count + modellis.Count;//总经销
  2635. break;
  2636. case 1:
  2637. Quotient = modellist.Count + modellis.Count;//二级商
  2638. break;
  2639. case 2:
  2640. Bigfarmer = modellist.Count + modellis.Count;//种田大户
  2641. break;
  2642. case 3:
  2643. Companystaf = modellist.Count + modellis.Count;//公司员工
  2644. break;
  2645. case 4:
  2646. Peasant = modellist.Count + modellis.Count;//农户
  2647. break;
  2648. case 5:
  2649. Customers = modellist.Count + modellis.Count;//化工客户
  2650. break;
  2651. case 6:
  2652. Other = modellist.Count + modellis.Count;//其他
  2653. break;
  2654. }
  2655. }
  2656. var obj = new
  2657. {
  2658. state = "success",
  2659. message = "成功",
  2660. rows=new
  2661. {
  2662. Distribution,
  2663. Quotient,
  2664. Bigfarmer,
  2665. Companystaf,
  2666. Peasant,
  2667. Customers,
  2668. Other,
  2669. }
  2670. ,
  2671. total =6
  2672. };
  2673. return Content(obj.ToJson()); ;
  2674. }
  2675. BLL.T_Sys_DictionaryValue dicvalueBll = new BLL.T_Sys_DictionaryValue();
  2676. public class Brand
  2677. {
  2678. public string name;
  2679. public int number;
  2680. }
  2681. /// <summary>
  2682. /// 产品品牌对照表
  2683. /// </summary>
  2684. /// <param name="stime"></param>
  2685. /// <param name="endtime"></param>
  2686. /// <returns></returns>
  2687. public ActionResult GetbrandList(string stime, string endtime)
  2688. {
  2689. string sql = $" and F_IsDelete=0";
  2690. DataTable dt = new DataTable();
  2691. #region 筛选条件
  2692. if (stime != null && stime.Trim() != "")
  2693. {
  2694. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  2695. }
  2696. if (endtime != null && endtime.Trim() != "")
  2697. {
  2698. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  2699. }
  2700. #endregion
  2701. var dicv = dicvalueBll.GetList(" F_DictionaryFlag='" + "ZXCPMC" + "' and F_State=1 ").Tables[0];
  2702. List<Brand> list = new List<Brand>();
  2703. List<Model.T_Sys_DictionaryValue> dicval = new List<Model.T_Sys_DictionaryValue>();
  2704. if (dicv !=null )
  2705. {
  2706. dicval = dicvalueBll.DataTableToList(dicv);
  2707. }
  2708. if (dicval !=null&& dicval.Count >0)
  2709. {
  2710. foreach (var it in dicval)
  2711. {
  2712. var modellist = woBLL.GetModelList(" F_TS_Category in ('" + it.F_Name + "')" + sql );
  2713. Brand brand = new Brand();
  2714. brand.name = it.F_Name;
  2715. brand.number = modellist.Count;
  2716. list.Add(brand);
  2717. }
  2718. }
  2719. var obj = new
  2720. {
  2721. state = "success",
  2722. message = "成功",
  2723. rows = list
  2724. ,
  2725. total = list.Count ,
  2726. };
  2727. return Content(obj.ToJson()); ;
  2728. }
  2729. public class QuestionType
  2730. {
  2731. public string F_QuestionType;
  2732. public int number;
  2733. }
  2734. /// <summary>
  2735. ///月份投诉处理周期表
  2736. /// </summary>
  2737. /// <returns></returns>
  2738. public ActionResult GetComplainthandlList(string product,string salesBase,string stime ="", string endtime="", string questionName = "" )
  2739. {
  2740. string sql = $" F_IsDelete=0";
  2741. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  2742. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  2743. if (!string.IsNullOrWhiteSpace(product))//产品
  2744. sql += $" and F_TS_Category='" + product.Trim() + "'";
  2745. string Queststr = "";
  2746. if (questionName!="")
  2747. {
  2748. Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 and F_Label in(3) and F_QuestionName='" + questionName+"'";
  2749. }
  2750. else
  2751. {
  2752. Queststr = " select * from T_Wo_QuestionManage where F_IsDelete=0 AND F_Label in(3)";
  2753. }
  2754. DataTable QuestionManage = DbHelperSQL.Query(Queststr).Tables[0];
  2755. List<Model.T_Wo_QuestionManage> categorylist = quesBLL.DataTableToList(QuestionManage);
  2756. List<Complainthandling> modeNamelList = new List<Complainthandling>(categorylist.Count);
  2757. string time = "";
  2758. if (stime == "")
  2759. {
  2760. stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
  2761. }
  2762. if (endtime == "")
  2763. {
  2764. endtime = DateTime.Now.ToString("yyyy-MM-dd");
  2765. }
  2766. List<Complainthandling> modelList = new List<Complainthandling>(categorylist.Count);
  2767. for (int i = 0; i < categorylist.Count; i++)
  2768. {
  2769. Complainthandling model = new Complainthandling();
  2770. model.name = categorylist[i].F_QuestionName;
  2771. string strnumber = " select F_QuestionType,count(F_QuestionType) number from T_Wo_WorkOrder where" + sql+"and F_QuestionType= '" + categorylist[i].F_Id +"'" +
  2772. "group by F_QuestionType order by count(F_QuestionType) desc";
  2773. DataTable QuestionType = DbHelperSQL.Query(strnumber).Tables[0];
  2774. List<QuestionType> QuestionTypelists = DataTableToList(QuestionType);
  2775. if (QuestionTypelists.Count >0)
  2776. {
  2777. model.number = QuestionTypelists[0].number;
  2778. }
  2779. else
  2780. {
  2781. model.number = 0;
  2782. }
  2783. string msg = "select F_QuestionType,datediff(HH ,F_CreateOn,F_DealTime) number from T_Wo_WorkOrder where " + sql + time + "and F_QuestionType =" + "'" + categorylist[i].F_Id + "'" + "ORDER BY number ";
  2784. DataTable dtxy = DbHelperSQL.Query(msg).Tables[0];
  2785. List<QuestionType> QuestionTypes = DataTableToList(dtxy);
  2786. float average = 0;
  2787. int med = QuestionTypes.Count / 2;
  2788. if (QuestionTypes.Count>0)
  2789. {
  2790. for (int j = 0; j < QuestionTypes.Count; j++)
  2791. {
  2792. if(QuestionTypes.Count==1)
  2793. {
  2794. model.minimumtime = QuestionTypes[j].number.ToString();
  2795. model.ongesttime = QuestionTypes[j].number.ToString();
  2796. model.median = QuestionTypes[j].number.ToString();
  2797. }
  2798. else
  2799. {
  2800. if (j == 0)
  2801. {
  2802. model.minimumtime = QuestionTypes[j].number.ToString();
  2803. }
  2804. else if (j == QuestionTypes.Count - 1)
  2805. {
  2806. model.ongesttime = QuestionTypes[j].number.ToString();
  2807. }
  2808. else if (j == med)
  2809. {
  2810. model.median = QuestionTypes[j].number.ToString();
  2811. }
  2812. }
  2813. average += QuestionTypes[j].number;
  2814. }
  2815. }
  2816. else
  2817. {
  2818. model.minimumtime = "0";
  2819. model.ongesttime = "0";
  2820. model.median = "0";
  2821. }
  2822. float ave = average / QuestionTypes.Count;
  2823. if (float.IsNaN(ave))
  2824. {
  2825. ave = 0;
  2826. }
  2827. model.averageTime = string.Format("{0:f2}", ave);
  2828. string Over = "select F_QuestionType,count(F_IsOver) number from T_Wo_WorkOrder where " + sql +
  2829. "and F_QuestionType ='" + categorylist[i].F_Id + "'" + time + "group by F_QuestionType order by count(F_IsOver) desc";
  2830. DataTable Overdtxy = DbHelperSQL.Query(Over).Tables[0];
  2831. List<QuestionType> Overdue = DataTableToList(Overdtxy);
  2832. if (Overdue.Count >0)
  2833. {
  2834. model.Overdue = Overdue[0].number.ToString();
  2835. }
  2836. else
  2837. {
  2838. model.Overdue ="0";
  2839. }
  2840. int year = DateTime.Now.Year;//当前年
  2841. int mouth = DateTime.Now.Month;//当前月
  2842. if (stime != "")
  2843. {
  2844. year = DateTime.Parse(stime).Year;
  2845. mouth = DateTime.Parse(stime).Month;
  2846. }
  2847. int beforeYear = 0;
  2848. int beforeMouth = 0;
  2849. if (mouth <= 1)//如果当前月是一月,那么年份就要减1
  2850. {
  2851. beforeYear = year - 1;
  2852. beforeMouth = 12;//上个月
  2853. }
  2854. else
  2855. {
  2856. beforeYear = year;
  2857. beforeMouth = mouth - 1;//上个月
  2858. }
  2859. string beforeMouthOneDay = beforeYear + "年" + beforeMouth + "月" + 1 + "日";//上个月第一天
  2860. string beforeMouthLastDay = beforeYear + "年" + beforeMouth + "月" + DateTime.DaysInMonth(year, beforeMouth) + "日";//上个月最后一天
  2861. string time1 = DateTime.Parse(beforeMouthOneDay).ToString("yyyy-MM-dd");
  2862. string time2 = DateTime.Parse(beforeMouthLastDay).ToString("yyyy-MM-dd");
  2863. string times = "";
  2864. times += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + time1.Trim() + " 00:00:01', 120) ";
  2865. times += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + time2.Trim() + " 23:59:59', 120) ";
  2866. string msgs = "select F_QuestionType,datediff(HH ,F_CreateOn,F_DealTime) number from T_Wo_WorkOrder where " + sql + times + "and F_QuestionType =" + "'" + categorylist[i].F_Id + "'" + "ORDER BY number ";
  2867. DataTable dtxys = DbHelperSQL.Query(msgs).Tables[0];
  2868. List<QuestionType> Questionmonth = DataTableToList(dtxys);
  2869. float efficien = 0;
  2870. for (int j = 0; j < Questionmonth.Count; j++)
  2871. {
  2872. efficien += Questionmonth[j].number;
  2873. }
  2874. float eff = efficien / Questionmonth.Count;
  2875. float Percentile = (ave - eff) / eff * 100;
  2876. if (float .IsNaN (Percentile) )
  2877. {
  2878. Percentile = 0;
  2879. }
  2880. model.efficiency = string.Format("-{0:f2}% ", Percentile);
  2881. modelList.Add(model);
  2882. }
  2883. modelList.Sort((a, b) => b .number .CompareTo(a .number ));
  2884. var obj = new
  2885. {
  2886. state = "success",
  2887. message = "成功",
  2888. rows = modelList,
  2889. total = modelList.Count
  2890. };
  2891. return Content(obj.ToJson()); ;
  2892. }
  2893. public class People
  2894. {
  2895. public string name { get; set; }
  2896. public int age { get; set; }
  2897. public string sex { get; set; }
  2898. }
  2899. /// <summary>
  2900. /// 渠道来源数据分析表
  2901. /// </summary>
  2902. /// <returns></returns>
  2903. public ActionResult GetChannel(string channel="")
  2904. {
  2905. string sql = $" and F_IsDelete=0";
  2906. sql += "and F_State=" + (int)EnumWorkOrderState.evaluate;
  2907. DataTable dt = new DataTable();
  2908. #region 筛选条件
  2909. List<Channel> modelList = new List<Channel> ();
  2910. List<string> channelname = new List<string>();
  2911. if (channel != "")
  2912. {
  2913. channelname.Add(channel);
  2914. }
  2915. else
  2916. {
  2917. channelname.Add("总经销");
  2918. channelname.Add("二级商");
  2919. channelname.Add("种田大户");
  2920. channelname.Add("公司员工");
  2921. channelname.Add("其他公众");
  2922. }
  2923. for (int i = 0; i <channelname.Count ; i++)
  2924. {
  2925. Channel model = new Channel();
  2926. model.channel = channelname[i ];
  2927. string changel = "";
  2928. if (channelname[i ]!= "其他公众")
  2929. {
  2930. changel ="'"+ model.channel.Trim()+"'";
  2931. }
  2932. else
  2933. {
  2934. changel = "'农户','化工客户','其他'";
  2935. }
  2936. string msg = "";
  2937. var modellist= woBLL.GetModelList(" F_CustomerID in (" + GetCustomer(changel) + ")" + sql+ "and F_Type in (2,3)");
  2938. var modellis = woBLL.GetModelList(" F_CusPhone in (" + GetCustomerrel(changel) + ")" + sql + "and F_Type in (1,4)");
  2939. int phone = 0, Chat = 0, diate=0, Trans=0, Satis=0, Unsatis= 0,Verysatisfied=0, Commonly=0;
  2940. foreach (var it in modellist)
  2941. {
  2942. if (it .F_Source =="1")
  2943. phone ++;
  2944. if (it.F_Source == "2" || it.F_Source == "3")
  2945. Chat++;
  2946. if (it.F_DealType == "当即办理")
  2947. diate++;
  2948. if (it.F_DealType == "电话转接")
  2949. Trans++;
  2950. if ( it.F_VisitResult == "非常满意")
  2951. Verysatisfied++;
  2952. if (it.F_VisitResult == "满意")
  2953. Satis++;
  2954. if (it.F_VisitResult == "一般")
  2955. Commonly++;
  2956. if ( it.F_VisitResult == "不满意")
  2957. Unsatis++;
  2958. }
  2959. foreach (var it in modellis)
  2960. {
  2961. if (it.F_Source == "1")
  2962. phone++;
  2963. if (it.F_Source == "2" || it.F_Source == "3")
  2964. Chat++;
  2965. if (it.F_DealType == "当即办理")
  2966. diate++;
  2967. if (it.F_DealType == "电话转接")
  2968. Trans++;
  2969. if (it.F_VisitResult == "非常满意")
  2970. Verysatisfied++;
  2971. if (it.F_VisitResult == "满意")
  2972. Satis++;
  2973. if (it.F_VisitResult == "一般")
  2974. Commonly++;
  2975. if (it.F_VisitResult == "不满意")
  2976. Unsatis++;
  2977. }
  2978. model.Telephone = phone;
  2979. model.WeChat = Chat;
  2980. model.Immediate = diate;
  2981. model.Transfer = Trans;
  2982. model.Verysatisfied = Verysatisfied;
  2983. model.Commonly = Commonly;
  2984. model.Total = modellist.Count;
  2985. model.Satisfaction = Satis;
  2986. model.Unsatisfactory = Unsatis;
  2987. modelList.Add(model);
  2988. }
  2989. #endregion
  2990. var obj = new
  2991. {
  2992. state = "success",
  2993. message = "成功",
  2994. rows = modelList,
  2995. total = modelList.Count
  2996. };
  2997. return Content(obj.ToJson()); ;
  2998. }
  2999. /// <summary>
  3000. /// 大数据区域表
  3001. /// </summary>
  3002. /// <returns></returns>
  3003. public ActionResult GetRegionList(string stime, string endtime, string salesBase, string channel, int type = 0, int page = 1, int limit = 10)
  3004. {
  3005. string sql = $" and F_IsDelete=0";
  3006. DataTable dt = new DataTable();
  3007. #region 筛选条件
  3008. if (type > 0 && type < 5)//工单类型
  3009. sql += $" and F_Type=" + type;
  3010. if (stime != null && stime.Trim() != "")
  3011. {
  3012. sql += " and CONVERT(varchar , F_CreateOn, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  3013. }
  3014. if (endtime != null && endtime.Trim() != "")
  3015. {
  3016. sql += " and CONVERT(varchar , F_CreateOn, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  3017. }
  3018. if (!string.IsNullOrWhiteSpace(salesBase))//销售基地
  3019. sql += $" and F_SalesBase like '%" + salesBase.Trim() + "%'";
  3020. if (!string.IsNullOrWhiteSpace(channel))
  3021. {
  3022. sql += $" and T_Wo_WorkOrder.F_CustomerID in ( " + GetCustomerID(channel) + ") "; ;
  3023. }
  3024. sql += $" and T_Wo_WorkOrder.F_State in ( " + (int)EnumWorkOrderState.finish + "," + (int)EnumWorkOrderState.evaluate + ") "; ;
  3025. #endregion
  3026. int recordCount = 0;
  3027. if (!string.IsNullOrWhiteSpace(sql))
  3028. {
  3029. dt = BLL.PagerBLL.GetListPager(
  3030. "T_Wo_WorkOrder",
  3031. "F_ID",
  3032. "*",
  3033. sql,
  3034. "ORDER BY T_Wo_WorkOrder.F_ID desc",
  3035. limit,
  3036. page,
  3037. true,
  3038. out recordCount);
  3039. }
  3040. List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
  3041. if (modlelist.Count > 0)
  3042. {
  3043. List<Questions> input = modeltooip(modlelist);
  3044. var obj = new
  3045. {
  3046. state = "success",
  3047. message = "成功",
  3048. rows = input,
  3049. total = recordCount
  3050. };
  3051. return Content(obj.ToJson()); ;
  3052. }
  3053. else
  3054. {
  3055. return Success("暂无工单"); ;
  3056. }
  3057. }
  3058. public string GetCustomer(string msg)
  3059. {
  3060. string str = "";
  3061. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg+")";
  3062. return str;
  3063. }
  3064. public string GetCustomerrel(string msg)
  3065. {
  3066. string str = "";
  3067. str = "select F_LegalPhone from T_Cus_CustomerBaseNew where F_IsDelete=0" + " and F_Channel in(" + msg + ")";
  3068. return str;
  3069. }
  3070. private string ChannelType(string msg)
  3071. {
  3072. string mag = "";
  3073. DataTable dtxy = DbHelperSQL.Query(msg).Tables[0];
  3074. mag = dtxy.Rows.Count.ToString();
  3075. return mag;
  3076. }
  3077. /// <summary>
  3078. /// 验证物料编码为10位纯数字
  3079. /// </summary>
  3080. private bool valcode(string code, int number)
  3081. {
  3082. var res = false;
  3083. //11位数字
  3084. if (code.Length == number && Regex.IsMatch(code, @"^\d{" + number + "}$"))
  3085. res = true;
  3086. return res;
  3087. }
  3088. /// <summary>
  3089. /// 根据model返回Prescription对象
  3090. /// </summary>
  3091. private List<Prescription> modelPrescription(List<Model.T_Wo_WorkOrder> model1)
  3092. {
  3093. int userId = CurrentUser.UserData.F_UserId;
  3094. if (model1 != null && model1.Count > 0)
  3095. {
  3096. List<Prescription> Input = new List<Prescription>(model1.Count);
  3097. for (int i = 0; i < model1.Count; i++)
  3098. {
  3099. Prescription model = new Prescription();
  3100. if (!string .IsNullOrEmpty (model1[i].F_CustomerID))
  3101. {
  3102. if (valcode(model1[i].F_CustomerID, 10))//验证客户编码为10位纯数字
  3103. {
  3104. Model.T_Cus_CustomerBaseNew cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3105. if (cuModel != null)
  3106. {
  3107. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3108. if (pdModel != null)
  3109. {
  3110. model.AreaName = pdModel.F_DeptName;//大区名称
  3111. }
  3112. Model.T_Sys_Department pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);
  3113. if (pdModel1 != null)
  3114. {
  3115. model.BranchName = pdModel1.F_DeptName;//大区名称
  3116. }
  3117. model.Brands = cuModel.F_Brands;//品牌
  3118. }
  3119. }
  3120. }
  3121. if (!string.IsNullOrEmpty(model1[i].F_QuestionType))
  3122. {
  3123. Model.T_Wo_QuestionManage Manage = null;
  3124. try
  3125. {
  3126. int b = int.Parse(model1[i].F_QuestionType.Trim());
  3127. Manage = quesBLL.GetModel(b);
  3128. }
  3129. catch (Exception)
  3130. {
  3131. Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  3132. }
  3133. if (Manage != null)
  3134. {
  3135. if (Manage.F_Label == "1")
  3136. {
  3137. model.QuestionTypeone = Manage.F_QuestionName;
  3138. model.QuestionTypetwo = "";
  3139. model.QuestionTypethree = "";
  3140. }
  3141. else if (Manage.F_Label == "2")
  3142. {
  3143. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  3144. model.QuestionTypeone = Manage1.F_QuestionName;
  3145. model.QuestionTypetwo = Manage.F_QuestionName;
  3146. model.QuestionTypethree = "";
  3147. }
  3148. else
  3149. {
  3150. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  3151. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  3152. model.QuestionTypeone = Manage2.F_QuestionName;//问题类别1
  3153. model.QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
  3154. model.QuestionTypethree = Manage.F_QuestionName;//问题类别3
  3155. }
  3156. }
  3157. }
  3158. model.ProductBase = model1[i].F_SC_ProductBase;//生产基地
  3159. model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//责任科室
  3160. model.Description = model1[i].F_Description;//问题描述
  3161. model.Category = model1[i].F_TS_Category;//产品
  3162. model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  3163. model.CreatOn = model1[i].F_CreateOn.ToString();//时间
  3164. Input.Add(model);
  3165. }
  3166. return Input;
  3167. }
  3168. else
  3169. {
  3170. return null;
  3171. }
  3172. }
  3173. /// <summary>
  3174. /// 根据model返回Questions对象
  3175. /// </summary>
  3176. private List<Questions> modeltooip(List<Model.T_Wo_WorkOrder> model1)
  3177. {
  3178. int userId = CurrentUser.UserData.F_UserId;
  3179. if (model1 != null && model1.Count > 0)
  3180. {
  3181. List<Questions> Input = new List<Questions>(model1.Count);
  3182. for (int i = 0; i < model1.Count; i++)
  3183. {
  3184. Questions model = new Questions();
  3185. if (!string .IsNullOrEmpty (model1[i].F_CustomerID))
  3186. {
  3187. if (valcode(model1[i].F_CustomerID, 10))//验证客户编码为10位纯数字
  3188. {
  3189. Model.T_Cus_CustomerBaseNew cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3190. if (cuModel != null)
  3191. {
  3192. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3193. if (pdModel != null)
  3194. {
  3195. model.AreaName = pdModel.F_DeptName;
  3196. }
  3197. Model.T_Sys_Department pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);
  3198. if (pdModel1 != null)
  3199. {
  3200. model.BranchName = pdModel1.F_DeptName;
  3201. }
  3202. model.Salesman = cuModel.F_Salesman;
  3203. model.Brands = cuModel.F_Brands;
  3204. model.Channel = cuModel.F_Channel;
  3205. }
  3206. }
  3207. }
  3208. model .Category = model1[i].F_TS_Category ;
  3209. if (model1[i].F_Type == "1")
  3210. {
  3211. model.Type = "咨询";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3212. }
  3213. else if (model1[i].F_Type == "2")
  3214. {
  3215. model.Type = "投诉";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3216. }
  3217. else if (model1[i].F_Type == "3")
  3218. {
  3219. model.Type = "抽检";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3220. }
  3221. else
  3222. {
  3223. model.Type = "建议及其他";//工单类型:咨询及需求、投诉、抽检、其他(其它手动输入别的点选)
  3224. }
  3225. model.SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  3226. model.CreatOn = model1[i].F_CreateOn .ToString ();
  3227. if (TimeToOver(model1[i].F_ID, model1[i].F_limit) <0)
  3228. model.Overtime = Math .Abs(TimeToOver(model1[i].F_ID, model1[i].F_limit)).ToString ();
  3229. else
  3230. model.Overtime = "0";
  3231. if (model1[i].F_State == 11 && model1[i].F_IsVisit == 1)
  3232. model.Isvisit = "是";
  3233. else
  3234. model.Isvisit = "否";
  3235. if (model1[i].F_State == 11)
  3236. model.IsClose = "是";
  3237. else
  3238. model.IsClose = "否";
  3239. Input.Add(model);
  3240. }
  3241. return Input;
  3242. }
  3243. else
  3244. {
  3245. return null;
  3246. }
  3247. }
  3248. /// <summary>
  3249. /// 根据model返回WorkOrderComplaint对象
  3250. /// </summary>
  3251. private List<WorkOrderComplaint> modelComplaint(List<Model.T_Wo_WorkOrder> model1)
  3252. {
  3253. if (model1 != null && model1.Count > 0)
  3254. {
  3255. List<WorkOrderComplaint> Input = new List<WorkOrderComplaint>(model1.Count);
  3256. for (int i = 0; i < model1.Count; i++)
  3257. {
  3258. WorkOrderComplaint model = new WorkOrderComplaint();
  3259. if (!string .IsNullOrEmpty (model1[i].F_CustomerID))
  3260. {
  3261. if (valcode(model1[i].F_CustomerID, 10))//验证客户编码为10位纯数字
  3262. {
  3263. model.F_CustomerID = model1[i].F_CustomerID;//客户编码
  3264. Model.T_Cus_CustomerBaseNew cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3265. if (cuModel != null)
  3266. {
  3267. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3268. if (pdModel != null)
  3269. {
  3270. model.F_AreaName = pdModel.F_DeptName;//大区名称
  3271. }
  3272. Model.T_Sys_Department pdModel1 = departmentBLL.GetModel(cuModel.F_BranchID);
  3273. if (pdModel1 != null)
  3274. {
  3275. model.F_BranchName = pdModel1.F_DeptName;//分公司名称
  3276. }
  3277. model.F_Salesman = cuModel.F_Salesman;//业务员
  3278. }
  3279. }
  3280. }
  3281. if (!string .IsNullOrEmpty (model1[i].F_MaterialID))
  3282. {
  3283. if (valcode(model1[i].F_MaterialID, 11))
  3284. {
  3285. model.F_MaterialID =model1[i].F_MaterialID;//验证物料编码为11位纯数字
  3286. Model.T_Wo_MaterialManage maModel = mmBLL.GetModel(model1[i].F_MaterialID);//通过物料编码获取物料信息
  3287. if (maModel != null)
  3288. {
  3289. model.F_MaterialName = maModel.F_MaterialName;//物料名称
  3290. model.F_Model = maModel.F_Model;//型号
  3291. model.F_Specs = maModel.F_Specs;//规格
  3292. model.F_Level1 = maModel.F_Level1;//一级分类
  3293. model.F_Level2 = maModel.F_Level2;//二级分类
  3294. model.F_Level3 = maModel.F_Level3;//三级分类
  3295. model.F_Brand = maModel.F_Brand;//品牌
  3296. model.F_MaterialEffect = maModel.F_MaterialEffect;//F_MaterialEffect
  3297. model.F_Pipeline = maModel.F_Pipeline;//F_Pipeline
  3298. model.F_Craft = maModel.F_Craft;//F_Craft
  3299. }
  3300. }
  3301. }
  3302. if (!string .IsNullOrEmpty(model1[i].F_QuestionType))
  3303. {
  3304. Model.T_Wo_QuestionManage Manage = null;
  3305. try
  3306. {
  3307. int b = int.Parse(model1[i].F_QuestionType.Trim());
  3308. Manage = quesBLL.GetModel(b);
  3309. }
  3310. catch (Exception)
  3311. {
  3312. Manage = quesBLL.GetModel(model1[i].F_QuestionType); //问题类别(投诉抽捡和咨询类别不一样)
  3313. }
  3314. if (Manage !=null )
  3315. {
  3316. if (Manage .F_Label =="1")
  3317. {
  3318. model.F_QuestionTypeone = Manage.F_QuestionName;
  3319. model.F_QuestionTypetwo = "";
  3320. model.F_QuestionTypethree ="";
  3321. }
  3322. else if (Manage.F_Label == "2")
  3323. {
  3324. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int .Parse (Manage.F_ParentId.ToString () ) );//获取问题类别
  3325. model.F_QuestionTypeone = Manage1.F_QuestionName;
  3326. model.F_QuestionTypetwo = Manage.F_QuestionName;
  3327. model.F_QuestionTypethree = "";
  3328. }
  3329. else
  3330. {
  3331. Model.T_Wo_QuestionManage Manage1 = quesBLL.GetModel(int.Parse(Manage.F_ParentId.ToString()));//获取问题类别
  3332. Model.T_Wo_QuestionManage Manage2 = quesBLL.GetModel(int.Parse(Manage1.F_ParentId.ToString()));//获取问题类别
  3333. model.F_QuestionTypeone = Manage2.F_QuestionName;//问题类别1
  3334. model.F_QuestionTypetwo = Manage1.F_QuestionName;//问题类别2
  3335. model.F_QuestionTypethree =Manage.F_QuestionName;//问题类别3
  3336. }
  3337. }
  3338. }
  3339. model.F_CusName = model1[i].F_CusName;//客户姓名
  3340. model.F_CusPhone = model1[i].F_CusPhone;//客户电话
  3341. model.F_CompanyName = model1[i].F_CompanyName;//公司名称
  3342. model.F_IncidentProvince = model1[i].F_IncidentProvince;//事发地-省
  3343. model.F_IncidentCity = model1[i].F_IncidentCity;//事发地-市
  3344. model.F_IncidentCountry = model1[i].F_IncidentCountry;//事发地-县
  3345. model.F_IncidentTownship = model1[i].F_IncidentTownship;//事发地-乡
  3346. model.F_IncidentDetailed = model1[i].F_IncidentDetailed;//事发地-详细
  3347. model.F_SalesBase = model1[i].F_SalesBase;//销售基地:新乡、新疆、九江、东北、其他(其它手动输入别的点选)
  3348. model.F_Description = model1[i].F_Description;//问题描述
  3349. model.F_BatchNumber = model1[i].F_BatchNumber;//生产批次号
  3350. model.F_TS_Quantity = model1[i].F_TS_Quantity;//投诉-问题数量(吨)
  3351. model.F_SC_ProductBase = model1[i].F_SC_ProductBase;//市场管理科-生产基地(新乡、新疆、九江、东北、贴牌、无法确定)
  3352. model.F_SC_PreliminaryOpinion = model1[i].F_SC_PreliminaryOpinion;// 市场管理科-初审意见:退货、换货、补偿、自行处理
  3353. model.F_SC_QualityMonth = model1[i].F_SC_QualityMonth;//市场管理科-超出质保期限(算法:工单创建日期-生产日期,生产日期根据生产批次号获取,单位:月)
  3354. model.F_ZL_QualityEventLevel = model1[i].F_ZL_QualityEventLevel;// 质量管理科-质量事件等级(未遂、一般、较大、重大)
  3355. model.F_ZL_ClaimAmount = model1[i].F_ZL_ClaimAmount;//质量管理科-索赔金额(单位元,对应责任单位)
  3356. model.F_ZL_ResponsibleUnit = model1[i].F_ZL_ResponsibleUnit;//质量管理科-责任单位(需列出,可选多个)
  3357. model.F_ZL_ApprovalOpinions = model1[i].F_ZL_ApprovalOpinions;// 质量管理科-审批意见(同意、不同意,若选择不同意,增加输入框输入补充内容)
  3358. model.F_ZL_ApprovalDisagree = model1[i].F_ZL_ApprovalDisagree;// 质量管理科-审批不同意意见
  3359. model.F_ZL_CompensationMethod = model1[i].F_ZL_CompensationMethod;//质量管理科-补偿方式(实物、钱款【单位元】,若选择钱款,增加输入框输入补充内容)
  3360. model.F_ZL_CompensationMoney = model1[i].F_ZL_CompensationMoney;// 质量管理科-补偿钱款
  3361. model.F_ZL_CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;//质量管理科-对应责任单位(生产、研发、农化、物流、质量管理科,销售内勤)
  3362. model.F_ZL_Fquantity = model1[i].F_ZL_Fquantity;// 质量管理科-确认实收数量(吨)
  3363. model.F_ZL_ImprovementRequirements = model1[i].F_ZL_ImprovementRequirements;//质量管理科-改进要求
  3364. model.F_ZL_CApprovalNo = model1[i].F_ZL_CApprovalNo;//质量管理科-对应审批工作流单号
  3365. model.F_DealType = model1[i].F_DealType;//处理方式:当即办理、电话转接、网络转办
  3366. model.F_DealBy = model1[i].F_DealBy;//处理人
  3367. model.F_DealTime = model1[i].F_DealTime;//处理时间
  3368. model.F_DealContent = model1[i].F_DealContent;//处理内容
  3369. model.F_DealResult = model1[i].F_DealResult;//处理结果
  3370. model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
  3371. model.F_CreateOn = model1[i].F_CreateOn; ;//添加时间
  3372. Input.Add(model);
  3373. }
  3374. return Input;
  3375. }
  3376. else
  3377. {
  3378. return null;
  3379. }
  3380. }
  3381. /// <summary>
  3382. /// 根据model返回WorkOrderComplaint对象
  3383. /// </summary>
  3384. private List<Product> modelProduct(List<Model.T_Wo_WorkOrder> model1)
  3385. {
  3386. if (model1 != null && model1.Count > 0)
  3387. {
  3388. List<Product> Input = new List<Product>(model1.Count);
  3389. for (int i = 0; i < model1.Count; i++)
  3390. {
  3391. Product model = new Product();
  3392. if (!string .IsNullOrEmpty (model1[i].F_CustomerID))
  3393. {
  3394. if (valcode(model1[i].F_CustomerID, 10))//验证客户编码为10位纯数字
  3395. {
  3396. Model.T_Cus_CustomerBaseNew cuModel = cusbll.GetModel(model1[i].F_CustomerID);//通过客户编号获取客户资料
  3397. if (cuModel != null)
  3398. {
  3399. Model.T_Sys_Department pdModel = departmentBLL.GetModel(cuModel.F_AreaID);//通过公司id获取部门
  3400. model.F_Salesman = cuModel.F_Salesman;//业务员
  3401. }
  3402. }
  3403. }
  3404. model.Category = model1[i].F_TS_Category;//产品
  3405. model.Company = model1[i].F_CompanyName;//客户单位
  3406. if (!string.IsNullOrEmpty(model1[i].F_BatchNumber))
  3407. {
  3408. var prono = model1[i].F_BatchNumber.Substring(0, 6);
  3409. try
  3410. {
  3411. var pronos = DateTime.ParseExact(prono, "yyMMdd", null).ToString("yyyy-MM-dd");
  3412. // var protime = Convert.ToDateTime(pronos);
  3413. model.ProductionTime = pronos;
  3414. }
  3415. catch
  3416. {
  3417. model.ProductionTime = "";
  3418. }
  3419. }
  3420. model.CreatOn = model1[i].F_CreateOn .ToString (); ;
  3421. model.Spurtcode = model1[i].F_BatchNumber;
  3422. Model.T_Wo_QuestionManage Manage = null;
  3423. try
  3424. {
  3425. int b = int.Parse(model1[i].F_QuestionType.Trim());
  3426. Manage = quesBLL.GetModel(b);
  3427. if (Manage !=null )
  3428. {
  3429. model.QuestionType = Manage.F_QuestionName;
  3430. }
  3431. }
  3432. catch (Exception)
  3433. {
  3434. model.QuestionType = model1[i].F_QuestionType;
  3435. }
  3436. model.Description = model1[i].F_Description;
  3437. model.DealType = model1[i].F_DealType;
  3438. model.CResponsibleUnits = model1[i].F_ZL_CResponsibleUnits;
  3439. model.SalesBase = model1[i].F_SalesBase;
  3440. Input.Add(model);
  3441. }
  3442. return Input;
  3443. }
  3444. else
  3445. {
  3446. return null;
  3447. }
  3448. }
  3449. /// <summary>
  3450. /// 是否超时
  3451. /// </summary>
  3452. /// <param name="id"></param>
  3453. /// <returns></returns>
  3454. private float TimeToOver(int id,int time)
  3455. {
  3456. var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + "order by F_ID desc ");
  3457. string time1 = "", time2 = ""; int x = 0, y = 0;
  3458. if (itemlasts.Count > 0)
  3459. {
  3460. for (int i = 0; i < itemlasts.Count; i++)
  3461. {
  3462. if (itemlasts[i].F_WoState >= 1)
  3463. {
  3464. if (itemlasts[i].F_WoState == 1)
  3465. {
  3466. x = i;
  3467. time1 = itemlasts[i].F_CreateTime.ToString();
  3468. }
  3469. if (itemlasts[i].F_WoState == 10)
  3470. {
  3471. y = i;
  3472. time2 = itemlasts[i].F_CreateTime.ToString();
  3473. }
  3474. }
  3475. }
  3476. if (time2 != "")
  3477. {
  3478. if (time1 != "")
  3479. {
  3480. if (x > y)
  3481. {
  3482. float a = (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours;
  3483. float b = time - a;
  3484. return b;
  3485. }
  3486. else
  3487. {
  3488. float a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  3489. float b = time - a;
  3490. return b;
  3491. }
  3492. }
  3493. else
  3494. {
  3495. return 0;
  3496. }
  3497. }
  3498. else if (time1 != "")
  3499. {
  3500. float a = (DateTime.Now - DateTime.Parse(time1)).Hours;
  3501. float b = time - a;
  3502. return b;
  3503. }
  3504. else
  3505. {
  3506. return 0;
  3507. }
  3508. }
  3509. return 0;
  3510. }
  3511. /// <summary>
  3512. /// 获取客户编号
  3513. /// </summary>
  3514. /// <returns></returns>
  3515. public string GetCustomerID(string channel)
  3516. {
  3517. string str = string.Empty;
  3518. str = "select F_CustomerCode from T_Cus_CustomerBaseNew where F_Channel='" + channel + "' " + " and isnull(F_IsDelete,'0')='0' "; ;
  3519. return str;
  3520. }
  3521. /// <summary>
  3522. /// 获得数据列表
  3523. /// </summary>
  3524. public List<QuestionType> DataTableToList(DataTable dt)
  3525. {
  3526. List<QuestionType> modelList = new List<QuestionType>();
  3527. int rowsCount = dt.Rows.Count;
  3528. if (rowsCount > 0)
  3529. {
  3530. QuestionType model;
  3531. for (int n = 0; n < rowsCount; n++)
  3532. {
  3533. model = DataRowToModel(dt.Rows[n]);
  3534. if (model != null)
  3535. {
  3536. modelList.Add(model);
  3537. }
  3538. }
  3539. }
  3540. return modelList;
  3541. }
  3542. /// <summary>
  3543. /// 得到一个对象实体
  3544. /// </summary>
  3545. public QuestionType DataRowToModel(DataRow row)
  3546. {
  3547. QuestionType model = new QuestionType();
  3548. if (row != null)
  3549. {
  3550. if (row["F_QuestionType"] != null)
  3551. {
  3552. model.F_QuestionType = row["F_QuestionType"].ToString();
  3553. }
  3554. if (row["number"] != null && row["number"].ToString() != "")
  3555. {
  3556. model.number = int.Parse(row["number"].ToString());
  3557. }
  3558. }
  3559. return model;
  3560. }
  3561. private DataTable getData(string stime, string endtime, int deptid = 0)
  3562. {
  3563. DataTable dtNew = new DataTable();
  3564. #region 添加表格标题
  3565. //部门,工号,姓名,建单量,接单量,未处理量,异常量,已处理量
  3566. dtNew.Columns.Add("部门");
  3567. dtNew.Columns.Add("工号");
  3568. dtNew.Columns.Add("姓名");
  3569. dtNew.Columns.Add("建单量");
  3570. dtNew.Columns.Add("接单量");
  3571. dtNew.Columns.Add("未处理量");
  3572. dtNew.Columns.Add("异常量");
  3573. dtNew.Columns.Add("已处理量");
  3574. #endregion
  3575. #region 筛选条件
  3576. string sqlwo = " isdel=0 "; string sqluser = " F_DeleteFlag=0 ";string sqldept = " F_State=1 ";
  3577. if (stime != null && stime.Trim() != "")
  3578. {
  3579. sqlwo += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  3580. }
  3581. if (endtime != null && endtime.Trim() != "")
  3582. {
  3583. sqlwo += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
  3584. }
  3585. if (deptid > 0)
  3586. {
  3587. sqluser += " and F_DeptId=" + deptid;
  3588. sqldept += " and F_DeptId=" + deptid;
  3589. }
  3590. #endregion
  3591. //获取部门
  3592. var depts = new BLL.T_Sys_Department().GetModelList(sqldept);
  3593. //获取人员
  3594. var users = new BLL.T_Sys_UserAccount().GetModelList(sqluser);
  3595. #region 获取工单量
  3596. //--创建量,接单量,未处理量,异常量,已处理量
  3597. //--创建量
  3598. string sqlcreate = $" select CreateUser,COUNT(1) con from T_Wo_WorkOrder where " +sqlwo+" group by CreateUser";
  3599. DataTable dtcreate = DbHelperSQL.Query(sqlcreate).Tables[0];
  3600. //--接单量
  3601. string sqljd = $"select F_NextUser, COUNT(1) con from( " +
  3602. "select F_WoID, F_NextUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.assign + " " +
  3603. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  3604. "group by F_WoID, F_NextUser) t group by F_NextUser ";
  3605. DataTable dtjd= DbHelperSQL.Query(sqljd).Tables[0];
  3606. //--未处理量
  3607. string sqlwcl = $"select F_CreateUser, COUNT(1) con from( " +
  3608. "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState < " + (int)EnumWorkOrderState.finish + " " +
  3609. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  3610. "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
  3611. DataTable dtwcl = DbHelperSQL.Query(sqlwcl).Tables[0];
  3612. //--异常量:以提交异常退回的人员为准
  3613. string sqlyc = $"select F_CreateUser, COUNT(1) con from( " +
  3614. "select F_WoID, F_CreateUser from T_Wo_WorkOrderItem_New where F_ItemType = 1 and F_WoState = " + (int)EnumWorkOrderState.abreback + " " +
  3615. "and F_WoID in (select ID FROM T_Wo_WorkOrder where " + sqlwo + ") " +
  3616. "group by F_WoID, F_CreateUser) t group by F_CreateUser ";
  3617. DataTable dtyc = DbHelperSQL.Query(sqlyc).Tables[0];
  3618. //--已处理量:以最终处理人为准
  3619. string sqlwj = $" select LastDealUser,COUNT(1) con from T_Wo_WorkOrder where " + sqlwo + " and State=" + (int)EnumWorkOrderState.finish + " group by LastDealUser";
  3620. DataTable dtwj = DbHelperSQL.Query(sqlwj).Tables[0];
  3621. #endregion
  3622. foreach (var user in users)
  3623. {
  3624. DataRow drNew = dtNew.NewRow();
  3625. //部门,
  3626. var dept = depts.Where(d => d.F_DeptId == user.F_DeptId).FirstOrDefault();
  3627. var deptname = dept != null ? dept.F_DeptName : "";
  3628. //建单量,
  3629. var createcount = "0";
  3630. var createRows = dtcreate.Select(" CreateUser = '" + user.F_UserCode + "'");
  3631. if (createRows.Length > 0)
  3632. createcount = createRows[0]["con"].ToString();
  3633. //接单量,
  3634. var jdcount = "0";
  3635. var jdRows = dtjd.Select(" F_NextUser = '" + user.F_UserCode + "'");
  3636. if (jdRows.Length > 0)
  3637. jdcount = jdRows[0]["con"].ToString();
  3638. //未处理量,
  3639. var wclcount = "0";
  3640. var wclRows=dtwcl.Select(" F_CreateUser = '" + user.F_UserCode + "'");
  3641. if (wclRows.Length > 0)
  3642. wclcount = wclRows[0]["con"].ToString();
  3643. //异常量,
  3644. var yccount = "0";
  3645. var ycRows = dtyc.Select(" F_CreateUser = '" + user.F_UserCode + "'");
  3646. if (ycRows.Length>0)
  3647. yccount=ycRows[0]["con"].ToString();
  3648. //已处理量
  3649. var wjcount = "0";
  3650. var wjRows = dtwj.Select(" LastDealUser = '" + user.F_UserCode + "'");
  3651. if (wjRows.Length > 0)
  3652. wjcount= wjRows[0]["con"].ToString();
  3653. drNew["部门"] = deptname;
  3654. drNew["工号"] = user.F_UserCode;
  3655. drNew["姓名"] = user.F_UserName;
  3656. drNew["建单量"] = createcount;
  3657. drNew["接单量"] = jdcount;
  3658. drNew["未处理量"] = wclcount;
  3659. drNew["异常量"] = yccount;
  3660. drNew["已处理量"] = wjcount;
  3661. dtNew.Rows.Add(drNew);
  3662. }
  3663. return dtNew;
  3664. }
  3665. }
  3666. }
  3667. public class DynamicModel : DynamicObject
  3668. {
  3669. private string propertyName;
  3670. public string PropertyName
  3671. {
  3672. get { return propertyName; }
  3673. set { propertyName = value; }
  3674. }
  3675. // The inner dictionary.
  3676. Dictionary<string, object> dicProperty
  3677. = new Dictionary<string, object>();
  3678. public Dictionary<string, object> DicProperty
  3679. {
  3680. get
  3681. {
  3682. return dicProperty;
  3683. }
  3684. }
  3685. // This property returns the number of elements
  3686. // in the inner dictionary.
  3687. public int Count
  3688. {
  3689. get
  3690. {
  3691. return dicProperty.Count;
  3692. }
  3693. }
  3694. // If you try to get a value of a property
  3695. // not defined in the class, this method is called.
  3696. public override bool TryGetMember(
  3697. GetMemberBinder binder, out object result)
  3698. {
  3699. // Converting the property name to lowercase
  3700. // so that property names become case-insensitive.
  3701. string name = binder.Name;
  3702. // If the property name is found in a dictionary,
  3703. // set the result parameter to the property value and return true.
  3704. // Otherwise, return false.
  3705. return dicProperty.TryGetValue(name, out result);
  3706. }
  3707. // If you try to set a value of a property that is
  3708. // not defined in the class, this method is called.
  3709. public override bool TrySetMember(
  3710. SetMemberBinder binder, object value)
  3711. {
  3712. // Converting the property name to lowercase
  3713. // so that property names become case-insensitive.
  3714. if (binder.Name == "Property")
  3715. {
  3716. dicProperty[PropertyName] = value;
  3717. }
  3718. else
  3719. {
  3720. dicProperty[binder.Name] = value;
  3721. }
  3722. // You can always add a value to a dictionary,
  3723. // so this method always returns true.
  3724. return true;
  3725. }
  3726. }